From 2e7891080667c59ac80f788eef4d59d447595772 Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Wed, 2 Jun 2021 08:40:30 -0700 Subject: [PATCH 001/251] MDEV-25635 Assertion failure when pushing from HAVING into WHERE of view This bug could manifest itself after pushing a where condition over a mergeable derived table / view / CTE DT into a grouping view / derived table / CTE V whose item list contained set functions with constant arguments such as MIN(2), SUM(1) etc. In such cases the field references used in the condition pushed into the view V that correspond set functions are wrapped into Item_direct_view_ref wrappers. Due to a wrong implementation of the virtual method const_item() for the class Item_direct_view_ref the wrapped set functions with constant arguments could be erroneously taken for constant items. This could lead to a wrong result set returned by the main select query in 10.2. In 10.4 where a possibility of pushing condition from HAVING into WHERE had been added this could cause a crash. Approved by Sergey Petrunya --- mysql-test/r/derived_cond_pushdown.result | 39 +++++++++++++++++++++++ mysql-test/t/derived_cond_pushdown.test | 25 +++++++++++++++ sql/item.h | 5 ++- 3 files changed, 68 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/derived_cond_pushdown.result b/mysql-test/r/derived_cond_pushdown.result index 25237aa11a9..28532ae88a4 100644 --- a/mysql-test/r/derived_cond_pushdown.result +++ b/mysql-test/r/derived_cond_pushdown.result @@ -10634,4 +10634,43 @@ m 7 drop view v1; drop table t1; +# +# MDEV-25635: pushdown into grouping view using aggregate functions +# with constant arguments via a mergeable derived table +# +create table t1 (a int); +insert into t1 values (3), (7), (1), (3), (7), (7), (3); +create view v1 as select a, sum(1) as f, sum(1) as g from t1 group by a; +select * from v1; +a f g +1 1 1 +3 3 3 +7 3 3 +select * from (select * from v1) as dt where a=f and a=g; +a f g +1 1 1 +3 3 3 +explain extended select * from (select * from v1) as dt where a=f and a=g; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY ALL NULL NULL NULL NULL 7 100.00 Using where +3 DERIVED t1 ALL NULL NULL NULL NULL 7 100.00 Using temporary; Using filesort +Warnings: +Note 1003 select `v1`.`a` AS `a`,`v1`.`f` AS `f`,`v1`.`g` AS `g` from `test`.`v1` where `v1`.`a` = `v1`.`f` and `v1`.`a` = `v1`.`g` +create view v2 as select a, min(1) as f, min(1) as g from t1 group by a; +select * from v2; +a f g +1 1 1 +3 1 1 +7 1 1 +select * from (select * from v2) as dt where a=f and a=g; +a f g +1 1 1 +explain extended select * from (select * from v2) as dt where a=f and a=g; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY ALL NULL NULL NULL NULL 7 100.00 Using where +3 DERIVED t1 ALL NULL NULL NULL NULL 7 100.00 Using temporary; Using filesort +Warnings: +Note 1003 select `v2`.`a` AS `a`,`v2`.`f` AS `f`,`v2`.`g` AS `g` from `test`.`v2` where `v2`.`f` = `v2`.`a` and `v2`.`g` = `v2`.`a` +drop view v1,v2; +drop table t1; # End of 10.2 tests diff --git a/mysql-test/t/derived_cond_pushdown.test b/mysql-test/t/derived_cond_pushdown.test index 31b49047bf1..58f38ac1e5a 100644 --- a/mysql-test/t/derived_cond_pushdown.test +++ b/mysql-test/t/derived_cond_pushdown.test @@ -2212,4 +2212,29 @@ select * from v1 where m > 0; drop view v1; drop table t1; +--echo # +--echo # MDEV-25635: pushdown into grouping view using aggregate functions +--echo # with constant arguments via a mergeable derived table +--echo # + +create table t1 (a int); +insert into t1 values (3), (7), (1), (3), (7), (7), (3); + +create view v1 as select a, sum(1) as f, sum(1) as g from t1 group by a; +select * from v1; +let $q1= +select * from (select * from v1) as dt where a=f and a=g; +eval $q1; +eval explain extended $q1; + +create view v2 as select a, min(1) as f, min(1) as g from t1 group by a; +select * from v2; +let $q2= +select * from (select * from v2) as dt where a=f and a=g; +eval $q2; +eval explain extended $q2; + +drop view v1,v2; +drop table t1; + --echo # End of 10.2 tests diff --git a/sql/item.h b/sql/item.h index c94709c733e..76be66d2a7c 100644 --- a/sql/item.h +++ b/sql/item.h @@ -4952,7 +4952,10 @@ public: table_map used_tables() const; void update_used_tables(); table_map not_null_tables() const; - bool const_item() const { return used_tables() == 0; } + bool const_item() const + { + return (*ref)->const_item() && (null_ref_table == NO_NULL_TABLE); + } TABLE *get_null_ref_table() const { return null_ref_table; } bool walk(Item_processor processor, bool walk_subquery, void *arg) { From fa0bbff032bc5717715fdf32ce4c8ebdfcf73944 Mon Sep 17 00:00:00 2001 From: Monty Date: Wed, 2 Jun 2021 14:05:12 +0300 Subject: [PATCH 002/251] Fixed that compile-pentium64-valgrind-max works MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Removed Tokudb (no need to test this anymore with valgrind) - Added __attribute__(unused)) to a few places to be able to compile even if valgrind/memcheck.h is not installed. Reviewer: Marko Mäkelä --- BUILD/compile-pentium64-valgrind-max | 2 +- sql/field.cc | 2 +- storage/innobase/include/srv0mon.h | 2 +- storage/innobase/page/page0cur.cc | 26 +++++++++++++------------- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/BUILD/compile-pentium64-valgrind-max b/BUILD/compile-pentium64-valgrind-max index 0653fb7fe75..84e78805246 100755 --- a/BUILD/compile-pentium64-valgrind-max +++ b/BUILD/compile-pentium64-valgrind-max @@ -33,6 +33,6 @@ path=`dirname $0` . "$path/SETUP.sh" extra_flags="$pentium64_cflags $debug_cflags $valgrind_flags" -extra_configs="$pentium_configs $debug_configs $valgrind_configs $max_configs" +extra_configs="$pentium_configs $debug_configs $valgrind_configs $max_configs --without-plugin-tokudb" . "$path/FINISH.sh" diff --git a/sql/field.cc b/sql/field.cc index 89c51288de8..cf4bb4ef4f2 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -7806,7 +7806,7 @@ my_decimal *Field_varstring::val_decimal(my_decimal *decimal_value) #ifdef HAVE_valgrind void Field_varstring::mark_unused_memory_as_defined() { - uint used_length= get_length(); + uint used_length __attribute__((unused)) = get_length(); MEM_MAKE_DEFINED(get_data() + used_length, field_length - used_length); } #endif diff --git a/storage/innobase/include/srv0mon.h b/storage/innobase/include/srv0mon.h index 58e36676398..934f88ac8ae 100644 --- a/storage/innobase/include/srv0mon.h +++ b/storage/innobase/include/srv0mon.h @@ -656,7 +656,7 @@ Use MONITOR_DEC if appropriate mutex protection exists. #ifdef HAVE_valgrind # define MONITOR_CHECK_DEFINED(value) do { \ - mon_type_t m = value; \ + mon_type_t m __attribute__((unused))= value; \ MEM_CHECK_DEFINED(&m, sizeof m); \ } while (0) #else /* HAVE_valgrind */ diff --git a/storage/innobase/page/page0cur.cc b/storage/innobase/page/page0cur.cc index 9bf9fe66b33..14a0ab8aa8a 100644 --- a/storage/innobase/page/page0cur.cc +++ b/storage/innobase/page/page0cur.cc @@ -1299,12 +1299,12 @@ page_cur_insert_rec_low( #ifdef HAVE_valgrind { - const void* rec_start - = rec - rec_offs_extra_size(offsets); - ulint extra_size - = rec_offs_extra_size(offsets) - - (rec_offs_comp(offsets) - ? REC_N_NEW_EXTRA_BYTES + const void* rec_start __attribute__((unused)) + = rec - rec_offs_extra_size(offsets); + ulint extra_size __attribute__((unused)) + = rec_offs_extra_size(offsets) + - (rec_offs_comp(offsets) + ? REC_N_NEW_EXTRA_BYTES : REC_N_OLD_EXTRA_BYTES); /* All data bytes of the record must be valid. */ @@ -1530,13 +1530,13 @@ page_cur_insert_rec_zip( #ifdef HAVE_valgrind { - const void* rec_start - = rec - rec_offs_extra_size(offsets); - ulint extra_size - = rec_offs_extra_size(offsets) - - (rec_offs_comp(offsets) - ? REC_N_NEW_EXTRA_BYTES - : REC_N_OLD_EXTRA_BYTES); + const void* rec_start __attribute__((unused)) + = rec - rec_offs_extra_size(offsets); + ulint extra_size __attribute__((unused)) + = rec_offs_extra_size(offsets) + - (rec_offs_comp(offsets) + ? REC_N_NEW_EXTRA_BYTES + : REC_N_OLD_EXTRA_BYTES); /* All data bytes of the record must be valid. */ MEM_CHECK_DEFINED(rec, rec_offs_data_size(offsets)); From 5c896472b6cb315fc54091a342ec37a7c4b5421d Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 2 Jun 2021 23:10:21 +0200 Subject: [PATCH 003/251] MDEV-25672 table alias from previous statement interferes later commands only perform the "correct table name" check for *new* generated columns, but not for already existing ones - they're guaranteed to be valid --- mysql-test/suite/vcol/r/vcol_syntax.result | 11 ++++++++++- mysql-test/suite/vcol/t/vcol_syntax.test | 17 +++++++++++++---- sql/item.h | 2 +- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/mysql-test/suite/vcol/r/vcol_syntax.result b/mysql-test/suite/vcol/r/vcol_syntax.result index c8983f34c93..0063f38ea36 100644 --- a/mysql-test/suite/vcol/r/vcol_syntax.result +++ b/mysql-test/suite/vcol/r/vcol_syntax.result @@ -1,4 +1,3 @@ -drop table if exists t1; set @OLD_SQL_MODE=@@SESSION.SQL_MODE; create table t1 (a int, b int generated always as (a+1)); show create table t1; @@ -88,3 +87,13 @@ create table t1 (x int, y int default test2.t1.x); ERROR 42S22: Unknown column '`test2`.`t1`.`x`' in 'DEFAULT' create table t1 (x int, check (test2.t1.x > 0)); ERROR 42S22: Unknown column '`test2`.`t1`.`x`' in 'CHECK' +# +# MDEV-25672 table alias from previous statement interferes later commands +# +create table t1 (a int, v_a int generated always as (a)); +update t1 as x set a = 1; +alter table t1 force; +drop table t1; +# +# End of 10.2 tests +# diff --git a/mysql-test/suite/vcol/t/vcol_syntax.test b/mysql-test/suite/vcol/t/vcol_syntax.test index f425b52ab79..3c8a50a7f36 100644 --- a/mysql-test/suite/vcol/t/vcol_syntax.test +++ b/mysql-test/suite/vcol/t/vcol_syntax.test @@ -1,10 +1,6 @@ # # test syntax # ---disable_warnings -drop table if exists t1; ---enable_warnings - set @OLD_SQL_MODE=@@SESSION.SQL_MODE; create table t1 (a int, b int generated always as (a+1)); show create table t1; @@ -72,3 +68,16 @@ create table t1 (x int, y int check (y > test2.t1.x)); create table t1 (x int, y int default test2.t1.x); --error ER_BAD_FIELD_ERROR create table t1 (x int, check (test2.t1.x > 0)); + +--echo # +--echo # MDEV-25672 table alias from previous statement interferes later commands +--echo # +create table t1 (a int, v_a int generated always as (a)); +update t1 as x set a = 1; +alter table t1 force; +drop table t1; + + +--echo # +--echo # End of 10.2 tests +--echo # diff --git a/sql/item.h b/sql/item.h index 76be66d2a7c..cc1914a7ad4 100644 --- a/sql/item.h +++ b/sql/item.h @@ -2841,7 +2841,7 @@ public: bool check_table_name_processor(void *arg) { Check_table_name_prm &p= *(Check_table_name_prm *) arg; - if (p.table_name.length && table_name) + if (!field && p.table_name.length && table_name) { DBUG_ASSERT(p.db.length); if ((db_name && From 663bc849b5a26a5325adf009a8e8fa9155c6b833 Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Wed, 26 May 2021 23:41:59 -0700 Subject: [PATCH 004/251] MDEV-25714 Join using derived with aggregation returns incorrect results If a join query uses a derived table (view / CTE) with GROUP BY clause then the execution plan for such join may employ split optimization. When this optimization is employed the derived table is not materialized. Rather only some partitions of the derived table are subject to grouping. Split optimization can be applied only if: - there are some indexes over the tables used in the join specifying the derived table whose prefixes partially cover the field items used in the GROUP BY list (such indexes are called splitting indexes) - the WHERE condition of the join query contains conjunctive equalities between columns of the derived table that comprise major parts of splitting indexes and columns of the other join tables. When the optimizer evaluates extending of a partial join by the rows of the derived table it always considers a possibility of using split optimization. Different splitting indexes can be used depending on the extended partial join. At some rare conditions, for example, when there is a non-splitting covering index for a table joined in the join specifying the derived table usage of a splitting index to produce rows needed for grouping may be still less beneficial than usage of such covering index without any splitting technique. The function JOIN_TAB::choose_best_splitting() must take this into account. Approved by Oleksandr Byelkin --- mysql-test/main/derived_cond_pushdown.result | 2 +- mysql-test/main/derived_split_innodb.result | 61 ++++++++++++++++++++ mysql-test/main/derived_split_innodb.test | 37 ++++++++++++ sql/opt_split.cc | 27 +++++++-- 4 files changed, 121 insertions(+), 6 deletions(-) diff --git a/mysql-test/main/derived_cond_pushdown.result b/mysql-test/main/derived_cond_pushdown.result index f3d63b5887f..5fc01112642 100644 --- a/mysql-test/main/derived_cond_pushdown.result +++ b/mysql-test/main/derived_cond_pushdown.result @@ -16712,7 +16712,7 @@ EXPLAIN EXTENDED SELECT * FROM v1 JOIN v2 ON v1.f = v2.f; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables -3 LATERAL DERIVED NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table Warnings: Note 1003 /* select#1 */ select NULL AS `f`,`v2`.`f` AS `f` from `test`.`t1` `a` straight_join `test`.`t1` `b` join `test`.`v2` where 0 DROP VIEW v1,v2; diff --git a/mysql-test/main/derived_split_innodb.result b/mysql-test/main/derived_split_innodb.result index 0b57e72b821..7ea3b689f23 100644 --- a/mysql-test/main/derived_split_innodb.result +++ b/mysql-test/main/derived_split_innodb.result @@ -174,3 +174,64 @@ id select_type table type possible_keys key key_len ref rows Extra 2 LATERAL DERIVED t1 ref a,a_2 a 5 test.t1.a 1 Using where; Using temporary; Using filesort 2 LATERAL DERIVED t2 ref c c 5 test.t1.b 1 Using index DROP TABLE t1, t2; +# +# Bug mdev-25714: usage non-splitting covering index is cheaper than +# usage of the best splitting index for one group +# +create table t1 ( +id int not null, itemid int not null, index idx (itemid) +) engine=innodb; +insert into t1 values (1, 2), (2,2), (4,2), (4,2), (0,3), (3,3); +create table t2 (id int not null) engine=innodb; +insert into t2 values (2); +create table t3 ( +id int not null, itemid int not null, userid int not null, primary key (id), +index idx1 (userid, itemid), index idx2 (itemid) +) engine innodb; +insert into t3 values (1,1,1), (2,1,1), (3,2,1), (4,2,1), (5,3,1); +analyze table t1,t2,t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +set optimizer_switch='split_materialized=on'; +explain select t1.id, t1.itemid, dt.id, t2.id +from t1, +(select itemid, max(id) as id from t3 where userid = 1 group by itemid) dt, +t2 +where t1.id = dt.id and t1.itemid = dt.itemid and t2.id=t1.itemid; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t2 ALL NULL NULL NULL NULL 1 +1 PRIMARY t1 ref idx idx 4 test.t2.id 1 +1 PRIMARY ref key0 key0 9 test.t2.id,test.t1.id 2 +2 DERIVED t3 ref idx1,idx2 idx1 4 const 5 Using where; Using index +select t1.id, t1.itemid, dt.id, t2.id +from t1, +(select itemid, max(id) as id from t3 where userid = 1 group by itemid) dt, +t2 +where t1.id = dt.id and t1.itemid = dt.itemid and t2.id=t1.itemid; +id itemid id id +4 2 4 2 +4 2 4 2 +set optimizer_switch='split_materialized=off'; +explain select t1.id, t1.itemid, dt.id, t2.id +from t1, +(select itemid, max(id) as id from t3 where userid = 1 group by itemid) dt, +t2 +where t1.id = dt.id and t1.itemid = dt.itemid and t2.id=t1.itemid; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t2 ALL NULL NULL NULL NULL 1 +1 PRIMARY t1 ref idx idx 4 test.t2.id 1 +1 PRIMARY ref key0 key0 9 test.t2.id,test.t1.id 2 +2 DERIVED t3 ref idx1 idx1 4 const 5 Using where; Using index +select t1.id, t1.itemid, dt.id, t2.id +from t1, +(select itemid, max(id) as id from t3 where userid = 1 group by itemid) dt, +t2 +where t1.id = dt.id and t1.itemid = dt.itemid and t2.id=t1.itemid; +id itemid id id +4 2 4 2 +4 2 4 2 +drop table t1,t2,t3; +set optimizer_switch='split_materialized=default'; +# End of 10.3 tests diff --git a/mysql-test/main/derived_split_innodb.test b/mysql-test/main/derived_split_innodb.test index 19a6ecf216f..6f33c71eede 100644 --- a/mysql-test/main/derived_split_innodb.test +++ b/mysql-test/main/derived_split_innodb.test @@ -150,3 +150,40 @@ eval set statement optimizer_switch='split_materialized=on' for $query; DROP TABLE t1, t2; +--echo # +--echo # Bug mdev-25714: usage non-splitting covering index is cheaper than +--echo # usage of the best splitting index for one group +--echo # + +create table t1 ( + id int not null, itemid int not null, index idx (itemid) +) engine=innodb; +insert into t1 values (1, 2), (2,2), (4,2), (4,2), (0,3), (3,3); +create table t2 (id int not null) engine=innodb; +insert into t2 values (2); +create table t3 ( + id int not null, itemid int not null, userid int not null, primary key (id), + index idx1 (userid, itemid), index idx2 (itemid) +) engine innodb; +insert into t3 values (1,1,1), (2,1,1), (3,2,1), (4,2,1), (5,3,1); +analyze table t1,t2,t3; + +let $q= +select t1.id, t1.itemid, dt.id, t2.id + from t1, + (select itemid, max(id) as id from t3 where userid = 1 group by itemid) dt, + t2 + where t1.id = dt.id and t1.itemid = dt.itemid and t2.id=t1.itemid; + +set optimizer_switch='split_materialized=on'; +eval explain $q; +eval $q; + +set optimizer_switch='split_materialized=off'; +eval explain $q; +eval $q; + +drop table t1,t2,t3; +set optimizer_switch='split_materialized=default'; + +--echo # End of 10.3 tests diff --git a/sql/opt_split.cc b/sql/opt_split.cc index c3a2d03a93b..edf9ae3deff 100644 --- a/sql/opt_split.cc +++ b/sql/opt_split.cc @@ -960,11 +960,7 @@ SplM_plan_info * JOIN_TAB::choose_best_splitting(double record_count, in the cache */ spl_plan= spl_opt_info->find_plan(best_table, best_key, best_key_parts); - if (!spl_plan && - (spl_plan= (SplM_plan_info *) thd->alloc(sizeof(SplM_plan_info))) && - (spl_plan->best_positions= - (POSITION *) thd->alloc(sizeof(POSITION) * join->table_count)) && - !spl_opt_info->plan_cache.push_back(spl_plan)) + if (!spl_plan) { /* The plan for the chosen key has not been found in the cache. @@ -974,6 +970,27 @@ SplM_plan_info * JOIN_TAB::choose_best_splitting(double record_count, reset_validity_vars_for_keyuses(best_key_keyuse_ext_start, best_table, best_key, remaining_tables, true); choose_plan(join, all_table_map & ~join->const_table_map); + + /* + Check that the chosen plan is really a splitting plan. + If not or if there is not enough memory to save the plan in the cache + then just return with no splitting plan. + */ + POSITION *first_non_const_pos= join->best_positions + join->const_tables; + TABLE *table= first_non_const_pos->table->table; + key_map spl_keys= table->keys_usable_for_splitting; + if (!(first_non_const_pos->key && + spl_keys.is_set(first_non_const_pos->key->key)) || + !(spl_plan= (SplM_plan_info *) thd->alloc(sizeof(SplM_plan_info))) || + !(spl_plan->best_positions= + (POSITION *) thd->alloc(sizeof(POSITION) * join->table_count)) || + spl_opt_info->plan_cache.push_back(spl_plan)) + { + reset_validity_vars_for_keyuses(best_key_keyuse_ext_start, best_table, + best_key, remaining_tables, false); + return 0; + } + spl_plan->keyuse_ext_start= best_key_keyuse_ext_start; spl_plan->table= best_table; spl_plan->key= best_key; From 0b797130c674a4dd8b8dcf35d3ade38353e19284 Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Wed, 26 May 2021 23:41:59 -0700 Subject: [PATCH 005/251] MDEV-25714 Join using derived with aggregation returns incorrect results If a join query uses a derived table (view / CTE) with GROUP BY clause then the execution plan for such join may employ split optimization. When this optimization is employed the derived table is not materialized. Rather only some partitions of the derived table are subject to grouping. Split optimization can be applied only if: - there are some indexes over the tables used in the join specifying the derived table whose prefixes partially cover the field items used in the GROUP BY list (such indexes are called splitting indexes) - the WHERE condition of the join query contains conjunctive equalities between columns of the derived table that comprise major parts of splitting indexes and columns of the other join tables. When the optimizer evaluates extending of a partial join by the rows of the derived table it always considers a possibility of using split optimization. Different splitting indexes can be used depending on the extended partial join. At some rare conditions, for example, when there is a non-splitting covering index for a table joined in the join specifying the derived table usage of a splitting index to produce rows needed for grouping may be still less beneficial than usage of such covering index without any splitting technique. The function JOIN_TAB::choose_best_splitting() must take this into account. Approved by Oleksandr Byelkin --- mysql-test/main/derived_cond_pushdown.result | 2 +- mysql-test/main/derived_split_innodb.result | 61 ++++++++++++++++++++ mysql-test/main/derived_split_innodb.test | 37 ++++++++++++ sql/opt_split.cc | 27 +++++++-- 4 files changed, 121 insertions(+), 6 deletions(-) diff --git a/mysql-test/main/derived_cond_pushdown.result b/mysql-test/main/derived_cond_pushdown.result index 7644e65a868..52d8ccd1b80 100644 --- a/mysql-test/main/derived_cond_pushdown.result +++ b/mysql-test/main/derived_cond_pushdown.result @@ -16703,7 +16703,7 @@ EXPLAIN EXTENDED SELECT * FROM v1 JOIN v2 ON v1.f = v2.f; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables -3 LATERAL DERIVED NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table +3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table Warnings: Note 1003 /* select#1 */ select NULL AS `f`,`v2`.`f` AS `f` from `test`.`t1` `a` straight_join `test`.`t1` `b` join `test`.`v2` where 0 DROP VIEW v1,v2; diff --git a/mysql-test/main/derived_split_innodb.result b/mysql-test/main/derived_split_innodb.result index ff71b7df097..6119145105b 100644 --- a/mysql-test/main/derived_split_innodb.result +++ b/mysql-test/main/derived_split_innodb.result @@ -175,3 +175,64 @@ id select_type table type possible_keys key key_len ref rows Extra 3 LATERAL DERIVED t1 ref a,a_2 a 5 test.t1.a 1 Using where; Using temporary; Using filesort 3 LATERAL DERIVED t2 ref c c 5 test.t1.b 1 Using index DROP TABLE t1, t2; +# +# Bug mdev-25714: usage non-splitting covering index is cheaper than +# usage of the best splitting index for one group +# +create table t1 ( +id int not null, itemid int not null, index idx (itemid) +) engine=innodb; +insert into t1 values (1, 2), (2,2), (4,2), (4,2), (0,3), (3,3); +create table t2 (id int not null) engine=innodb; +insert into t2 values (2); +create table t3 ( +id int not null, itemid int not null, userid int not null, primary key (id), +index idx1 (userid, itemid), index idx2 (itemid) +) engine innodb; +insert into t3 values (1,1,1), (2,1,1), (3,2,1), (4,2,1), (5,3,1); +analyze table t1,t2,t3; +Table Op Msg_type Msg_text +test.t1 analyze status OK +test.t2 analyze status OK +test.t3 analyze status OK +set optimizer_switch='split_materialized=on'; +explain select t1.id, t1.itemid, dt.id, t2.id +from t1, +(select itemid, max(id) as id from t3 where userid = 1 group by itemid) dt, +t2 +where t1.id = dt.id and t1.itemid = dt.itemid and t2.id=t1.itemid; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t2 ALL NULL NULL NULL NULL 1 +1 PRIMARY t1 ref idx idx 4 test.t2.id 1 +1 PRIMARY ref key0 key0 9 test.t2.id,test.t1.id 2 +2 DERIVED t3 ref idx1,idx2 idx1 4 const 5 Using where; Using index +select t1.id, t1.itemid, dt.id, t2.id +from t1, +(select itemid, max(id) as id from t3 where userid = 1 group by itemid) dt, +t2 +where t1.id = dt.id and t1.itemid = dt.itemid and t2.id=t1.itemid; +id itemid id id +4 2 4 2 +4 2 4 2 +set optimizer_switch='split_materialized=off'; +explain select t1.id, t1.itemid, dt.id, t2.id +from t1, +(select itemid, max(id) as id from t3 where userid = 1 group by itemid) dt, +t2 +where t1.id = dt.id and t1.itemid = dt.itemid and t2.id=t1.itemid; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t2 ALL NULL NULL NULL NULL 1 +1 PRIMARY t1 ref idx idx 4 test.t2.id 1 +1 PRIMARY ref key0 key0 9 test.t2.id,test.t1.id 2 +2 DERIVED t3 ref idx1 idx1 4 const 5 Using where; Using index +select t1.id, t1.itemid, dt.id, t2.id +from t1, +(select itemid, max(id) as id from t3 where userid = 1 group by itemid) dt, +t2 +where t1.id = dt.id and t1.itemid = dt.itemid and t2.id=t1.itemid; +id itemid id id +4 2 4 2 +4 2 4 2 +drop table t1,t2,t3; +set optimizer_switch='split_materialized=default'; +# End of 10.3 tests diff --git a/mysql-test/main/derived_split_innodb.test b/mysql-test/main/derived_split_innodb.test index 19a6ecf216f..6f33c71eede 100644 --- a/mysql-test/main/derived_split_innodb.test +++ b/mysql-test/main/derived_split_innodb.test @@ -150,3 +150,40 @@ eval set statement optimizer_switch='split_materialized=on' for $query; DROP TABLE t1, t2; +--echo # +--echo # Bug mdev-25714: usage non-splitting covering index is cheaper than +--echo # usage of the best splitting index for one group +--echo # + +create table t1 ( + id int not null, itemid int not null, index idx (itemid) +) engine=innodb; +insert into t1 values (1, 2), (2,2), (4,2), (4,2), (0,3), (3,3); +create table t2 (id int not null) engine=innodb; +insert into t2 values (2); +create table t3 ( + id int not null, itemid int not null, userid int not null, primary key (id), + index idx1 (userid, itemid), index idx2 (itemid) +) engine innodb; +insert into t3 values (1,1,1), (2,1,1), (3,2,1), (4,2,1), (5,3,1); +analyze table t1,t2,t3; + +let $q= +select t1.id, t1.itemid, dt.id, t2.id + from t1, + (select itemid, max(id) as id from t3 where userid = 1 group by itemid) dt, + t2 + where t1.id = dt.id and t1.itemid = dt.itemid and t2.id=t1.itemid; + +set optimizer_switch='split_materialized=on'; +eval explain $q; +eval $q; + +set optimizer_switch='split_materialized=off'; +eval explain $q; +eval $q; + +drop table t1,t2,t3; +set optimizer_switch='split_materialized=default'; + +--echo # End of 10.3 tests diff --git a/sql/opt_split.cc b/sql/opt_split.cc index 395422de3c3..d272638f00c 100644 --- a/sql/opt_split.cc +++ b/sql/opt_split.cc @@ -960,11 +960,7 @@ SplM_plan_info * JOIN_TAB::choose_best_splitting(double record_count, in the cache */ spl_plan= spl_opt_info->find_plan(best_table, best_key, best_key_parts); - if (!spl_plan && - (spl_plan= (SplM_plan_info *) thd->alloc(sizeof(SplM_plan_info))) && - (spl_plan->best_positions= - (POSITION *) thd->alloc(sizeof(POSITION) * join->table_count)) && - !spl_opt_info->plan_cache.push_back(spl_plan)) + if (!spl_plan) { /* The plan for the chosen key has not been found in the cache. @@ -974,6 +970,27 @@ SplM_plan_info * JOIN_TAB::choose_best_splitting(double record_count, reset_validity_vars_for_keyuses(best_key_keyuse_ext_start, best_table, best_key, remaining_tables, true); choose_plan(join, all_table_map & ~join->const_table_map); + + /* + Check that the chosen plan is really a splitting plan. + If not or if there is not enough memory to save the plan in the cache + then just return with no splitting plan. + */ + POSITION *first_non_const_pos= join->best_positions + join->const_tables; + TABLE *table= first_non_const_pos->table->table; + key_map spl_keys= table->keys_usable_for_splitting; + if (!(first_non_const_pos->key && + spl_keys.is_set(first_non_const_pos->key->key)) || + !(spl_plan= (SplM_plan_info *) thd->alloc(sizeof(SplM_plan_info))) || + !(spl_plan->best_positions= + (POSITION *) thd->alloc(sizeof(POSITION) * join->table_count)) || + spl_opt_info->plan_cache.push_back(spl_plan)) + { + reset_validity_vars_for_keyuses(best_key_keyuse_ext_start, best_table, + best_key, remaining_tables, false); + return 0; + } + spl_plan->keyuse_ext_start= best_key_keyuse_ext_start; spl_plan->table= best_table; spl_plan->key= best_key; From 385f4316c3b8250943383145c115000ee153e3de Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Thu, 3 Jun 2021 20:43:04 -0700 Subject: [PATCH 006/251] Corrected the test case of MDEV-25714 in order to have the same EXPLAIN output as in 10.3 --- mysql-test/main/derived_split_innodb.result | 4 ++++ mysql-test/main/derived_split_innodb.test | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/mysql-test/main/derived_split_innodb.result b/mysql-test/main/derived_split_innodb.result index 6119145105b..63db8c94dde 100644 --- a/mysql-test/main/derived_split_innodb.result +++ b/mysql-test/main/derived_split_innodb.result @@ -190,6 +190,8 @@ id int not null, itemid int not null, userid int not null, primary key (id), index idx1 (userid, itemid), index idx2 (itemid) ) engine innodb; insert into t3 values (1,1,1), (2,1,1), (3,2,1), (4,2,1), (5,3,1); +set use_stat_tables='never'; +set optimizer_use_condition_selectivity=1; analyze table t1,t2,t3; Table Op Msg_type Msg_text test.t1 analyze status OK @@ -235,4 +237,6 @@ id itemid id id 4 2 4 2 drop table t1,t2,t3; set optimizer_switch='split_materialized=default'; +set use_stat_tables=default; +set optimizer_use_condition_selectivity=default; # End of 10.3 tests diff --git a/mysql-test/main/derived_split_innodb.test b/mysql-test/main/derived_split_innodb.test index 6f33c71eede..22793b448da 100644 --- a/mysql-test/main/derived_split_innodb.test +++ b/mysql-test/main/derived_split_innodb.test @@ -166,6 +166,8 @@ create table t3 ( index idx1 (userid, itemid), index idx2 (itemid) ) engine innodb; insert into t3 values (1,1,1), (2,1,1), (3,2,1), (4,2,1), (5,3,1); +set use_stat_tables='never'; +set optimizer_use_condition_selectivity=1; analyze table t1,t2,t3; let $q= @@ -185,5 +187,7 @@ eval $q; drop table t1,t2,t3; set optimizer_switch='split_materialized=default'; +set use_stat_tables=default; +set optimizer_use_condition_selectivity=default; --echo # End of 10.3 tests From 2d38c5e64edbfdc8368954775880c2d677fbd195 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 4 Jun 2021 09:35:18 +0300 Subject: [PATCH 007/251] MDEV-17749 fixup: ./mtr --embedded main.lock_kill (again) --- mysql-test/main/lock_kill.test | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/main/lock_kill.test b/mysql-test/main/lock_kill.test index dfeebbc4f6a..2c1396e5ff3 100644 --- a/mysql-test/main/lock_kill.test +++ b/mysql-test/main/lock_kill.test @@ -17,7 +17,7 @@ LOCK TABLE t1 WRITE; eval KILL $conid; --enable_query_log --connection con1 ---error 0,2013,ER_CONNECTION_KILLED +--error 0,2006,2013,ER_CONNECTION_KILLED reap; --connection default --disconnect con1 @@ -35,7 +35,7 @@ LOCK TABLE t1 WRITE, t2 WRITE; eval KILL $conid; --enable_query_log --connection con1 ---error 0,2013,ER_CONNECTION_KILLED +--error 0,2006,2013,ER_CONNECTION_KILLED reap; --connection default --disconnect con1 From 7eed97ed9fe2b0c1e69167576be12759dffcd926 Mon Sep 17 00:00:00 2001 From: Anel Husakovic Date: Wed, 26 May 2021 14:15:26 +0200 Subject: [PATCH 008/251] MDEV-25777: JAVA_INCLUDE_PATH and JAVA_INCLUDE_PATH2 not found with out of source configuration and Ninja generator - As solution `PLUGIN_CONNECT=NO` use early check to disable plugin: Solution suggested by wlad@mariadb.com - `JNI_FOUND` is a internal result variable and should be set with cached library and header variables (like `JAVA_INCLUDE_PATH`) defined. * Note: wrapper cmake/FindJNI.cmake runs first time and cmake native Find returns only cached variable, like `JAVA_INCLUDE_PATH`, results variable are not cached). Reviewed by: serg@mariadb.com --- cmake/FindJNI.cmake | 2 +- storage/connect/CMakeLists.txt | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cmake/FindJNI.cmake b/cmake/FindJNI.cmake index 12305d7c86d..b2c6f849c87 100644 --- a/cmake/FindJNI.cmake +++ b/cmake/FindJNI.cmake @@ -1,4 +1,4 @@ -if(JAVA_AWT_LIBRARY) +if(JAVA_AWT_LIBRARY AND JAVA_INCLUDE_PATH) set(JNI_FOUND TRUE) return() endif() diff --git a/storage/connect/CMakeLists.txt b/storage/connect/CMakeLists.txt index e9533e8f3e5..d3632b689fe 100644 --- a/storage/connect/CMakeLists.txt +++ b/storage/connect/CMakeLists.txt @@ -13,6 +13,10 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA +IF(WITHOUT_DYNAMIC_PLUGINS OR WITH_NONE OR ("${PLUGIN_CONNECT}" STREQUAL "NO")) + RETURN() +ENDIF() + SET(CONNECT_PLUGIN_STATIC "connect") SET(CONNECT_PLUGIN_DYNAMIC "connect") From ddddfc33c7825609a25ce9531183a0b0fb97f206 Mon Sep 17 00:00:00 2001 From: Anel Husakovic Date: Fri, 4 Jun 2021 14:57:11 +0200 Subject: [PATCH 009/251] Fix mtr tests with file_key_managment extension for Windows Commit b5615eff0d00 introduced comment in result file during shutdown. In case of Windows for the tests involving `file_key_managment.so` as plugin-load-add the tests will be overwritten with .dll extension. The same happens with environment variable `$FILE_KEY_MANAGMENT_SO`. So the patch is removing the extension to be extension agnostic. Reviewed by: wlad@mariadb.com --- .../encrypted_master_switch_to_unencrypted.test | 2 +- .../suite/encryption/r/innodb-bad-key-change2.result | 12 ++++++------ .../suite/encryption/r/innodb-bad-key-change4.result | 6 +++--- .../encryption/r/innodb-encryption-disable.result | 4 ++-- .../encryption/r/innodb-remove-encryption.result | 2 +- .../suite/encryption/t/innodb-bad-key-change2.test | 12 ++++++------ .../suite/encryption/t/innodb-bad-key-change3.test | 6 +++--- .../suite/encryption/t/innodb-bad-key-change4.test | 6 +++--- .../encryption/t/innodb-encryption-disable.test | 4 ++-- .../suite/encryption/t/innodb-remove-encryption.test | 2 +- mysql-test/suite/maria/encrypt-wrong-key.test | 6 +++--- 11 files changed, 31 insertions(+), 31 deletions(-) diff --git a/mysql-test/suite/binlog_encryption/encrypted_master_switch_to_unencrypted.test b/mysql-test/suite/binlog_encryption/encrypted_master_switch_to_unencrypted.test index eec72d64066..1e1b0cbd353 100644 --- a/mysql-test/suite/binlog_encryption/encrypted_master_switch_to_unencrypted.test +++ b/mysql-test/suite/binlog_encryption/encrypted_master_switch_to_unencrypted.test @@ -65,7 +65,7 @@ INSERT INTO table1_no_encryption SELECT NULL,NOW(),b FROM table1_no_encryption; --echo # Part 2: restart master, now with binlog encryption --echo ##################################################### ---let $rpl_server_parameters= --encrypt-binlog=1 --plugin-load-add=$FILE_KEY_MANAGEMENT_SO --file-key-management --loose-file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys.txt +--let $rpl_server_parameters= --encrypt-binlog=1 --plugin-load-add=file_key_management --file-key-management --loose-file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys.txt --let $rpl_server_number= 1 --source restart_server.inc diff --git a/mysql-test/suite/encryption/r/innodb-bad-key-change2.result b/mysql-test/suite/encryption/r/innodb-bad-key-change2.result index 543c3bc29b2..af1028f1331 100644 --- a/mysql-test/suite/encryption/r/innodb-bad-key-change2.result +++ b/mysql-test/suite/encryption/r/innodb-bad-key-change2.result @@ -7,12 +7,12 @@ call mtr.add_suppression("InnoDB: Table `test`\\.`t1` is corrupted"); call mtr.add_suppression("InnoDB: Cannot delete tablespace .* because it is not found in the tablespace memory cache"); call mtr.add_suppression("InnoDB: ALTER TABLE `test`\\.`t1` DISCARD TABLESPACE failed to find tablespace"); call mtr.add_suppression("\\[ERROR\\] InnoDB: Cannot decrypt \\[page id: space="); -# restart: --plugin-load-add=file_key_management.so --file-key-management --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys2.txt +# restart: --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys2.txt SET GLOBAL innodb_file_per_table = ON; CREATE TABLE t1 (pk INT PRIMARY KEY, f VARCHAR(8)) ENGINE=InnoDB ENCRYPTED=YES ENCRYPTION_KEY_ID=4; INSERT INTO t1 VALUES (1,'foo'),(2,'bar'); -# restart: --plugin-load-add=file_key_management.so --file-key-management --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys3.txt +# restart: --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys3.txt SELECT * FROM t1; ERROR 42S02: Table 'test.t1' doesn't exist in engine SHOW WARNINGS; @@ -35,11 +35,11 @@ test.t1 check Error Table 'test.t1' doesn't exist in engine test.t1 check status Operation failed SHOW WARNINGS; Level Code Message -# restart: --plugin-load-add=file_key_management.so --file-key-management --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys2.txt +# restart: --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys2.txt FLUSH TABLES t1 FOR EXPORT; backup: t1 UNLOCK TABLES; -# restart: --plugin-load-add=file_key_management.so --file-key-management --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys3.txt +# restart: --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys3.txt ALTER TABLE t1 DISCARD TABLESPACE; ERROR 42S02: Table 'test.t1' doesn't exist in engine DROP TABLE t1; @@ -47,7 +47,7 @@ CREATE TABLE t1 (pk INT PRIMARY KEY, f VARCHAR(8)) ENGINE=InnoDB ENCRYPTED=YES ENCRYPTION_KEY_ID=4; ALTER TABLE t1 DISCARD TABLESPACE; restore: t1 .ibd and .cfg files -# restart: --plugin-load-add=file_key_management.so --file-key-management --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys2.txt +# restart: --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys2.txt ALTER TABLE t1 DISCARD TABLESPACE; Warnings: Warning 1814 Tablespace has been discarded for table `t1` @@ -61,7 +61,7 @@ t1 CREATE TABLE `t1` ( `f` varchar(8) DEFAULT NULL, PRIMARY KEY (`pk`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 `ENCRYPTED`=YES `ENCRYPTION_KEY_ID`=4 -# restart: --innodb-encrypt-tables --plugin-load-add=file_key_management.so --file-key-management --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys3.txt +# restart: --innodb-encrypt-tables --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys3.txt RENAME TABLE t1 TO t1new; ERROR HY000: Error on rename of './test/t1' to './test/t1new' (errno: 155 "The table does not exist in the storage engine") ALTER TABLE t1 RENAME TO t1new; diff --git a/mysql-test/suite/encryption/r/innodb-bad-key-change4.result b/mysql-test/suite/encryption/r/innodb-bad-key-change4.result index e37ee8eb8cd..ad218457068 100644 --- a/mysql-test/suite/encryption/r/innodb-bad-key-change4.result +++ b/mysql-test/suite/encryption/r/innodb-bad-key-change4.result @@ -4,12 +4,12 @@ call mtr.add_suppression("failed to read or decrypt \\[page id: space=[1-9][0-9] call mtr.add_suppression("Couldn't load plugins from 'file_key_management"); call mtr.add_suppression("InnoDB: Table `test`\\.`t1` is corrupted"); call mtr.add_suppression("\\[ERROR\\] InnoDB: Cannot decrypt \\[page id: space="); -# restart: --plugin-load-add=file_key_management.so --file-key-management --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys2.txt +# restart: --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys2.txt SET GLOBAL innodb_file_per_table = ON; CREATE TABLE t1 (pk INT PRIMARY KEY, f VARCHAR(8)) ENGINE=InnoDB ENCRYPTED=YES ENCRYPTION_KEY_ID=4; INSERT INTO t1 VALUES (1,'foo'),(2,'bar'); -# restart: --plugin-load-add=file_key_management.so --file-key-management --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys3.txt +# restart: --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys3.txt OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize Error Table 'test.t1' doesn't exist in engine @@ -22,5 +22,5 @@ test.t1 check Error Table 'test.t1' doesn't exist in engine test.t1 check status Operation failed SHOW WARNINGS; Level Code Message -# restart: --plugin-load-add=file_key_management.so --file-key-management --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys2.txt +# restart: --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys2.txt DROP TABLE t1; diff --git a/mysql-test/suite/encryption/r/innodb-encryption-disable.result b/mysql-test/suite/encryption/r/innodb-encryption-disable.result index e49a6b759e9..bb4f02b9c39 100644 --- a/mysql-test/suite/encryption/r/innodb-encryption-disable.result +++ b/mysql-test/suite/encryption/r/innodb-encryption-disable.result @@ -4,7 +4,7 @@ call mtr.add_suppression("failed to read or decrypt \\[page id: space=[1-9][0-9] call mtr.add_suppression("InnoDB: Encrypted page \\[page id: space=[1-9][0-9]*, page number=3\\] in file .*test.t[15].ibd looks corrupted; key_version=1"); call mtr.add_suppression("InnoDB: Table `test`\\.`t[15]` is corrupted"); call mtr.add_suppression("Couldn't load plugins from 'file_key_management"); -# restart: --innodb-encrypt-tables=ON --plugin-load-add=file_key_management.so --file-key-management --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys2.txt +# restart: --innodb-encrypt-tables=ON --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys2.txt create table t5 ( `intcol1` int(32) DEFAULT NULL, `intcol2` int(32) DEFAULT NULL, @@ -27,6 +27,6 @@ select * from t1; ERROR 42S02: Table 'test.t1' doesn't exist in engine select * from t5; ERROR 42S02: Table 'test.t5' doesn't exist in engine -# restart: --innodb-encrypt-tables=ON --plugin-load-add=file_key_management.so --file-key-management --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys2.txt +# restart: --innodb-encrypt-tables=ON --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=MYSQL_TEST_DIR/std_data/keys2.txt drop table t1; drop table t5; diff --git a/mysql-test/suite/encryption/r/innodb-remove-encryption.result b/mysql-test/suite/encryption/r/innodb-remove-encryption.result index 08b31cb568d..9bce59dbbea 100644 --- a/mysql-test/suite/encryption/r/innodb-remove-encryption.result +++ b/mysql-test/suite/encryption/r/innodb-remove-encryption.result @@ -6,7 +6,7 @@ flush tables; create table t1(a int not null primary key, b char(200)) engine=innodb; # Restart server with encryption -# restart: --plugin-load-add=file_key_management.so --loose-file-key-management --loose-file-key-management-filename=MYSQL_TEST_DIR/std_data/keys.txt --file-key-management-encryption-algorithm=aes_cbc --innodb-encrypt-tables=ON --innodb-encryption-threads=4 --innodb-tablespaces-encryption --innodb-encryption-rotate-key-age=15 +# restart: --plugin-load-add=file_key_management --loose-file-key-management --loose-file-key-management-filename=MYSQL_TEST_DIR/std_data/keys.txt --file-key-management-encryption-algorithm=aes_cbc --innodb-encrypt-tables=ON --innodb-encryption-threads=4 --innodb-tablespaces-encryption --innodb-encryption-rotate-key-age=15 # Wait until encryption threads have encrypted all tablespaces SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; NAME diff --git a/mysql-test/suite/encryption/t/innodb-bad-key-change2.test b/mysql-test/suite/encryption/t/innodb-bad-key-change2.test index bdbf2327e5d..19399b1e891 100644 --- a/mysql-test/suite/encryption/t/innodb-bad-key-change2.test +++ b/mysql-test/suite/encryption/t/innodb-bad-key-change2.test @@ -20,7 +20,7 @@ call mtr.add_suppression("InnoDB: ALTER TABLE `test`\\.`t1` DISCARD TABLESPACE f # for innodb_checksum_algorithm=full_crc32 only call mtr.add_suppression("\\[ERROR\\] InnoDB: Cannot decrypt \\[page id: space="); ---let $restart_parameters=--plugin-load-add=file_key_management.so --file-key-management --file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys2.txt +--let $restart_parameters=--plugin-load-add=file_key_management --file-key-management --file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys2.txt --source include/restart_mysqld.inc SET GLOBAL innodb_file_per_table = ON; @@ -29,7 +29,7 @@ CREATE TABLE t1 (pk INT PRIMARY KEY, f VARCHAR(8)) ENGINE=InnoDB ENCRYPTED=YES ENCRYPTION_KEY_ID=4; INSERT INTO t1 VALUES (1,'foo'),(2,'bar'); ---let $restart_parameters=--plugin-load-add=file_key_management.so --file-key-management --file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys3.txt +--let $restart_parameters=--plugin-load-add=file_key_management --file-key-management --file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys3.txt --source include/restart_mysqld.inc --error ER_NO_SUCH_TABLE_IN_ENGINE @@ -48,7 +48,7 @@ CHECK TABLE t1; --replace_regex /key_id [1-9][0-9]*/\1 / SHOW WARNINGS; ---let $restart_parameters=--plugin-load-add=file_key_management.so --file-key-management --file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys2.txt +--let $restart_parameters=--plugin-load-add=file_key_management --file-key-management --file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys2.txt --source include/restart_mysqld.inc let MYSQLD_DATADIR =`SELECT @@datadir`; @@ -60,7 +60,7 @@ ib_backup_tablespaces("test", "t1"); EOF UNLOCK TABLES; ---let $restart_parameters=--plugin-load-add=file_key_management.so --file-key-management --file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys3.txt +--let $restart_parameters=--plugin-load-add=file_key_management --file-key-management --file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys3.txt --source include/restart_mysqld.inc --error ER_NO_SUCH_TABLE_IN_ENGINE @@ -78,7 +78,7 @@ ib_discard_tablespaces("test", "t1"); ib_restore_tablespaces("test", "t1"); EOF ---let $restart_parameters=--plugin-load-add=file_key_management.so --file-key-management --file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys2.txt +--let $restart_parameters=--plugin-load-add=file_key_management --file-key-management --file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys2.txt --source include/restart_mysqld.inc ALTER TABLE t1 DISCARD TABLESPACE; @@ -92,7 +92,7 @@ EOF ALTER TABLE t1 IMPORT TABLESPACE; SHOW CREATE TABLE t1; ---let $restart_parameters= --innodb-encrypt-tables --plugin-load-add=file_key_management.so --file-key-management --file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys3.txt +--let $restart_parameters= --innodb-encrypt-tables --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys3.txt --source include/restart_mysqld.inc --error ER_ERROR_ON_RENAME diff --git a/mysql-test/suite/encryption/t/innodb-bad-key-change3.test b/mysql-test/suite/encryption/t/innodb-bad-key-change3.test index dbd04748143..9c2918f3118 100644 --- a/mysql-test/suite/encryption/t/innodb-bad-key-change3.test +++ b/mysql-test/suite/encryption/t/innodb-bad-key-change3.test @@ -25,7 +25,7 @@ call mtr.add_suppression("InnoDB: Cannot calculate statistics for table .* becau 4;770A8A65DA156D24EE2A093277530143 EOF ---exec echo "restart:--innodb-encrypt-tables --innodb-stats-persistent --plugin-load-add=file_key_management.so --file-key-management --file-key-management-filename=$MYSQLTEST_VARDIR/keys1.txt" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--exec echo "restart:--innodb-encrypt-tables --innodb-stats-persistent --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=$MYSQLTEST_VARDIR/keys1.txt" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --enable_reconnect --source include/wait_until_connected_again.inc @@ -62,7 +62,7 @@ ib_discard_tablespaces("test", "t1"); ib_restore_tablespaces("test", "t1"); EOF ---exec echo "restart:--innodb-encrypt-tables --innodb-stats-persistent --plugin-load-add=file_key_management.so --file-key-management --file-key-management-filename=$MYSQLTEST_VARDIR/keys2.txt" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--exec echo "restart:--innodb-encrypt-tables --innodb-stats-persistent --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=$MYSQLTEST_VARDIR/keys2.txt" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --enable_reconnect --source include/wait_until_connected_again.inc --source include/restart_mysqld.inc @@ -89,7 +89,7 @@ SELECT * FROM t1; 4;770A8A65DA156D24EE2A093277530143 EOF ---exec echo "restart:--innodb-encrypt-tables --innodb-stats-persistent --plugin-load-add=file_key_management.so --file-key-management --file-key-management-filename=$MYSQLTEST_VARDIR/keys1.txt" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--exec echo "restart:--innodb-encrypt-tables --innodb-stats-persistent --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=$MYSQLTEST_VARDIR/keys1.txt" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --enable_reconnect --source include/wait_until_connected_again.inc DROP TABLE t1; diff --git a/mysql-test/suite/encryption/t/innodb-bad-key-change4.test b/mysql-test/suite/encryption/t/innodb-bad-key-change4.test index b341fc81d39..58517f14978 100644 --- a/mysql-test/suite/encryption/t/innodb-bad-key-change4.test +++ b/mysql-test/suite/encryption/t/innodb-bad-key-change4.test @@ -16,7 +16,7 @@ call mtr.add_suppression("InnoDB: Table `test`\\.`t1` is corrupted"); # for innodb_checksum_algorithm=full_crc32 only call mtr.add_suppression("\\[ERROR\\] InnoDB: Cannot decrypt \\[page id: space="); ---let $restart_parameters=--plugin-load-add=file_key_management.so --file-key-management --file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys2.txt +--let $restart_parameters=--plugin-load-add=file_key_management --file-key-management --file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys2.txt --source include/restart_mysqld.inc SET GLOBAL innodb_file_per_table = ON; @@ -25,7 +25,7 @@ CREATE TABLE t1 (pk INT PRIMARY KEY, f VARCHAR(8)) ENGINE=InnoDB ENCRYPTED=YES ENCRYPTION_KEY_ID=4; INSERT INTO t1 VALUES (1,'foo'),(2,'bar'); ---let $restart_parameters=--plugin-load-add=file_key_management.so --file-key-management --file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys3.txt +--let $restart_parameters=--plugin-load-add=file_key_management --file-key-management --file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys3.txt --source include/restart_mysqld.inc --replace_regex /key_id [1-9][0-9]*/\1 / @@ -38,7 +38,7 @@ CHECK TABLE t1; --replace_regex /key_id [1-9][0-9]*/\1 / SHOW WARNINGS; ---let $restart_parameters=--plugin-load-add=file_key_management.so --file-key-management --file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys2.txt +--let $restart_parameters=--plugin-load-add=file_key_management --file-key-management --file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys2.txt --source include/restart_mysqld.inc DROP TABLE t1; diff --git a/mysql-test/suite/encryption/t/innodb-encryption-disable.test b/mysql-test/suite/encryption/t/innodb-encryption-disable.test index 4d0aa04bc56..2097a4ad184 100644 --- a/mysql-test/suite/encryption/t/innodb-encryption-disable.test +++ b/mysql-test/suite/encryption/t/innodb-encryption-disable.test @@ -16,7 +16,7 @@ call mtr.add_suppression("InnoDB: Table `test`\\.`t[15]` is corrupted"); # Suppression for builds where file_key_management plugin is linked statically call mtr.add_suppression("Couldn't load plugins from 'file_key_management"); ---let $restart_parameters=--innodb-encrypt-tables=ON --plugin-load-add=file_key_management.so --file-key-management --file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys2.txt +--let $restart_parameters=--innodb-encrypt-tables=ON --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys2.txt --source include/restart_mysqld.inc create table t5 ( @@ -48,7 +48,7 @@ select * from t1; --error ER_NO_SUCH_TABLE_IN_ENGINE select * from t5; ---let $restart_parameters=--innodb-encrypt-tables=ON --plugin-load-add=file_key_management.so --file-key-management --file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys2.txt +--let $restart_parameters=--innodb-encrypt-tables=ON --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys2.txt --source include/restart_mysqld.inc drop table t1; diff --git a/mysql-test/suite/encryption/t/innodb-remove-encryption.test b/mysql-test/suite/encryption/t/innodb-remove-encryption.test index 24e00a00a02..3d719dbef74 100644 --- a/mysql-test/suite/encryption/t/innodb-remove-encryption.test +++ b/mysql-test/suite/encryption/t/innodb-remove-encryption.test @@ -18,7 +18,7 @@ create table t1(a int not null primary key, b char(200)) engine=innodb; --echo --echo # Restart server with encryption --- let $restart_parameters=--plugin-load-add=$FILE_KEY_MANAGEMENT_SO --loose-file-key-management --loose-file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys.txt --file-key-management-encryption-algorithm=aes_cbc --innodb-encrypt-tables=ON --innodb-encryption-threads=4 --innodb-tablespaces-encryption --innodb-encryption-rotate-key-age=15 +-- let $restart_parameters=--plugin-load-add=file_key_management --loose-file-key-management --loose-file-key-management-filename=$MYSQL_TEST_DIR/std_data/keys.txt --file-key-management-encryption-algorithm=aes_cbc --innodb-encrypt-tables=ON --innodb-encryption-threads=4 --innodb-tablespaces-encryption --innodb-encryption-rotate-key-age=15 -- source include/restart_mysqld.inc --echo # Wait until encryption threads have encrypted all tablespaces diff --git a/mysql-test/suite/maria/encrypt-wrong-key.test b/mysql-test/suite/maria/encrypt-wrong-key.test index 2afa785dd0f..ca65e1018d0 100644 --- a/mysql-test/suite/maria/encrypt-wrong-key.test +++ b/mysql-test/suite/maria/encrypt-wrong-key.test @@ -17,7 +17,7 @@ call mtr.add_suppression("Failed to decrypt"); 1;770A8A65DA156D24EE2A093277530142 EOF ---exec echo "restart:--aria-encrypt-tables=1 --plugin-load-add=file_key_management.so --file-key-management --file-key-management-filename=$MYSQLTEST_VARDIR/keys1.txt" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--exec echo "restart:--aria-encrypt-tables=1 --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=$MYSQLTEST_VARDIR/keys1.txt" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --enable_reconnect --source include/wait_until_connected_again.inc @@ -32,7 +32,7 @@ INSERT INTO t1 VALUES (1); 2;770A8A65DA156D24EE2A093277530143 EOF ---exec echo "restart:--aria-encrypt-tables=1 --plugin-load-add=file_key_management.so --file-key-management --file-key-management-filename=$MYSQLTEST_VARDIR/keys2.txt" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--exec echo "restart:--aria-encrypt-tables=1 --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=$MYSQLTEST_VARDIR/keys2.txt" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --enable_reconnect --source include/wait_until_connected_again.inc @@ -44,7 +44,7 @@ INSERT INTO t1 VALUES (2); --shutdown_server --source include/wait_until_disconnected.inc ---exec echo "restart:--aria-encrypt-tables=1 --plugin-load-add=file_key_management.so --file-key-management --file-key-management-filename=$MYSQLTEST_VARDIR/keys1.txt" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +--exec echo "restart:--aria-encrypt-tables=1 --plugin-load-add=file_key_management --file-key-management --file-key-management-filename=$MYSQLTEST_VARDIR/keys1.txt" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --enable_reconnect --source include/wait_until_connected_again.inc From b1b4d67bcda32472f5b9c46465bff9db86904a00 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Fri, 4 Jun 2021 15:00:34 +0200 Subject: [PATCH 010/251] MDEV-21373 DBUG compilation - bad synchronization in ha_heap::external_lock() ha_heap::external_lock contains some consistency checks for the table,# in a debug compilation. This code suffers from lack of synchronization, in a rare case where mysql_lock_tables() fail, and unlock is forced, even if lock was not previously taken. To workaround, require EXTRA_DEBUG compile definition in order to activate the consistency checks.The code still might be useful in some cases - but the audience are developers looking for errors in single-threaded scenarios, rather than multiuser stress-tests. --- storage/heap/ha_heap.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/heap/ha_heap.cc b/storage/heap/ha_heap.cc index 5af68f098a4..8a8e1f74e47 100644 --- a/storage/heap/ha_heap.cc +++ b/storage/heap/ha_heap.cc @@ -423,7 +423,7 @@ int ha_heap::reset_auto_increment(ulonglong value) int ha_heap::external_lock(THD *thd, int lock_type) { -#ifndef DBUG_OFF +#if !defined(DBUG_OFF) && defined(EXTRA_DEBUG) if (lock_type == F_UNLCK && file->s->changed && heap_check_heap(file, 0)) return HA_ERR_CRASHED; #endif From cebc435592043a83d5f430aec8bdaa79cd7c1d44 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Sat, 5 Jun 2021 16:57:10 +0200 Subject: [PATCH 011/251] MDEV-25859 - HeidiSQL 11.3 --- win/packaging/heidisql.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/win/packaging/heidisql.cmake b/win/packaging/heidisql.cmake index 6de033eacb2..c57282ce90a 100644 --- a/win/packaging/heidisql.cmake +++ b/win/packaging/heidisql.cmake @@ -1,4 +1,4 @@ -SET(HEIDISQL_BASE_NAME "HeidiSQL_11.2_32_Portable") +SET(HEIDISQL_BASE_NAME "HeidiSQL_11.3_32_Portable") SET(HEIDISQL_ZIP "${HEIDISQL_BASE_NAME}.zip") SET(HEIDISQL_URL "http://www.heidisql.com/downloads/releases/${HEIDISQL_ZIP}") SET(HEIDISQL_DOWNLOAD_DIR ${THIRD_PARTY_DOWNLOAD_LOCATION}/${HEIDISQL_BASE_NAME}) From d4a6e3a6988e47e826e4c7cf770c38a94cb58d43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Otto=20Kek=C3=A4l=C3=A4inen?= Date: Thu, 6 May 2021 12:08:38 -0700 Subject: [PATCH 012/251] Deb: Misc cleanup and autobake-deb.sh and Salsa-CI fixes * Clean up autobake-deb.sh - No need to define any TokuDB rules, there is no such package - No need to define RocksDB arch, it already has "Architecture:" line - No need to dh-systemd backwards compat stanza, neither Debian Jessie nor Ubuntu Xenial has any new MariaDB 10.5 releases anymore - Minor spelling fixes * Ensure dch runs non-interactively so builds pass with new dch version A recent version of dch (available in Ubuntu Hirsute and Debian Bullseye) had a change in behaviour that it started prompting if the DEBEMAIL or EMAIL variable as unset, asking for confirmation. We can't have anything interactive in our build scripts, so prevent this prompt by giving --controlmaint to the command, so it always uses the name and email from the debian/control file and does not prompt anything. The command-line argument has been around for a long time, so it is safe to use on all Debian/Ubuntu builds we have. See https://manpages.debian.org/jessie/devscripts/dch.1.en.html Since MariaDB 10.5 is the oldest release we still release for Ubuntu Hisute and Debian Bullseye, merge this on 10.5 and from there merge up to latest. No need to consider 10.2, 10.3 and 10.4 as those will not be released for Ubuntu Bullseye or Ubuntu Hirsute. * Minor Salsa-CI cleanup - Fix spelling (synced from downstream Debian) * Many minor spelling fixes (synced from downstream Debian) --- debian/autobake-deb.sh | 34 +++++------------------- debian/mariadb-server-10.5.README.Debian | 16 +++++------ debian/mariadb-server-10.5.mysql.default | 4 +-- debian/mariadb-server-10.5.postinst | 2 +- debian/rules | 2 +- debian/salsa-ci.yml | 9 ++----- debian/tests/control | 2 +- debian/tests/smoke | 2 +- 8 files changed, 23 insertions(+), 48 deletions(-) diff --git a/debian/autobake-deb.sh b/debian/autobake-deb.sh index f7be508c1bd..516b842ba57 100755 --- a/debian/autobake-deb.sh +++ b/debian/autobake-deb.sh @@ -6,12 +6,12 @@ # Always keep the actual packaging as up-to-date as possible following the latest # Debian policy and targeting Debian Sid. Then case-by-case run in autobake-deb.sh # tests for backwards compatibility and strip away parts on older builders or -# specfic build environments. +# specific build environments. # Exit immediately on any error set -e -# This file is invocated from Buildbot and Travis-CI to build deb packages. +# This file is invoked from Buildbot and Travis-CI to build deb packages. # As both of those CI systems have many parallel jobs that include different # parts of the test suite, we don't need to run the mysql-test-run at all when # building the deb packages here. @@ -24,7 +24,7 @@ then echo >> debian/control cat storage/columnstore/columnstore/debian/control >> debian/control - # ColumnStore is explcitly disabled in the native build, so allow it now + # ColumnStore is explicitly disabled in the native build, so allow it now # when build it when triggered by autobake-deb.sh sed '/-DPLUGIN_COLUMNSTORE=NO/d' -i debian/rules fi @@ -42,7 +42,7 @@ then sed "/Package: mariadb-plugin-columnstore/,/^$/d" -i debian/control fi -# Don't build or try to put files in a package for selected plugins and compontents on Travis-CI +# Don't build or try to put files in a package for selected plugins and components on Travis-CI # in order to keep build small (in both duration and disk space) if [[ $TRAVIS ]] then @@ -62,27 +62,6 @@ then sed "/Package: libmariadbd-dev/,/^$/d" -i debian/control fi -## Skip TokuDB if arch is not amd64 -if [[ ! $(dpkg-architecture -q DEB_BUILD_ARCH) =~ amd64 ]] -then - sed '/Package: mariadb-plugin-tokudb/,/^$/d' -i debian/control -fi - - -if [[ $(arch) =~ i[346]86 ]] -then - sed "/Package: mariadb-plugin-rocksdb/,/^$/d" -i debian/control -fi - -# From Debian Stretch/Ubuntu Bionic onwards dh-systemd is just an empty -# transitional metapackage and the functionality was merged into debhelper. -# In Ubuntu Hirsute is was completely removed, so it can't be referenced anymore. -# Keep using it only on Debian Jessie and Ubuntu Xenial. -if apt-cache madison dh-systemd | grep 'dh-systemd' >/dev/null 2>&1 -then - sed 's/debhelper (>= 9.20160709~),/debhelper (>= 9), dh-systemd,/' -i debian/control -fi - # If rocksdb-tools is not available (before Debian Buster and Ubuntu Disco) # remove the dependency from the RocksDB plugin so it can install properly # and instead ship the one built from MariaDB sources @@ -93,7 +72,8 @@ then echo "usr/bin/sst_dump" >> debian/mariadb-plugin-rocksdb.install fi -# From Debian Buster/Ubuntu Bionic, libcurl4 replaces libcurl3 +# If libcurl4 is not available (before Debian Buster and Ubuntu Bionic) +# use older libcurl3 instead if ! apt-cache madison libcurl4 | grep 'libcurl4' >/dev/null 2>&1 then sed 's/libcurl4/libcurl3/g' -i debian/control @@ -111,7 +91,7 @@ CODENAME="$(lsb_release -sc)" EPOCH="1:" VERSION="${EPOCH}${UPSTREAM}${PATCHLEVEL}~${CODENAME}" -dch -b -D "${CODENAME}" -v "${VERSION}" "Automatic build with ${LOGSTRING}." +dch -b -D "${CODENAME}" -v "${VERSION}" "Automatic build with ${LOGSTRING}." --controlmaint echo "Creating package version ${VERSION} ... " diff --git a/debian/mariadb-server-10.5.README.Debian b/debian/mariadb-server-10.5.README.Debian index f93484271fb..6042249a706 100644 --- a/debian/mariadb-server-10.5.README.Debian +++ b/debian/mariadb-server-10.5.README.Debian @@ -31,13 +31,13 @@ name has been kept as a symbolic link to the new name for backwards compatibilit * NATIVE SYSTEMD SERVICE INTRODUCED IN MARIADB 10.1 =================================================== -From MariaDB 10.1 onwards the upstream mariadb.service and mariadb@.service are +From MariaDB 10.1 onward the upstream mariadb.service and mariadb@.service are used to provide the full systemd experience. Some features available in traditional /etc/init.d/mysql have been changed. For details see https://mariadb.com/kb/en/mariadb/systemd/ -* MIXING PACKAGES FROM MARIAD.ORG AND OFFICIAL DEBIAN REPOSITORIES +* MIXING PACKAGES FROM MARIADB.ORG AND OFFICIAL DEBIAN REPOSITORIES ================================================================== Please note that the MariaDB packaging in official Debian repositories are of @@ -57,7 +57,7 @@ revision string. On new installs no root password is set and no debian-sys-maint user is created anymore. Instead the MariaDB root account is set to be authenticated -using the unix socket, e.g. any mysqld invocation by root or via sudo will +using the Unix socket, e.g. any mysqld invocation by root or via sudo will let the user see the mysqld prompt. You may never ever delete the mysql user "root". Although it has no password @@ -65,7 +65,7 @@ is set, the unix_auth plugin ensure that it can only be run locally as the root user. The credentials in /etc/mysql/debian.cnf specify the user which is used by the -init scripts to stop the server and perform logrotation. This used to be the +init scripts to stop the server and perform log rotation. This used to be the debian-sys-maint user which is no longer used as root can run directly. If you have start/stop problems make sure that the /etc/mysql/debian.cnf file @@ -79,7 +79,7 @@ file as is has been obsoleted. MariaDB in Debian is secure by default, because: - It only listens to the localhost socket and cannot be accessed remotely unless - the sysadmin changes the configurationin /etc/mysql to allow so. + the sysadmin changes the configuration in /etc/mysql to allow so. - There is no debian-sys-maint with password in /etc/mysql/debian.cnf anymore. - There is no root account with password anymore. The system admin needs to create one themselves if they need it. With no password, all issues related @@ -141,9 +141,9 @@ https://mariadb.com/kb It is recommended you create additional admin users for your database administration needs in addition to the default root user. -If your local unix account is the one you want to have local super user +If your local Unix account is the one you want to have local super user access on your database with you can create the following account that will -only work for the local unix user connecting to the database locally. +only work for the local Unix user connecting to the database locally. sudo /usr/bin/mysql -e "GRANT ALL ON *.* TO '$USER'@'localhost' IDENTIFIED VIA unix_socket WITH GRANT OPTION" @@ -176,7 +176,7 @@ https://mariadb.com/kb/en/configuring-mariadb-with-mycnf/. ============================== If the MySQL server is acting as a replication slave, you should not -set --tmpdir to point to a directory on a memory-based filesystem or to +set --tmpdir to point to a directory on a memory-based file system or to a directory that is cleared when the server host restarts. A replication slave needs some of its temporary files to survive a machine restart so that it can replicate temporary tables or LOAD DATA INFILE operations. If diff --git a/debian/mariadb-server-10.5.mysql.default b/debian/mariadb-server-10.5.mysql.default index 3810c73bf52..36079edecb2 100644 --- a/debian/mariadb-server-10.5.mysql.default +++ b/debian/mariadb-server-10.5.mysql.default @@ -1,9 +1,9 @@ # # NOTE: This file is read only by the traditional SysV init script. -# Debian 9 and Ubuntu 17.04 onwards do not normally read this file as they use +# Debian 9 and Ubuntu 17.04 onward do not normally read this file as they use # systemd by default. # -# For similar behaviour, systemd users should override ExecStart by dropping +# For similar behavior, systemd users should override ExecStart by dropping # files into /etc/systemd/system/mariadb.service.d/ # # See also: diff --git a/debian/mariadb-server-10.5.postinst b/debian/mariadb-server-10.5.postinst index 9b0120cb58f..97828ed15e8 100644 --- a/debian/mariadb-server-10.5.postinst +++ b/debian/mariadb-server-10.5.postinst @@ -36,7 +36,7 @@ case "$1" in # latest 'mariadb' file. This has also the added benefit that anything that # invokes traditional sysv init with either 'mysql' or 'mariadb' will end up # controlling this newly installed MariaDB, and thus we maintain better - # backwards compatiblity. + # backwards compatibility. # # Note that the 'Provides' line is also updated to avoid 'insserv' exiting # on failure (when it is run by update-rc.d) because of duplicate service diff --git a/debian/rules b/debian/rules index d029eead974..5e7da691b00 100755 --- a/debian/rules +++ b/debian/rules @@ -143,7 +143,7 @@ endif # If mariadb-test package is removed, also remove most of it's files grep --quiet "Package: mariadb-test" debian/control || rm -rf $(TMP)/usr/share/mysql/mysql-test - # Delete private files from libraries so they don't get shipped in the -dev pacakges + # Delete private files from libraries so they don't get shipped in the -dev packages rm -r $(TMP)/usr/include/mariadb/server/private # Don't ship sql-bench at all, just delete it completely even though it builds diff --git a/debian/salsa-ci.yml b/debian/salsa-ci.yml index af9e95b2bfa..29ea9afd9d0 100644 --- a/debian/salsa-ci.yml +++ b/debian/salsa-ci.yml @@ -69,9 +69,6 @@ build i386: image: $SALSA_CI_IMAGES_BASE_I386 variables: ARCH: 'i386' - except: - variables: - - $SALSA_CI_DISABLE_BUILD_PACKAGE_I386 =~ /^(1|yes|true)$/ build native deb: extends: .build-package @@ -545,8 +542,6 @@ mysql-8.0 Sid to mariadb-10.5 upgrade: except: variables: - $CI_COMMIT_TAG != null && $SALSA_CI_ENABLE_PIPELINE_ON_TAGS !~ /^(1|yes|true)$/ - # Installation often fails (not a MariaDB reason), so do not require this test to pass - allow_failure: true # Upgrading from MySQL 8.0 with datadir in place is not possible. Users need to do a data dump. # The Debian maintainer scripts detect this situation and simply moves old datadir aside and start fresh. @@ -638,12 +633,12 @@ mariadb.org-10.5 to mariadb-10.5 upgrade: - echo 'deb http://mirror.one.com/mariadb/repo/10.5/debian sid main' > /etc/apt/sources.list.d/mariadb.list - apt-get update - *test-install-readline-in-sid-for-backwards-compat - # The 10.5.9 relase is missing mariadb-plugin-columnstore, define all other packages but it to avoid hitting the error: + # The 10.5.9 release is missing mariadb-plugin-columnstore, define all other packages but it to avoid hitting the error: # The following packages have unmet dependencies: # mariadb-plugin-columnstore : Depends: mariadb-server-10.5 (= 1:10.5.8+maria~sid) but 1:10.5.9+maria~sid is to be installed - apt-get install -y libmariadb3 'libmariadb-*' 'libmariadbd*' 'mariadb-c*' 'mariadb-b*' 'mariadb-s*' 'mariadb-t*' 'mariadb-plugin-con*' 'mariadb-plugin-cr*' 'mariadb-plugin-g*' 'mariadb-plugin-m*' 'mariadb-plugin-o*' 'mariadb-plugin-s*' # Once 10.5.10 is out, revert back to: - # Package libmariadbclient-dev from mariadb.org conficts with libmariadb-dev in Sid, so cannot use wildcard that would include it + # Package libmariadbclient-dev from mariadb.org conflicts with libmariadb-dev in Sid, so cannot use wildcard that would include it #- apt-get install -y 'mariadb*' libmariadb3 'libmariadb-*' 'libmariadbd*' - *test-verify-initial # Install MariaDB built in this commit diff --git a/debian/tests/control b/debian/tests/control index 45097079629..3706829904f 100644 --- a/debian/tests/control +++ b/debian/tests/control @@ -1,7 +1,7 @@ Tests: smoke # RocksDB is not built for all archs. Rather than duplicating the condition # for its existence (see the list in debian/control), install it if available -# and check in the test if it's funcational when it should be. +# and check in the test if it's functional when it should be. # The plugin package also already depends on the other one. Depends: mariadb-plugin-rocksdb | mariadb-server-10.5 Restrictions: allow-stderr needs-root isolation-container diff --git a/debian/tests/smoke b/debian/tests/smoke index 5de9d425e16..4e06feae20c 100644 --- a/debian/tests/smoke +++ b/debian/tests/smoke @@ -31,7 +31,7 @@ if ! which systemctl then if ! /etc/init.d/mariadb status then - echo "Did not find systemctl and deamon was not running, starting it.." + echo "Did not find systemctl and daemon was not running, starting it.." /etc/init.d/mariadb start fi else From 9f9a925c399b9d960f095be0886f56f51396eb04 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Sun, 6 Jun 2021 08:46:59 +0200 Subject: [PATCH 013/251] MDEV-23815 Windows : mysql_upgrade_wizard fails, if service name has spaces The fix is to quote service name parameter, when it is passed to mysql_upgrade_service subprocess. --- win/upgrade_wizard/upgradeDlg.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/win/upgrade_wizard/upgradeDlg.cpp b/win/upgrade_wizard/upgradeDlg.cpp index d996c0ebe5d..d0dd6a3fa75 100644 --- a/win/upgrade_wizard/upgradeDlg.cpp +++ b/win/upgrade_wizard/upgradeDlg.cpp @@ -367,7 +367,10 @@ void CUpgradeDlg::UpgradeOneService(const string& servicename) ErrorExit("Stdout SetHandleInformation"); string commandline("mysql_upgrade_service.exe --service="); + commandline += "\""; commandline += servicename; + commandline += "\""; + si.cb = sizeof(si); si.hStdInput= GetStdHandle(STD_INPUT_HANDLE); si.hStdOutput= hPipeWrite; @@ -397,7 +400,7 @@ void CUpgradeDlg::UpgradeOneService(const string& servicename) else { /* - Creating a process with CREATE_BREAKAWAY_FROM_JOB, reset this flag + Creating a process with CREATE_BREAKAWAY_FROM_JOB failed, reset this flag and retry. */ if (!CreateProcess(NULL, (LPSTR)commandline.c_str(), NULL, NULL, TRUE, From 3c922d6defcfa6be819fe33794abcf507bb70c25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Otto=20Kek=C3=A4l=C3=A4inen?= Date: Fri, 28 May 2021 22:04:17 -0700 Subject: [PATCH 014/251] Revert "CONNECT: move jar files to /usr/share and include them in DEBs" This partially reverts commit d7321893d8c50071632a102e17a7869da9cb03a5. The *.jar files are not being built and all Debian builds are failing as dh_install stops on missing files. To build them we would need to also add new Java build dependencies. In a stable release (10.2->10.5) we shouldn't add new files and certainly not any new build dependencies, so reverting commit. Also, the files are located in a different path, and already included in the mariadb-test-data package: /usr/share/mysql/mysql-test/plugin/connect/connect/std_data/JavaWrappers.jar /usr/share/mysql/mysql-test/plugin/connect/connect/std_data/JdbcMariaDB.jar /usr/share/mysql/mysql-test/plugin/connect/connect/std_data/Mongo2.jar /usr/share/mysql/mysql-test/plugin/connect/connect/std_data/Mongo3.jar This change needs to be redesigned and applies only on 10.6 or newer. --- debian/mariadb-plugin-connect.install | 4 ---- 1 file changed, 4 deletions(-) diff --git a/debian/mariadb-plugin-connect.install b/debian/mariadb-plugin-connect.install index 7b5a5f0633e..8a7aee412df 100644 --- a/debian/mariadb-plugin-connect.install +++ b/debian/mariadb-plugin-connect.install @@ -1,6 +1,2 @@ etc/mysql/conf.d/connect.cnf usr/lib/mysql/plugin/ha_connect.so -usr/share/mysql/Mongo2.jar -usr/share/mysql/Mongo3.jar -usr/share/mysql/JavaWrappers.jar -usr/share/mysql/JdbcInterface.jar From 3d6eb7afcfb47cb432f790d0b25c8c1f4ec5bcf3 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Sun, 6 Jun 2021 13:21:03 +0200 Subject: [PATCH 015/251] MDEV-25602 get rid of __WIN__ in favor of standard _WIN32 This fixed the MySQL bug# 20338 about misuse of double underscore prefix __WIN__, which was old MySQL's idea of identifying Windows Replace it by _WIN32 standard symbol for targeting Windows OS (both 32 and 64 bit) Not that connect storage engine is not fixed in this patch (must be fixed in "upstream" branch) --- client/async_example.c | 4 +- client/client_priv.h | 2 +- client/mysql.cc | 14 +++--- client/mysql_plugin.c | 8 ++-- client/mysql_upgrade.c | 8 ++-- client/mysqladmin.cc | 6 +-- client/mysqlbinlog.cc | 2 +- client/mysqlcheck.c | 4 +- client/mysqldump.c | 4 +- client/mysqlimport.c | 4 +- client/mysqlshow.c | 4 +- client/mysqlslap.c | 11 +++-- client/readline.cc | 2 +- cmake/os/Windows.cmake | 2 +- config.h.cmake | 2 +- dbug/dbug.c | 8 ++-- extra/innochecksum.cc | 2 +- extra/mariabackup/ds_stdout.cc | 2 +- extra/mariabackup/xbstream_read.cc | 2 +- extra/mariabackup/xbstream_write.cc | 2 +- extra/mariabackup/xtrabackup.cc | 4 +- include/my_dbug.h | 10 ++--- include/my_global.h | 32 ++++++++----- include/my_net.h | 4 +- include/my_pthread.h | 4 +- include/my_stacktrace.h | 6 +-- include/mysql.h | 14 +----- include/mysql_com.h | 4 +- include/thr_alarm.h | 4 +- include/violite.h | 4 +- libmysqld/lib_sql.cc | 2 +- libmysqld/libmysql.c | 16 +++---- libmysqld/libmysqld.c | 11 +---- mysys/get_password.c | 8 ++-- mysys/mf_keycache.c | 6 +-- mysys/mf_path.c | 4 +- mysys/mf_tempdir.c | 4 +- mysys/my_access.c | 13 +++--- mysys/my_conio.c | 4 +- mysys/my_copy.c | 2 +- mysys/my_default.c | 14 +++--- mysys/my_getncpus.c | 2 +- mysys/my_getpagesize.c | 2 +- mysys/my_getwd.c | 2 +- mysys/my_mkdir.c | 2 +- mysys/my_pthread.c | 2 +- mysys/my_redel.c | 4 +- mysys/my_rename.c | 2 +- mysys/my_sleep.c | 2 +- mysys/my_wincond.c | 2 +- mysys/stacktrace.c | 10 ++--- mysys/string.c | 4 +- mysys/thr_alarm.c | 2 +- mysys/thr_mutex.c | 8 ++-- plugin/feedback/utils.cc | 2 +- plugin/server_audit/server_audit.c | 6 +-- sql/custom_conf.h | 2 +- sql/hash_filo.cc | 4 +- sql/hostname.cc | 6 +-- sql/mf_iocache.cc | 2 +- sql/mysqld.cc | 36 +++++++-------- sql/mysqld.h | 2 +- sql/net_serv.cc | 16 +++---- sql/signal_handler.cc | 4 +- sql/sql_base.cc | 2 +- sql/sql_class.cc | 2 +- sql/sql_class.h | 2 +- sql/sql_connect.cc | 2 +- sql/sql_const.h | 13 ------ sql/sql_db.cc | 2 +- sql/sql_load.cc | 2 +- sql/sql_partition.cc | 2 +- sql/sql_plugin.cc | 2 +- sql/sql_profile.cc | 4 +- sql/sql_profile.h | 2 +- sql/sql_show.cc | 2 +- sql/sql_table.cc | 2 +- sql/sys_vars.cc | 2 +- sql/udf_example.c | 6 +-- sql/wsrep_sst.cc | 14 +++--- storage/connect/CMakeLists.txt | 1 + storage/federatedx/ha_federatedx.cc | 2 +- storage/heap/hp_write.c | 2 +- storage/innobase/buf/buf0dump.cc | 2 +- storage/innobase/handler/ha_innodb.cc | 2 +- storage/innobase/include/univ.i | 2 +- storage/innobase/row/row0mysql.cc | 6 +-- storage/maria/aria_chk.c | 2 +- storage/maria/aria_dump_log.c | 2 +- storage/maria/aria_read_log.c | 4 +- storage/maria/ma_control_file.c | 4 +- storage/maria/ma_create.c | 6 +-- storage/maria/ma_info.c | 2 +- storage/maria/ma_locking.c | 4 +- storage/maria/ma_loghandler.c | 4 +- storage/maria/ma_open.c | 6 +-- storage/maria/ma_pagecache.c | 6 +-- storage/maria/ma_sort.c | 2 +- storage/maria/unittest/ma_pagecache_consist.c | 2 +- .../maria/unittest/ma_pagecache_rwconsist.c | 2 +- .../maria/unittest/ma_pagecache_rwconsist2.c | 2 +- storage/maria/unittest/ma_pagecache_single.c | 2 +- storage/maria/unittest/ma_test_loghandler-t.c | 2 +- .../unittest/ma_test_loghandler_first_lsn-t.c | 2 +- .../unittest/ma_test_loghandler_max_lsn-t.c | 2 +- .../ma_test_loghandler_multithread-t.c | 2 +- .../unittest/ma_test_loghandler_noflush-t.c | 2 +- .../unittest/ma_test_loghandler_nologs-t.c | 2 +- .../unittest/ma_test_loghandler_pagecache-t.c | 2 +- .../unittest/ma_test_loghandler_purge-t.c | 2 +- storage/maria/unittest/test_file.c | 2 +- storage/myisam/mi_create.c | 2 +- storage/myisam/mi_extra.c | 45 ------------------- storage/myisam/mi_info.c | 2 +- storage/myisam/mi_log.c | 2 +- storage/myisam/mi_open.c | 2 +- storage/myisam/myisamchk.c | 2 +- storage/myisam/sort.c | 2 +- storage/rocksdb/ut0counter.h | 2 +- storage/sphinx/ha_sphinx.cc | 12 ++--- storage/sphinx/snippets_udf.cc | 8 ++-- storage/spider/hs_client/auto_addrinfo.hpp | 2 +- storage/spider/hs_client/auto_file.hpp | 2 +- storage/spider/hs_client/socket.cpp | 38 ++++++++-------- strings/my_vsnprintf.c | 2 +- tests/list_test.c | 2 +- tests/nonblock-wrappers.h | 4 +- tests/showdb_test.c | 2 +- tests/ssl_test.c | 2 +- tests/thread_test.c | 2 +- unittest/mytap/tap.c | 4 +- vio/viosocket.c | 10 ++--- 132 files changed, 303 insertions(+), 379 deletions(-) diff --git a/client/async_example.c b/client/async_example.c index ccb60950904..f216de22930 100644 --- a/client/async_example.c +++ b/client/async_example.c @@ -16,7 +16,7 @@ */ -#ifndef __WIN__ +#ifndef _WIN32 #include #else #include @@ -33,7 +33,7 @@ static const char *my_groups[]= { "client", NULL }; static int wait_for_mysql(MYSQL *mysql, int status) { -#ifdef __WIN__ +#ifdef _WIN32 fd_set rs, ws, es; int res; struct timeval tv, *timeout; diff --git a/client/client_priv.h b/client/client_priv.h index cd95d235763..ee33a0b0f99 100644 --- a/client/client_priv.h +++ b/client/client_priv.h @@ -27,7 +27,7 @@ #include #ifndef WEXITSTATUS -# ifdef __WIN__ +# ifdef _WIN32 # define WEXITSTATUS(stat_val) (stat_val) # else # define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8) diff --git a/client/mysql.cc b/client/mysql.cc index 2bb3f2309d6..d22a3d49b16 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -88,7 +88,7 @@ extern "C" { #endif /* defined(HAVE_CURSES_H) && defined(HAVE_TERM_H) */ #undef bcmp // Fix problem with new readline -#if defined(__WIN__) +#if defined(_WIN32) #include #else #include @@ -1587,7 +1587,7 @@ static struct my_option my_long_options[] = {"password", 'p', "Password to use when connecting to server. If password is not given it's asked from the tty.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, -#ifdef __WIN__ +#ifdef _WIN32 {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif @@ -1893,7 +1893,7 @@ get_one_option(const struct my_option *opt, const char *argument, const char *fi set_if_bigger(opt_silent,1); // more silent break; case 'W': -#ifdef __WIN__ +#ifdef _WIN32 opt_protocol = MYSQL_PROTOCOL_PIPE; opt_protocol_type= "pipe"; @@ -2026,7 +2026,7 @@ static int get_options(int argc, char **argv) static int read_and_execute(bool interactive) { -#if defined(__WIN__) +#if defined(_WIN32) String tmpbuf; String buffer; #endif @@ -2106,7 +2106,7 @@ static int read_and_execute(bool interactive) if (opt_outfile && glob_buffer.is_empty()) fflush(OUTFILE); -#if defined(__WIN__) +#if defined(_WIN32) tee_fputs(prompt, stdout); if (!tmpbuf.is_alloced()) tmpbuf.alloc(65535); @@ -2139,7 +2139,7 @@ static int read_and_execute(bool interactive) if (line) free(line); line= readline(prompt); -#endif /* defined(__WIN__) */ +#endif /* defined(_WIN32) */ /* When Ctrl+d or Ctrl+z is pressed, the line may be NULL on some OS @@ -2194,7 +2194,7 @@ static int read_and_execute(bool interactive) } } -#if defined(__WIN__) +#if defined(_WIN32) buffer.free(); tmpbuf.free(); #else diff --git a/client/mysql_plugin.c b/client/mysql_plugin.c index 32030ce1dee..abb42dd01ef 100644 --- a/client/mysql_plugin.c +++ b/client/mysql_plugin.c @@ -233,7 +233,7 @@ static int run_command(char* cmd, const char *mode) } -#ifdef __WIN__ +#ifdef _WIN32 /** Check to see if there are spaces in a path. @@ -329,7 +329,7 @@ static int get_default_values() if ((error= make_tempfile(defaults_file, "txt"))) goto exit; -#ifdef __WIN__ +#ifdef _WIN32 { char *format_str= 0; @@ -860,7 +860,7 @@ static int process_options(int argc, char *argv[], char *operation) memset(buff, 0, sizeof(buff)); strncpy(buff, opt_basedir, sizeof(buff) - 1); -#ifdef __WIN__ +#ifdef _WIN32 strncat(buff, "/", sizeof(buff) - strlen(buff) - 1); #else strncat(buff, FN_DIRSEP, sizeof(buff) - strlen(buff) - 1); @@ -1175,7 +1175,7 @@ static int bootstrap_server(char *server_path, char *bootstrap_file) char bootstrap_cmd[FN_REFLEN]; int error= 0; -#ifdef __WIN__ +#ifdef _WIN32 char *format_str= 0; const char *verbose_str= NULL; diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index e49b0fd0dc0..0ac2c8b5853 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -29,7 +29,7 @@ #endif #ifndef WEXITSTATUS -# ifdef __WIN__ +# ifdef _WIN32 # define WEXITSTATUS(stat_val) (stat_val) # else # define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8) @@ -121,7 +121,7 @@ static struct my_option my_long_options[]= "Password to use when connecting to server. If password is not given," " it's solicited on the tty.", &opt_password,&opt_password, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, -#ifdef __WIN__ +#ifdef _WIN32 {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif @@ -451,7 +451,7 @@ static int run_tool(char *tool_path, DYNAMIC_STRING *ds_res, ...) va_end(args); -#ifdef __WIN__ +#ifdef _WIN32 dynstr_append(&ds_cmdline, "\""); #endif @@ -1286,7 +1286,7 @@ int main(int argc, char **argv) load_defaults_or_exit("my", load_default_groups, &argc, &argv); defaults_argv= argv; /* Must be freed by 'free_defaults' */ -#if defined(__WIN__) +#if defined(_WIN32) if (GetModuleFileName(NULL, self_name, FN_REFLEN) == 0) #endif { diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc index de9fe1f7a70..6fa5d6c73d0 100644 --- a/client/mysqladmin.cc +++ b/client/mysqladmin.cc @@ -175,7 +175,7 @@ static struct my_option my_long_options[] = {"password", 'p', "Password to use when connecting to server. If password is not given it's asked from the tty.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, -#ifdef __WIN__ +#ifdef _WIN32 {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif @@ -278,7 +278,7 @@ get_one_option(const struct my_option *opt, const char *argument, const char *fi option_silent++; break; case 'W': -#ifdef __WIN__ +#ifdef _WIN32 opt_protocol = MYSQL_PROTOCOL_PIPE; /* Prioritize pipe if explicit via command line */ @@ -1153,7 +1153,7 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv) { bool old= (find_type(argv[0], &command_typelib, FIND_TYPE_BASIC) == ADMIN_OLD_PASSWORD); -#ifdef __WIN__ +#ifdef _WIN32 size_t pw_len= strlen(typed_password); if (pw_len > 1 && typed_password[0] == '\'' && typed_password[pw_len-1] == '\'') diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index d3fc58351ee..d65828ea71c 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -2918,7 +2918,7 @@ static Exit_status dump_local_log_entries(PRINT_EVENT_INFO *print_event_info, stdin in binary mode. Errors on setting this mode result in halting the function and printing an error message to stderr. */ -#if defined (__WIN__) || defined(_WIN64) +#if defined (_WIN32) if (_setmode(fileno(stdin), O_BINARY) == -1) { error("Could not set binary mode on stdin."); diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index 5d96dd29be2..480308aa015 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -165,7 +165,7 @@ static struct my_option my_long_options[] = "When using ANALYZE TABLE use the PERSISTENT FOR ALL option.", &opt_persistent_all, &opt_persistent_all, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, -#ifdef __WIN__ +#ifdef _WIN32 {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif @@ -355,7 +355,7 @@ get_one_option(const struct my_option *opt, opt_upgrade= 1; break; case 'W': -#ifdef __WIN__ +#ifdef _WIN32 opt_protocol = MYSQL_PROTOCOL_PIPE; /* Prioritize pipe if explicit via command line */ diff --git a/client/mysqldump.c b/client/mysqldump.c index 7fda95239e6..b6419e11a0e 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -504,7 +504,7 @@ static struct my_option my_long_options[] = {"password", 'p', "Password to use when connecting to server. If password is not given it's solicited on the tty.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, -#ifdef __WIN__ +#ifdef _WIN32 {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif @@ -896,7 +896,7 @@ get_one_option(const struct my_option *opt, exit(1); break; case 'W': -#ifdef __WIN__ +#ifdef _WIN32 opt_protocol= MYSQL_PROTOCOL_PIPE; /* Prioritize pipe if explicit via command line */ diff --git a/client/mysqlimport.c b/client/mysqlimport.c index 32022146230..8723641c74b 100644 --- a/client/mysqlimport.c +++ b/client/mysqlimport.c @@ -146,7 +146,7 @@ static struct my_option my_long_options[] = {"password", 'p', "Password to use when connecting to server. If password is not given it's asked from the tty.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, -#ifdef __WIN__ +#ifdef _WIN32 {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif @@ -252,7 +252,7 @@ get_one_option(const struct my_option *opt, const char *argument, else tty_password= 1; break; -#ifdef __WIN__ +#ifdef _WIN32 case 'W': opt_protocol = MYSQL_PROTOCOL_PIPE; opt_local_file=1; diff --git a/client/mysqlshow.c b/client/mysqlshow.c index d09839d04a8..9b31d87225c 100644 --- a/client/mysqlshow.c +++ b/client/mysqlshow.c @@ -247,7 +247,7 @@ static struct my_option my_long_options[] = &opt_mysql_port, &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, -#ifdef __WIN__ +#ifdef _WIN32 {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif @@ -336,7 +336,7 @@ get_one_option(const struct my_option *opt, const char *argument, tty_password=1; break; case 'W': -#ifdef __WIN__ +#ifdef _WIN32 opt_protocol = MYSQL_PROTOCOL_PIPE; /* Prioritize pipe if explicit via command line */ diff --git a/client/mysqlslap.c b/client/mysqlslap.c index f456d9b1841..555f0624c7e 100644 --- a/client/mysqlslap.c +++ b/client/mysqlslap.c @@ -86,16 +86,15 @@ TODO: #include #include #include -#ifndef __WIN__ +#ifndef _WIN32 #include #endif #include #include /* ORACLE_WELCOME_COPYRIGHT_NOTICE */ -#ifdef __WIN__ +#ifdef _WIN32 #define srandom srand #define random rand -#define snprintf _snprintf #endif @@ -282,7 +281,7 @@ static long int timedif(struct timeval a, struct timeval b) return s + us; } -#ifdef __WIN__ +#ifdef _WIN32 static int gettimeofday(struct timeval *tp, void *tzp) { unsigned int ticks; @@ -665,7 +664,7 @@ static struct my_option my_long_options[] = {"password", 'p', "Password to use when connecting to server. If password is not given it's " "asked from the tty.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, -#ifdef __WIN__ +#ifdef _WIN32 {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif @@ -772,7 +771,7 @@ get_one_option(const struct my_option *opt, const char *argument, tty_password= 1; break; case 'W': -#ifdef __WIN__ +#ifdef _WIN32 opt_protocol= MYSQL_PROTOCOL_PIPE; /* Prioritize pipe if explicit via command line */ diff --git a/client/readline.cc b/client/readline.cc index 8d3d97b8585..6b9e8239984 100644 --- a/client/readline.cc +++ b/client/readline.cc @@ -34,7 +34,7 @@ LINE_BUFFER *batch_readline_init(ulong max_size,FILE *file) { LINE_BUFFER *line_buff; -#ifndef __WIN__ +#ifndef _WIN32 MY_STAT input_file_stat; if (my_fstat(fileno(file), &input_file_stat, MYF(MY_WME)) || MY_S_ISDIR(input_file_stat.st_mode) || diff --git a/cmake/os/Windows.cmake b/cmake/os/Windows.cmake index 71ad4ab0912..73463ef2833 100644 --- a/cmake/os/Windows.cmake +++ b/cmake/os/Windows.cmake @@ -50,7 +50,7 @@ IF(MSVC AND CMAKE_CXX_COMPILER_ID MATCHES Clang) SET(CLANG_CL TRUE) ENDIF() -ADD_DEFINITIONS(-D_WINDOWS -D__WIN__ -D_CRT_SECURE_NO_DEPRECATE) +ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE) ADD_DEFINITIONS(-D_WIN32_WINNT=0x0A00) # We do not want the windows.h macros min/max ADD_DEFINITIONS(-DNOMINMAX) diff --git a/config.h.cmake b/config.h.cmake index ae77d676502..80721592ab0 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -429,7 +429,7 @@ #define PSAPI_VERSION 1 /* for GetProcessMemoryInfo() */ /* We don't want the min/max macros */ -#ifdef __WIN__ +#ifdef _WIN32 #define NOMINMAX 1 #endif diff --git a/dbug/dbug.c b/dbug/dbug.c index 5c05994fb4e..548d82d03e6 100644 --- a/dbug/dbug.c +++ b/dbug/dbug.c @@ -97,7 +97,7 @@ extern void __gcov_flush(); #define fnmatch(A,B,C) strcmp(A,B) #endif -#if defined(__WIN__) +#if defined(_WIN32) #include #endif @@ -1872,7 +1872,7 @@ static void DoPrefix(CODE_STATE *cs, uint _line_) (void) fprintf(cs->stack->out_file->file, "%5d: ", cs->lineno); if (cs->stack->flags & TIMESTAMP_ON) { -#ifdef __WIN__ +#ifdef _WIN32 /* FIXME This doesn't give microseconds as in Unix case, and the resolution is in system ticks, 10 ms intervals. See my_getsystime.c for high res */ SYSTEMTIME loc_t; @@ -2203,7 +2203,7 @@ void _db_flush_() } -#ifndef __WIN__ +#ifndef _WIN32 void _db_suicide_() { int retval; @@ -2222,7 +2222,7 @@ void _db_suicide_() fprintf(stderr, "sigsuspend returned %d errno %d \n", retval, errno); assert(FALSE); /* With full signal mask, we should never return here. */ } -#endif /* ! __WIN__ */ +#endif /* ! _WIN32 */ void _db_lock_file_() diff --git a/extra/innochecksum.cc b/extra/innochecksum.cc index 02aec1bd919..5d705e64423 100644 --- a/extra/innochecksum.cc +++ b/extra/innochecksum.cc @@ -32,7 +32,7 @@ #include #include #include -#ifndef __WIN__ +#ifndef _WIN32 # include #endif #include diff --git a/extra/mariabackup/ds_stdout.cc b/extra/mariabackup/ds_stdout.cc index 08776e99329..a9639ff7739 100644 --- a/extra/mariabackup/ds_stdout.cc +++ b/extra/mariabackup/ds_stdout.cc @@ -75,7 +75,7 @@ stdout_open(ds_ctxt_t *ctxt __attribute__((unused)), stdout_file = (ds_stdout_file_t *) (file + 1); -#ifdef __WIN__ +#ifdef _WIN32 setmode(fileno(stdout), _O_BINARY); #endif diff --git a/extra/mariabackup/xbstream_read.cc b/extra/mariabackup/xbstream_read.cc index 84bb279aba0..b54a98157ea 100644 --- a/extra/mariabackup/xbstream_read.cc +++ b/extra/mariabackup/xbstream_read.cc @@ -43,7 +43,7 @@ xb_stream_read_new(void) stream = (xb_rstream_t *) my_malloc(PSI_NOT_INSTRUMENTED, sizeof(xb_rstream_t), MYF(MY_FAE)); -#ifdef __WIN__ +#ifdef _WIN32 setmode(fileno(stdin), _O_BINARY); #endif diff --git a/extra/mariabackup/xbstream_write.cc b/extra/mariabackup/xbstream_write.cc index 2c9ffde6c42..5801e867aac 100644 --- a/extra/mariabackup/xbstream_write.cc +++ b/extra/mariabackup/xbstream_write.cc @@ -110,7 +110,7 @@ xb_stream_write_open(xb_wstream_t *stream, const char *path, file->chunk_ptr = file->chunk; file->chunk_free = XB_STREAM_MIN_CHUNK_SIZE; if (onwrite) { -#ifdef __WIN__ +#ifdef _WIN32 setmode(fileno(stdout), _O_BINARY); #endif file->userdata = userdata; diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index 9d1e9a22b4a..04ca6fa11d6 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -1398,7 +1398,7 @@ struct my_option xb_server_options[] = (G_PTR*) &mysql_data_home, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"tmpdir", 't', "Path for temporary files. Several paths may be specified, separated by a " -#if defined(__WIN__) || defined(OS2) || defined(__NETWARE__) +#if defined(_WIN32) "semicolon (;)" #else "colon (:)" @@ -6690,7 +6690,7 @@ static int main_low(char** argv) /* get default temporary directory */ if (!opt_mysql_tmpdir || !opt_mysql_tmpdir[0]) { opt_mysql_tmpdir = getenv("TMPDIR"); -#if defined(__WIN__) +#if defined(_WIN32) if (!opt_mysql_tmpdir) { opt_mysql_tmpdir = getenv("TEMP"); } diff --git a/include/my_dbug.h b/include/my_dbug.h index fa5b4c126d1..e25bfcf28a7 100644 --- a/include/my_dbug.h +++ b/include/my_dbug.h @@ -17,9 +17,9 @@ #ifndef _my_dbug_h #define _my_dbug_h -#ifndef __WIN__ +#ifndef _WIN32 #include -#endif /* not __WIN__ */ +#endif #ifdef __cplusplus extern "C" { @@ -134,7 +134,7 @@ extern int (*dbug_sanity)(void); #define DBUG_FREE_CODE_STATE(arg) dbug_free_code_state(arg) #undef DBUG_ASSERT_AS_PRINTF -#ifndef __WIN__ +#ifndef _WIN32 #define DBUG_ABORT() (_db_flush_(), abort()) #else /* @@ -156,12 +156,12 @@ extern int (*dbug_sanity)(void); An alternative would be to use _exit(EXIT_FAILURE), but then valgrind would report lots of memory leaks. */ -#ifdef __WIN__ +#ifdef _WIN32 #define DBUG_SUICIDE() DBUG_ABORT() #else extern void _db_suicide_(void); #define DBUG_SUICIDE() (_db_flush_(), _db_suicide_()) -#endif /* __WIN__ */ +#endif /* _WIN32 */ #else /* No debugger */ diff --git a/include/my_global.h b/include/my_global.h index e999e555bf7..92fdfef228e 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -20,9 +20,17 @@ #ifndef MY_GLOBAL_INCLUDED #define MY_GLOBAL_INCLUDED -/* Client library users on Windows need this macro defined here. */ -#if !defined(__WIN__) && defined(_WIN32) -#define __WIN__ +/* + MDEV-25602 Deprecate __WIN__ symbol. + Temporarily, allow inside connect engine, + until fixed in upstream. +*/ +#ifndef connect_EXPORTS +#ifdef _MSC_VER +#pragma deprecated("__WIN__") +#elif defined (__GNUC__) +#pragma GCC poison __WIN__ +#endif #endif /* @@ -43,7 +51,7 @@ #undef _WIN #undef _WIN32 #undef _WIN64 -#undef __WIN__ +#undef _WIN32 #undef __WIN32__ #define HAVE_ERRNO_AS_DEFINE #define _POSIX_MONOTONIC_CLOCK @@ -79,7 +87,7 @@ #endif /* WITH_PERFSCHEMA_STORAGE_ENGINE */ /* Make it easier to add conditional code in _expressions_ */ -#ifdef __WIN__ +#ifdef _WIN32 #define IF_WIN(A,B) A #else #define IF_WIN(A,B) B @@ -240,7 +248,7 @@ #endif -#if !defined(__WIN__) +#if !defined(_WIN32) #ifndef _POSIX_PTHREAD_SEMANTICS #define _POSIX_PTHREAD_SEMANTICS /* We want posix threads */ #endif @@ -261,7 +269,7 @@ C_MODE_END #if !defined(SCO) && !defined(_REENTRANT) #define _REENTRANT 1 /* Threads requires reentrant code */ #endif -#endif /* !defined(__WIN__) */ +#endif /* !defined(_WIN32) */ /* gcc/egcs issues */ @@ -588,12 +596,12 @@ typedef SOCKET_SIZE_TYPE size_socket; #endif /* additional file share flags for win32 */ -#ifdef __WIN__ +#ifdef _WIN32 #define _SH_DENYRWD 0x110 /* deny read/write mode & delete */ #define _SH_DENYWRD 0x120 /* deny write mode & delete */ #define _SH_DENYRDD 0x130 /* deny read mode & delete */ #define _SH_DENYDEL 0x140 /* deny delete only */ -#endif /* __WIN__ */ +#endif /* _WIN32 */ /* General constants */ @@ -693,7 +701,7 @@ typedef SOCKET_SIZE_TYPE size_socket; /* Some defines of functions for portability */ #undef remove /* Crashes MySQL on SCO 5.0.0 */ -#ifndef __WIN__ +#ifndef _WIN32 #define closesocket(A) close(A) #endif @@ -915,7 +923,7 @@ typedef ulonglong uint64; #if defined(NO_CLIENT_LONG_LONG) typedef unsigned long my_ulonglong; -#elif defined (__WIN__) +#elif defined (_WIN32) typedef unsigned __int64 my_ulonglong; #else typedef unsigned long long my_ulonglong; @@ -955,7 +963,7 @@ typedef ulonglong table_map; /* Used for table bits in join */ typedef const struct charset_info_st CHARSET_INFO; typedef struct st_mysql_lex_string LEX_STRING; -#if defined(__WIN__) +#if defined(_WIN32) #define socket_errno WSAGetLastError() #define SOCKET_EINTR WSAEINTR #define SOCKET_ETIMEDOUT WSAETIMEDOUT diff --git a/include/my_net.h b/include/my_net.h index 9a4f2f44b49..f56ae09ad8c 100644 --- a/include/my_net.h +++ b/include/my_net.h @@ -43,7 +43,7 @@ C_MODE_START #include #endif -#if !defined(__WIN__) +#if !defined(_WIN32) #include #include #include @@ -52,7 +52,7 @@ C_MODE_START #endif #endif -#if defined(__WIN__) +#if defined(_WIN32) #define O_NONBLOCK 1 /* For emulation of fcntl() */ /* diff --git a/include/my_pthread.h b/include/my_pthread.h index e6fd0dfc5da..d38d69d04a0 100644 --- a/include/my_pthread.h +++ b/include/my_pthread.h @@ -30,7 +30,7 @@ extern "C" { #define EXTERNC #endif /* __cplusplus */ -#if defined(__WIN__) +#if defined(_WIN32) typedef CRITICAL_SECTION pthread_mutex_t; typedef DWORD pthread_t; typedef struct thread_attr { @@ -277,7 +277,7 @@ struct tm *gmtime_r(const time_t *clock, struct tm *res); #define HAVE_PTHREAD_KILL 1 #endif -#endif /* defined(__WIN__) */ +#endif /* defined(_WIN32) */ #if defined(HPUX10) && !defined(DONT_REMAP_PTHREAD_FUNCTIONS) #undef pthread_cond_timedwait diff --git a/include/my_stacktrace.h b/include/my_stacktrace.h index 20b86f45232..7cfee0f7a4f 100644 --- a/include/my_stacktrace.h +++ b/include/my_stacktrace.h @@ -23,7 +23,7 @@ (defined(__alpha__) && defined(__GNUC__)) #define HAVE_STACKTRACE 1 #endif -#elif defined(__WIN__) || defined(HAVE_PRINTSTACK) +#elif defined(_WIN32) || defined(HAVE_PRINTSTACK) #define HAVE_STACKTRACE 1 #endif @@ -49,12 +49,12 @@ void my_write_core(int sig); # if BACKTRACE_DEMANGLE char *my_demangle(const char *mangled_name, int *status); # endif /* BACKTRACE_DEMANGLE */ -# ifdef __WIN__ +# ifdef _WIN32 # define my_setup_stacktrace() void my_set_exception_pointers(EXCEPTION_POINTERS *ep); # else void my_setup_stacktrace(void); -# endif /* __WIN__ */ +# endif /* _WIN32 */ #else # define my_setup_stacktrace() #endif /* ! (defined(HAVE_STACKTRACE) || defined(HAVE_BACKTRACE)) */ diff --git a/include/mysql.h b/include/mysql.h index 6ff4c6d3fad..87def05dc7e 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -32,13 +32,6 @@ #include #endif -#ifdef __CYGWIN__ /* CYGWIN implements a UNIX API */ -#undef WIN -#undef _WIN -#undef _WIN32 -#undef _WIN64 -#undef __WIN__ -#endif #ifdef __cplusplus extern "C" { @@ -53,10 +46,7 @@ extern "C" { typedef char my_bool; #endif -#if (defined(_WIN32) || defined(_WIN64)) && !defined(__WIN__) -#define __WIN__ -#endif -#if !defined(__WIN__) +#if !defined(_WIN32) #define STDCALL #else #define STDCALL __stdcall @@ -130,7 +120,7 @@ typedef unsigned int MYSQL_FIELD_OFFSET; /* offset to current field */ #ifndef MY_GLOBAL_INCLUDED #if defined(NO_CLIENT_LONG_LONG) typedef unsigned long my_ulonglong; -#elif defined (__WIN__) +#elif defined (_WIN32) typedef unsigned __int64 my_ulonglong; #else typedef unsigned long long my_ulonglong; diff --git a/include/mysql_com.h b/include/mysql_com.h index 0f525488b53..e0a81a7e31b 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -96,10 +96,10 @@ #define LOCAL_HOST_NAMEDPIPE "." -#if defined(__WIN__) && !defined( _CUSTOMCONFIG_) +#if defined(_WIN32) && !defined( _CUSTOMCONFIG_) #define MYSQL_NAMEDPIPE "MySQL" #define MYSQL_SERVICENAME "MySQL" -#endif /* __WIN__ */ +#endif /* You should add new commands to the end of this list, otherwise old diff --git a/include/thr_alarm.h b/include/thr_alarm.h index 250590a0e2f..e0f3fdd1c25 100644 --- a/include/thr_alarm.h +++ b/include/thr_alarm.h @@ -65,7 +65,7 @@ typedef my_bool ALARM; #define end_thr_alarm(A) #else -#if defined(__WIN__) +#if defined(_WIN32) typedef struct st_thr_alarm_entry { UINT_PTR crono; @@ -77,7 +77,7 @@ typedef int thr_alarm_entry; #define thr_got_alarm(thr_alarm) (**(thr_alarm)) -#endif /* __WIN__ */ +#endif /* _WIN32 */ typedef thr_alarm_entry* thr_alarm_t; diff --git a/include/violite.h b/include/violite.h index 2333d0018b5..b823e62b2e1 100644 --- a/include/violite.h +++ b/include/violite.h @@ -74,11 +74,11 @@ struct vio_keepalive_opts Vio* vio_new(my_socket sd, enum enum_vio_type type, uint flags); Vio* mysql_socket_vio_new(MYSQL_SOCKET mysql_socket, enum enum_vio_type type, uint flags); -#ifdef __WIN__ +#ifdef _WIN32 Vio* vio_new_win32pipe(HANDLE hPipe); #else #define HANDLE void * -#endif /* __WIN__ */ +#endif /* _WIN32 */ void vio_delete(Vio* vio); int vio_close(Vio* vio); diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc index 3d0482d1cd5..5374c420fac 100644 --- a/libmysqld/lib_sql.cc +++ b/libmysqld/lib_sql.cc @@ -578,7 +578,7 @@ int init_embedded_server(int argc, char **argv, char **groups) /* Get default temporary directory */ opt_mysql_tmpdir=getenv("TMPDIR"); /* Use this if possible */ -#if defined(__WIN__) +#if defined(_WIN32) if (!opt_mysql_tmpdir) opt_mysql_tmpdir=getenv("TEMP"); if (!opt_mysql_tmpdir) diff --git a/libmysqld/libmysql.c b/libmysqld/libmysql.c index 2c954cea390..09ae52aedee 100644 --- a/libmysqld/libmysql.c +++ b/libmysqld/libmysql.c @@ -35,7 +35,7 @@ #ifdef HAVE_PWD_H #include #endif -#if !defined(__WIN__) +#if !defined(_WIN32) #include #include #include @@ -46,7 +46,7 @@ #ifdef HAVE_SYS_SELECT_H #include #endif -#endif /* !defined(__WIN__) */ +#endif /* !defined(_WIN32) */ #if defined(HAVE_POLL_H) #include #elif defined(HAVE_SYS_POLL_H) @@ -55,7 +55,7 @@ #ifdef HAVE_SYS_UN_H #include #endif -#if !defined(__WIN__) +#if !defined(_WIN32) #include /* because of signal() */ #endif #ifndef INADDR_NONE @@ -78,13 +78,13 @@ ulong max_allowed_packet= 1024L*1024L*1024L; my_bool net_flush(NET *net); #endif -#if defined(__WIN__) +#if defined(_WIN32) /* socket_errno is defined in my_global.h for all platforms */ #define perror(A) #else #include #define SOCKET_ERROR -1 -#endif /* __WIN__ */ +#endif /* _WIN32 */ /* If allowed through some configuration, then this needs to @@ -167,7 +167,7 @@ int STDCALL mysql_server_init(int argc __attribute__((unused)), if (!mysql_unix_port) { char *env; -#ifdef __WIN__ +#ifdef _WIN32 mysql_unix_port = (char*) MYSQL_NAMEDPIPE; #else mysql_unix_port = (char*) MYSQL_UNIX_ADDR; @@ -176,7 +176,7 @@ int STDCALL mysql_server_init(int argc __attribute__((unused)), mysql_unix_port = env; } mysql_debug(NullS); -#if defined(SIGPIPE) && !defined(__WIN__) +#if defined(SIGPIPE) && !defined(_WIN32) (void) signal(SIGPIPE, SIG_IGN); #endif #ifdef EMBEDDED_LIBRARY @@ -421,7 +421,7 @@ struct passwd *getpwuid(uid_t); char* getlogin(void); #endif -#if !defined(__WIN__) +#if !defined(_WIN32) void read_user_name(char *name) { diff --git a/libmysqld/libmysqld.c b/libmysqld/libmysqld.c index d29126467e2..774b687f0e2 100644 --- a/libmysqld/libmysqld.c +++ b/libmysqld/libmysqld.c @@ -32,7 +32,7 @@ #ifdef HAVE_PWD_H #include #endif -#if !defined(__WIN__) +#if !defined(_WIN32) #include #include #include @@ -54,7 +54,7 @@ extern ulong net_buffer_length; extern ulong max_allowed_packet; -#if defined(__WIN__) +#if defined(_WIN32) #define ERRNO WSAGetLastError() #define perror(A) #else @@ -69,13 +69,6 @@ struct passwd *getpwuid(uid_t); char* getlogin(void); #endif -#ifdef __WIN__ -static my_bool is_NT(void) -{ - char *os=getenv("OS"); - return (os && !strcmp(os, "Windows_NT")) ? 1 : 0; -} -#endif int mysql_init_character_set(MYSQL *mysql); diff --git a/mysys/get_password.c b/mysys/get_password.c index 2a5ddc9a4d7..24befa6b5df 100644 --- a/mysys/get_password.c +++ b/mysys/get_password.c @@ -29,7 +29,7 @@ #include #endif /* HAVE_PWD_H */ #else /* ! HAVE_GETPASS */ -#ifndef __WIN__ +#ifndef _WIN32 #include #ifdef HAVE_TERMIOS_H /* For tty-password */ #include @@ -49,14 +49,14 @@ #endif #else #include -#endif /* __WIN__ */ +#endif /* _WIN32 */ #endif /* HAVE_GETPASS */ #ifdef HAVE_GETPASSPHRASE /* For Solaris */ #define getpass(A) getpassphrase(A) #endif -#ifdef __WIN__ +#ifdef _WIN32 /* were just going to fake it here and get input from the keyboard */ @@ -204,4 +204,4 @@ char *get_tty_password(const char *opt_message) DBUG_RETURN(my_strdup(PSI_INSTRUMENT_ME, buff, MYF(MY_FAE))); } -#endif /*__WIN__*/ +#endif /*_WIN32*/ diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c index ec5e39938b6..4056935b6d6 100644 --- a/mysys/mf_keycache.c +++ b/mysys/mf_keycache.c @@ -400,7 +400,7 @@ static long keycache_thread_id; #define HASH_LINK_NUMBER(h) \ ((uint) (((char*)(h)-(char *) keycache->hash_link_root)/sizeof(HASH_LINK))) -#if (defined(KEYCACHE_TIMEOUT) && !defined(__WIN__)) || defined(KEYCACHE_DEBUG) +#if (defined(KEYCACHE_TIMEOUT) && !defined(_WIN32)) || defined(KEYCACHE_DEBUG) static int keycache_pthread_cond_wait(mysql_cond_t *cond, mysql_mutex_t *mutex); #else @@ -4674,7 +4674,7 @@ static void keycache_dump(SIMPLE_KEY_CACHE_CB *keycache) #endif /* defined(KEYCACHE_TIMEOUT) */ -#if defined(KEYCACHE_TIMEOUT) && !defined(__WIN__) +#if defined(KEYCACHE_TIMEOUT) && !defined(_WIN32) static int keycache_pthread_cond_wait(mysql_cond_t *cond, @@ -4736,7 +4736,7 @@ static int keycache_pthread_cond_wait(mysql_cond_t *cond, return rc; } #endif -#endif /* defined(KEYCACHE_TIMEOUT) && !defined(__WIN__) */ +#endif /* defined(KEYCACHE_TIMEOUT) && !defined(_WIN32) */ #if defined(KEYCACHE_DEBUG) diff --git a/mysys/mf_path.c b/mysys/mf_path.c index 7da925d6f5f..cba80599daa 100644 --- a/mysys/mf_path.c +++ b/mysys/mf_path.c @@ -74,7 +74,7 @@ char * my_path(char * to, const char *progname, /* test if file without filename is found in path */ /* Returns to if found and to has dirpart if found, else NullS */ -#if defined(__WIN__) +#if defined(_WIN32) #define F_OK 0 #define PATH_SEP ';' #define PROGRAM_EXTENSION ".exe" @@ -107,7 +107,7 @@ static char *find_file_in_path(char *to, const char *name) } } } -#ifdef __WIN__ +#ifdef _WIN32 to[0]=FN_CURLIB; strxmov(to+1,dir,name,ext,NullS); if (!access(to,F_OK)) /* Test in current dir */ diff --git a/mysys/mf_tempdir.c b/mysys/mf_tempdir.c index d09b307c4c7..f2b1ea819b7 100644 --- a/mysys/mf_tempdir.c +++ b/mysys/mf_tempdir.c @@ -16,7 +16,7 @@ #include "mysys_priv.h" #include -#if defined(__WIN__) +#if defined(_WIN32) #define DELIM ';' #else #define DELIM ':' @@ -37,7 +37,7 @@ my_bool init_tmpdir(MY_TMPDIR *tmpdir, const char *pathlist) { /* Get default temporary directory */ pathlist=getenv("TMPDIR"); /* Use this if possible */ -#if defined(__WIN__) +#if defined(_WIN32) if (!pathlist) pathlist=getenv("TEMP"); if (!pathlist) diff --git a/mysys/my_access.c b/mysys/my_access.c index 65746295391..81e635d9716 100644 --- a/mysys/my_access.c +++ b/mysys/my_access.c @@ -17,7 +17,7 @@ #include "mysys_priv.h" #include -#ifdef __WIN__ +#ifdef _WIN32 /* Check a file or path for accessability. @@ -46,7 +46,7 @@ int my_access(const char *path, int amode) return 0; } -#endif /* __WIN__ */ +#endif /* _WIN32 */ /* @@ -150,7 +150,7 @@ int check_if_legal_tablename(const char *name) } -#ifdef __WIN__ +#ifdef _WIN32 /** Checks if the drive letter supplied is valid or not. Valid drive letters are A to Z, both lower case and upper case. @@ -217,10 +217,9 @@ my_bool is_filename_allowed(const char *name __attribute__((unused)), } return TRUE; } /* is_filename_allowed */ -#endif /* __WIN__ */ - -#if defined(__WIN__) || defined(__EMX__) +#endif /* _WIN32 */ +#if defined(_WIN32) /* Check if a path will access a reserved file name that may cause problems @@ -265,4 +264,4 @@ int check_if_legal_filename(const char *path) DBUG_RETURN(0); } -#endif /* defined(__WIN__) || defined(__EMX__) */ +#endif /* defined(_WIN32) */ diff --git a/mysys/my_conio.c b/mysys/my_conio.c index 04750635dd3..abcfa9798ec 100644 --- a/mysys/my_conio.c +++ b/mysys/my_conio.c @@ -17,7 +17,7 @@ #include "mysys_priv.h" -#ifdef __WIN__ +#ifdef _WIN32 static HANDLE my_coninpfh= 0; /* console input */ @@ -220,4 +220,4 @@ char* my_cgets(char *buffer, size_t clen, size_t* plen) return result; } -#endif /* __WIN__ */ +#endif /* _WIN32 */ diff --git a/mysys/my_copy.c b/mysys/my_copy.c index 94ad3f6b665..3b07dd5fd53 100644 --- a/mysys/my_copy.c +++ b/mysys/my_copy.c @@ -116,7 +116,7 @@ int my_copy(const char *from, const char *to, myf MyFlags) if (MyFlags & MY_FAE) goto err; } -#if !defined(__WIN__) +#if !defined(_WIN32) /* Copy ownership */ if (chown(to, stat_buff.st_uid, stat_buff.st_gid)) { diff --git a/mysys/my_default.c b/mysys/my_default.c index ec94aee290c..cc4462a240b 100644 --- a/mysys/my_default.c +++ b/mysys/my_default.c @@ -39,7 +39,7 @@ #include #include #include -#ifdef __WIN__ +#ifdef _WIN32 #include #endif @@ -66,7 +66,7 @@ const char *my_defaults_extra_file=0; #define DEFAULT_DIRS_SIZE (MAX_DEFAULT_DIRS + 1) /* Terminate with NULL */ static const char **default_directories = NULL; -#ifdef __WIN__ +#ifdef _WIN32 static const char *f_extensions[]= { ".ini", ".cnf", 0 }; #define NEWLINE "\r\n" #else @@ -620,7 +620,7 @@ static int search_default_file_with_ext(struct handle_option_ctx *ctx, strmov(name,config_file); } fn_format(name,name,"","",4); -#if !defined(__WIN__) +#if !defined(_WIN32) { MY_STAT stat_info; if (!my_stat(name,&stat_info,MYF(0))) @@ -973,7 +973,7 @@ static int add_directory(MEM_ROOT *alloc, const char *dir, const char **dirs) return 0; } -#ifdef __WIN__ +#ifdef _WIN32 static const char *my_get_module_parent(char *buf, size_t size) { char *last= NULL; @@ -1003,7 +1003,7 @@ static const char *my_get_module_parent(char *buf, size_t size) return buf; } -#endif /* __WIN__ */ +#endif /* _WIN32 */ static const char **init_default_directories(MEM_ROOT *alloc) @@ -1018,7 +1018,7 @@ static const char **init_default_directories(MEM_ROOT *alloc) DBUG_RETURN(NULL); bzero((char *) dirs, DEFAULT_DIRS_SIZE * sizeof(char *)); -#ifdef __WIN__ +#ifdef _WIN32 { char fname_buffer[FN_REFLEN]; @@ -1066,7 +1066,7 @@ static const char **init_default_directories(MEM_ROOT *alloc) /* Placeholder for --defaults-extra-file= */ errors += add_directory(alloc, "", dirs); -#if !defined(__WIN__) +#if !defined(_WIN32) errors += add_directory(alloc, "~/", dirs); #endif diff --git a/mysys/my_getncpus.c b/mysys/my_getncpus.c index 0d081b72d11..1f5fa794a55 100644 --- a/mysys/my_getncpus.c +++ b/mysys/my_getncpus.c @@ -63,7 +63,7 @@ int my_getncpus(void) #ifdef _SC_NPROCESSORS_ONLN ncpus= sysconf(_SC_NPROCESSORS_ONLN); -#elif defined(__WIN__) +#elif defined(_WIN32) SYSTEM_INFO sysinfo; /* diff --git a/mysys/my_getpagesize.c b/mysys/my_getpagesize.c index 030a62deb61..62d077ccdc4 100644 --- a/mysys/my_getpagesize.c +++ b/mysys/my_getpagesize.c @@ -18,7 +18,7 @@ #ifndef HAVE_GETPAGESIZE -#if defined __WIN__ +#if defined _WIN32 int my_getpagesize(void) { diff --git a/mysys/my_getwd.c b/mysys/my_getwd.c index cdad96b3a84..d74c263db03 100644 --- a/mysys/my_getwd.c +++ b/mysys/my_getwd.c @@ -22,7 +22,7 @@ #ifdef HAVE_GETWD #include #endif -#if defined(__WIN__) +#if defined(_WIN32) #include #include #include diff --git a/mysys/my_mkdir.c b/mysys/my_mkdir.c index f9067710331..00bcca7776e 100644 --- a/mysys/my_mkdir.c +++ b/mysys/my_mkdir.c @@ -18,7 +18,7 @@ #include "mysys_err.h" #include #include -#ifdef __WIN__ +#ifdef _WIN32 #include #endif diff --git a/mysys/my_pthread.c b/mysys/my_pthread.c index c1567f2cd03..0e766876792 100644 --- a/mysys/my_pthread.c +++ b/mysys/my_pthread.c @@ -90,7 +90,7 @@ struct tm *gmtime_r(const time_t *clock, struct tm *res) ** Author: Gary Wisniewski , much modified by Monty ****************************************************************************/ -#if !defined(HAVE_SIGWAIT) && !defined(sigwait) && !defined(__WIN__) && !defined(HAVE_rts_threads) +#if !defined(HAVE_SIGWAIT) && !defined(sigwait) && !defined(_WIN32) && !defined(HAVE_rts_threads) #if !defined(DONT_USE_SIGSUSPEND) diff --git a/mysys/my_redel.c b/mysys/my_redel.c index 1a69eaa291f..3dacfff96dd 100644 --- a/mysys/my_redel.c +++ b/mysys/my_redel.c @@ -106,7 +106,7 @@ int my_copystat(const char *from, const char *to, int MyFlags) return -1; } -#if !defined(__WIN__) +#if !defined(_WIN32) if (statbuf.st_nlink > 1 && MyFlags & MY_LINK_WARNING) { if (MyFlags & MY_LINK_WARNING) @@ -121,7 +121,7 @@ int my_copystat(const char *from, const char *to, int MyFlags) if (MyFlags & MY_FAE) return -1; } -#endif /* !__WIN__ */ +#endif /* !_WIN32 */ if (MyFlags & MY_COPYTIME) { diff --git a/mysys/my_rename.c b/mysys/my_rename.c index 7b31e83be20..93a59342b6c 100644 --- a/mysys/my_rename.c +++ b/mysys/my_rename.c @@ -81,7 +81,7 @@ int my_rename(const char *from, const char *to, myf MyFlags) DBUG_ENTER("my_rename"); DBUG_PRINT("my",("from %s to %s MyFlags %lu", from, to, MyFlags)); -#if defined(__WIN__) +#if defined(_WIN32) if (!win_rename_with_retries(from, to)) { my_osmaperr(GetLastError()); diff --git a/mysys/my_sleep.c b/mysys/my_sleep.c index 1c54b696aea..fff58e4aa2a 100644 --- a/mysys/my_sleep.c +++ b/mysys/my_sleep.c @@ -20,7 +20,7 @@ void my_sleep(ulong m_seconds) { -#if defined(__WIN__) +#if defined(_WIN32) Sleep(m_seconds/1000+1); /* Sleep() has millisecond arg */ #elif defined(HAVE_SELECT) struct timeval t; diff --git a/mysys/my_wincond.c b/mysys/my_wincond.c index 64c48c5aeba..978be9db862 100644 --- a/mysys/my_wincond.c +++ b/mysys/my_wincond.c @@ -111,4 +111,4 @@ int pthread_attr_destroy(pthread_attr_t *connect_att) return 0; } -#endif /* __WIN__ */ +#endif /* _WIN32 */ diff --git a/mysys/stacktrace.c b/mysys/stacktrace.c index 5718b2e762d..250d0bdbea2 100644 --- a/mysys/stacktrace.c +++ b/mysys/stacktrace.c @@ -18,7 +18,7 @@ #include "mysys_priv.h" #include -#ifndef __WIN__ +#ifndef _WIN32 #include #include #ifdef HAVE_STACKTRACE @@ -43,10 +43,10 @@ static sig_handler default_handle_fatal_signal(int sig) my_safe_printf_stderr("%s: Got signal %d. Attempting backtrace\n", my_progname_short, sig); my_print_stacktrace(0,0,1); -#ifndef __WIN__ +#ifndef _WIN32 signal(sig, SIG_DFL); kill(getpid(), sig); -#endif /* __WIN__ */ +#endif /* _WIN32 */ return; } @@ -428,7 +428,7 @@ void my_write_core(int sig) #endif } -#else /* __WIN__*/ +#else /* _WIN32*/ #ifdef _MSC_VER /* Silence warning in OS header dbghelp.h */ @@ -713,7 +713,7 @@ int my_safe_print_str(const char *val, size_t len) } return 0; } -#endif /*__WIN__*/ +#endif /*_WIN32*/ size_t my_write_stderr(const void *buf, size_t count) diff --git a/mysys/string.c b/mysys/string.c index b346393d91e..91e4306ced4 100644 --- a/mysys/string.c +++ b/mysys/string.c @@ -145,13 +145,13 @@ my_bool dynstr_trunc(DYNAMIC_STRING *str, size_t n) my_bool dynstr_append_os_quoted(DYNAMIC_STRING *str, const char *append, ...) { -#ifdef __WIN__ +#ifdef _WIN32 LEX_CSTRING quote= { C_STRING_WITH_LEN("\"") }; LEX_CSTRING replace= { C_STRING_WITH_LEN("\\\"") }; #else LEX_CSTRING quote= { C_STRING_WITH_LEN("\'") }; LEX_CSTRING replace= { C_STRING_WITH_LEN("'\"'\"'") }; -#endif /* __WIN__ */ +#endif /* _WIN32 */ my_bool ret= TRUE; va_list dirty_text; diff --git a/mysys/thr_alarm.c b/mysys/thr_alarm.c index 92a471075c6..666f444b51c 100644 --- a/mysys/thr_alarm.c +++ b/mysys/thr_alarm.c @@ -50,7 +50,7 @@ my_bool thr_alarm_inited= 0, my_disable_thr_alarm= 0; -#if !defined(__WIN__) +#if !defined(_WIN32) uint thr_client_alarm; static int alarm_aborted=1; /* No alarm thread */ diff --git a/mysys/thr_mutex.c b/mysys/thr_mutex.c index 2a8e54621c0..dd3a5ce132f 100644 --- a/mysys/thr_mutex.c +++ b/mysys/thr_mutex.c @@ -433,7 +433,7 @@ int safe_mutex_unlock(safe_mutex_t *mp,const char *file, uint line) remove_from_active_list(mp); -#ifdef __WIN__ +#ifdef _WIN32 pthread_mutex_unlock(&mp->mutex); error=0; #else @@ -446,7 +446,7 @@ int safe_mutex_unlock(safe_mutex_t *mp,const char *file, uint line) fflush(stderr); abort(); } -#endif /* __WIN__ */ +#endif /* _WIN32 */ pthread_mutex_unlock(&mp->global); return error; } @@ -603,7 +603,7 @@ int safe_mutex_destroy(safe_mutex_t *mp, const char *file, uint line) /* Free all entries that points to this one */ safe_mutex_free_deadlock_data(mp); -#ifdef __WIN__ +#ifdef _WIN32 pthread_mutex_destroy(&mp->global); pthread_mutex_destroy(&mp->mutex); #else @@ -611,7 +611,7 @@ int safe_mutex_destroy(safe_mutex_t *mp, const char *file, uint line) error=1; if (pthread_mutex_destroy(&mp->mutex)) error=1; -#endif /* __WIN__ */ +#endif /* _WIN32 */ mp->file= 0; /* Mark destroyed */ #ifdef SAFE_MUTEX_DETECT_DESTROY diff --git a/plugin/feedback/utils.cc b/plugin/feedback/utils.cc index e362446204f..bbbd5850089 100644 --- a/plugin/feedback/utils.cc +++ b/plugin/feedback/utils.cc @@ -246,7 +246,7 @@ int my_getncpus() { #ifdef _SC_NPROCESSORS_ONLN return sysconf(_SC_NPROCESSORS_ONLN); -#elif defined(__WIN__) +#elif defined(_WIN32) SYSTEM_INFO sysinfo; GetSystemInfo(&sysinfo); return sysinfo.dwNumberOfProcessors; diff --git a/plugin/server_audit/server_audit.c b/plugin/server_audit/server_audit.c index bfabe763eb7..49d41627275 100644 --- a/plugin/server_audit/server_audit.c +++ b/plugin/server_audit/server_audit.c @@ -217,7 +217,7 @@ static int loc_rename(const char *from, const char *to) { int error = 0; -#if defined(__WIN__) +#if defined(_WIN32) if (!MoveFileEx(from, to, MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING)) { @@ -1044,9 +1044,9 @@ static int get_user_host(const char *uh_line, unsigned int uh_len, return 0; } -#if defined(__WIN__) && !defined(S_ISDIR) +#if defined(_WIN32) && !defined(S_ISDIR) #define S_ISDIR(x) ((x) & _S_IFDIR) -#endif /*__WIN__ && !S_ISDIR*/ +#endif /*_WIN32 && !S_ISDIR*/ static int start_logging() { diff --git a/sql/custom_conf.h b/sql/custom_conf.h index 5847b939ca7..f0bb619a515 100644 --- a/sql/custom_conf.h +++ b/sql/custom_conf.h @@ -18,7 +18,7 @@ #define __MYSQL_CUSTOM_BUILD_CONFIG__ #define MYSQL_PORT 5002 -#ifdef __WIN__ +#ifdef _WIN32 #define MYSQL_NAMEDPIPE "SwSqlServer" #define MYSQL_SERVICENAME "SwSqlServer" #define KEY_SERVICE_PARAMETERS diff --git a/sql/hash_filo.cc b/sql/hash_filo.cc index b359bd95786..085c12f15da 100644 --- a/sql/hash_filo.cc +++ b/sql/hash_filo.cc @@ -27,7 +27,7 @@ #include "sql_priv.h" #include "hash_filo.h" -#ifdef __WIN__ +#ifdef _WIN32 // Remove linker warning 4221 about empty file namespace { char dummy; }; -#endif // __WIN__ +#endif // _WIN32 diff --git a/sql/hostname.cc b/sql/hostname.cc index fed47e88597..7b07ab620a6 100644 --- a/sql/hostname.cc +++ b/sql/hostname.cc @@ -28,7 +28,7 @@ #include "sql_priv.h" #include "unireg.h" // SPECIAL_NO_HOST_CACHE #include "hostname.h" -#ifndef __WIN__ +#ifndef _WIN32 #include // getservbyname, servent #endif #include "hash_filo.h" @@ -40,12 +40,12 @@ #ifdef __cplusplus extern "C" { // Because of SCO 3.2V4.2 #endif -#if !defined( __WIN__) +#if !defined( _WIN32) #ifdef HAVE_SYS_UN_H #include #endif #include -#endif // __WIN__ +#endif // _WIN32 #ifdef __cplusplus } #endif diff --git a/sql/mf_iocache.cc b/sql/mf_iocache.cc index 877a49edbec..a8087ed5fc5 100644 --- a/sql/mf_iocache.cc +++ b/sql/mf_iocache.cc @@ -87,7 +87,7 @@ int _my_b_net_read(IO_CACHE *info, uchar *Buffer, size_t) } /* extern "C" */ -#elif defined(__WIN__) +#elif defined(_WIN32) // Remove linker warning 4221 about empty file namespace { char dummy; }; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index dcddb157cda..249dde9177c 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -18,7 +18,7 @@ #include "sql_priv.h" #include "unireg.h" #include -#ifndef __WIN__ +#ifndef _WIN32 #include // getservbyname, servent #endif #include "sql_parse.h" // path_starts_from_data_home_dir @@ -148,7 +148,7 @@ extern "C" { // Because of SCO 3.2V4.2 #endif #include -#if !defined(__WIN__) +#if !defined(_WIN32) #include #ifdef HAVE_SYS_UN_H #include @@ -160,11 +160,11 @@ extern "C" { // Because of SCO 3.2V4.2 #include #endif #include -#endif /* __WIN__ */ +#endif /* _WIN32 */ #include -#ifdef __WIN__ +#ifdef _WIN32 #include #endif @@ -1636,7 +1636,7 @@ static void break_connect_loop() #endif } mysql_mutex_unlock(&LOCK_start_thread); -#endif /* __WIN__ */ +#endif /* _WIN32 */ } @@ -1784,7 +1784,7 @@ extern "C" sig_handler print_signal_warning(int sig) #ifdef SIGNAL_HANDLER_RESET_ON_DELIVERY my_sigset(sig,print_signal_warning); /* int. thread system calls */ #endif -#if !defined(__WIN__) +#if !defined(_WIN32) if (sig == SIGALRM) alarm(2); /* reschedule alarm */ #endif @@ -2109,7 +2109,7 @@ static void set_ports() } if (!mysqld_unix_port) { -#ifdef __WIN__ +#ifdef _WIN32 mysqld_unix_port= (char*) MYSQL_NAMEDPIPE; #else mysqld_unix_port= (char*) MYSQL_UNIX_ADDR; @@ -2168,7 +2168,7 @@ static void set_user(const char *user, struct passwd *user_info_arg) allow_coredumps(); } -#if !defined(__WIN__) +#if !defined(_WIN32) static void set_effective_user(struct passwd *user_info_arg) { DBUG_ASSERT(user_info_arg != 0); @@ -2189,7 +2189,7 @@ static void set_effective_user(struct passwd *user_info_arg) /** Change root user if started with @c --chroot . */ static void set_root(const char *path) { -#if !defined(__WIN__) +#if !defined(_WIN32) if (chroot(path) == -1) { sql_perror("chroot"); @@ -2272,7 +2272,7 @@ static void activate_tcp_port(uint port, mysql_socket_set_thread_owner(ip_sock); -#ifndef __WIN__ +#ifndef _WIN32 /* We should not use SO_REUSEADDR on windows as this would enable a user to open two mysqld servers with the same TCP/IP port. @@ -2280,7 +2280,7 @@ static void activate_tcp_port(uint port, arg= 1; (void) mysql_socket_setsockopt(ip_sock, SOL_SOCKET, SO_REUSEADDR, (char*)&arg, sizeof(arg)); -#endif /* __WIN__ */ +#endif /* _WIN32 */ #ifdef IPV6_V6ONLY /* @@ -2898,7 +2898,7 @@ static void start_signal_handler(void) static void check_data_home(const char *path) {} -#endif /* __WIN__ */ +#endif /* _WIN32 */ #if BACKTRACE_DEMANGLE @@ -2925,7 +2925,7 @@ mariadb_dbug_assert_failed(const char *assert_expr, const char *file, } #endif /* DBUG_ASSERT_AS_PRINT */ -#if !defined(__WIN__) +#if !defined(_WIN32) #ifndef SA_RESETHAND #define SA_RESETHAND 0 #endif /* SA_RESETHAND */ @@ -3191,7 +3191,7 @@ static void check_data_home(const char *path) {} #endif /*!EMBEDDED_LIBRARY*/ -#endif /* __WIN__*/ +#endif /* _WIN32*/ /** @@ -3995,7 +3995,7 @@ static int init_common_variables() /* MyISAM requires two file handles per table. */ wanted_files= (extra_files + max_connections + extra_max_connections + tc_size * 2 * tc_instances); -#if defined(HAVE_POOL_OF_THREADS) && !defined(__WIN__) +#if defined(HAVE_POOL_OF_THREADS) && !defined(_WIN32) // add epoll or kevent fd for each threadpool group, in case pool of threads is used wanted_files+= (thread_handling > SCHEDULER_NO_THREADS) ? 0 : threadpool_size; #endif @@ -6615,7 +6615,7 @@ struct my_option my_long_options[]= &opt_use_ssl, &opt_use_ssl, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0}, #endif -#ifdef __WIN__ +#ifdef _WIN32 {"standalone", 0, "Dummy option to start as a standalone program (NT).", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -7541,7 +7541,7 @@ static void usage(void) puts("\nFor more help options (several pages), use mysqld --verbose --help."); else { -#ifdef __WIN__ +#ifdef _WIN32 puts("NT and Win32 specific options:\n" " --install Install the default service (NT).\n" " --install-manual Install the default service started manually (NT).\n" @@ -7759,7 +7759,7 @@ static int mysql_init_variables(void) #endif /* ! EMBEDDED_LIBRARY */ #endif /* HAVE_OPENSSL */ -#if defined(__WIN__) +#if defined(_WIN32) /* Allow Win32 users to move MySQL anywhere */ { char prg_dev[LIBLEN]; diff --git a/sql/mysqld.h b/sql/mysqld.h index ff7060425cb..5356fd967c7 100644 --- a/sql/mysqld.h +++ b/sql/mysqld.h @@ -697,7 +697,7 @@ void init_sql_statement_info(); void init_com_statement_info(); #endif /* HAVE_PSI_STATEMENT_INTERFACE */ -#ifndef __WIN__ +#ifndef _WIN32 extern pthread_t signal_thread; #endif diff --git a/sql/net_serv.cc b/sql/net_serv.cc index 409d3cac85e..8b0f1eed46d 100644 --- a/sql/net_serv.cc +++ b/sql/net_serv.cc @@ -92,7 +92,7 @@ static void inline MYSQL_SERVER_my_error(...) {} the client should have a bigger max_allowed_packet. */ -#if defined(__WIN__) || !defined(MYSQL_SERVER) +#if defined(_WIN32) || !defined(MYSQL_SERVER) /* The following is because alarms doesn't work on windows. */ #ifndef NO_ALARM #define NO_ALARM @@ -167,7 +167,7 @@ my_bool my_net_init(NET *net, Vio *vio, void *thd, uint my_flags) { /* For perl DBI/DBD. */ net->fd= vio_fd(vio); -#if defined(MYSQL_SERVER) && !defined(__WIN__) +#if defined(MYSQL_SERVER) && !defined(_WIN32) if (!(test_flags & TEST_BLOCKING)) { my_bool old_mode; @@ -279,7 +279,7 @@ static int net_data_is_ready(my_socket sd) struct timeval tv; int res; -#ifndef __WIN__ +#ifndef _WIN32 /* Windows uses an _array_ of 64 fd's as default, so it's safe */ if (sd >= FD_SETSIZE) return -1; @@ -710,7 +710,7 @@ net_real_write(NET *net,const uchar *packet, size_t len) if ((long) (length= vio_write(net->vio,pos,(size_t) (end-pos))) <= 0) { my_bool interrupted = vio_should_retry(net->vio); -#if !defined(__WIN__) +#if !defined(_WIN32) if ((interrupted || length == 0) && !thr_alarm_in_use(&alarmed)) { if (!thr_alarm(&alarmed, net->write_timeout, &alarm_buff)) @@ -733,7 +733,7 @@ net_real_write(NET *net,const uchar *packet, size_t len) } } else -#endif /* !defined(__WIN__) */ +#endif /* !defined(_WIN32) */ if (thr_alarm_in_use(&alarmed) && !thr_got_alarm(&alarmed) && interrupted) { @@ -758,7 +758,7 @@ net_real_write(NET *net,const uchar *packet, size_t len) pos+=length; update_statistics(thd_increment_bytes_sent(net->thd, length)); } -#ifndef __WIN__ +#ifndef _WIN32 end: #endif #ifdef HAVE_COMPRESS @@ -1005,7 +1005,7 @@ retry: goto end; } -#if !defined(__WIN__) && defined(MYSQL_SERVER) +#if !defined(_WIN32) && defined(MYSQL_SERVER) /* We got an error that there was no data on the socket. We now set up an alarm to not 'read forever', change the socket to the blocking @@ -1037,7 +1037,7 @@ retry: continue; } } -#endif /* (!defined(__WIN__) && defined(MYSQL_SERVER) */ +#endif /* (!defined(_WIN32) && defined(MYSQL_SERVER) */ if (thr_alarm_in_use(&alarmed) && !thr_got_alarm(&alarmed) && interrupted) { /* Probably in MIT threads */ diff --git a/sql/signal_handler.cc b/sql/signal_handler.cc index 7b3cfefa377..f233f8a3a82 100644 --- a/sql/signal_handler.cc +++ b/sql/signal_handler.cc @@ -24,7 +24,7 @@ #include "sql_class.h" #include "my_stacktrace.h" -#ifdef __WIN__ +#ifdef _WIN32 #include #define SIGNAL_FMT "exception 0x%x" #else @@ -346,7 +346,7 @@ extern "C" sig_handler handle_fatal_signal(int sig) #endif end: -#ifndef __WIN__ +#ifndef _WIN32 /* Quit, without running destructors (etc.) Use a signal, because the parent (systemd) can check that with WIFSIGNALED diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 160ca1f5f2f..6845fe80445 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -54,7 +54,7 @@ #include "sql_table.h" // build_table_filename #include "datadict.h" // dd_frm_is_view() #include "rpl_rli.h" // rpl_group_info -#ifdef __WIN__ +#ifdef _WIN32 #include #endif #include "wsrep_mysqld.h" diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 017ae3c5eff..1d27854dc82 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1851,7 +1851,7 @@ void add_diff_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var, } #define SECONDS_TO_WAIT_FOR_KILL 2 -#if !defined(__WIN__) && defined(HAVE_SELECT) +#if !defined(_WIN32) && defined(HAVE_SELECT) /* my_sleep() can wait for sub second times */ #define WAIT_FOR_KILL_TRY_TIMES 20 #else diff --git a/sql/sql_class.h b/sql/sql_class.h index 3f748c6a206..0f85da68c8e 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -3033,7 +3033,7 @@ public: } default_transaction, *transaction; Global_read_lock global_read_lock; Field *dup_field; -#ifndef __WIN__ +#ifndef _WIN32 sigset_t signals; #endif #ifdef SIGNAL_WITH_VIO_CLOSE diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc index 1da8c42d96e..31297782f30 100644 --- a/sql/sql_connect.cc +++ b/sql/sql_connect.cc @@ -23,7 +23,7 @@ #include "mariadb.h" #include "mysqld.h" #include "sql_priv.h" -#ifndef __WIN__ +#ifndef _WIN32 #include // getservbyname, servent #endif #include "sql_audit.h" diff --git a/sql/sql_const.h b/sql/sql_const.h index 762728aa876..bcc556e61f9 100644 --- a/sql/sql_const.h +++ b/sql/sql_const.h @@ -297,19 +297,6 @@ */ #define MAX_TIME_ZONE_NAME_LENGTH (NAME_LEN + 1) -#if defined(__WIN__) - -#define INTERRUPT_PRIOR -2 -#define CONNECT_PRIOR -1 -#define WAIT_PRIOR 0 -#define QUERY_PRIOR 2 -#else -#define INTERRUPT_PRIOR 10 -#define CONNECT_PRIOR 9 -#define WAIT_PRIOR 8 -#define QUERY_PRIOR 6 -#endif /* __WIN92__ */ - #define SP_PSI_STATEMENT_INFO_COUNT 19 #endif /* SQL_CONST_INCLUDED */ diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 090b87af4ff..37e136927f2 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -44,7 +44,7 @@ #include #include #include "log.h" -#ifdef __WIN__ +#ifdef _WIN32 #include #endif #include "debug.h" // debug_crash_here diff --git a/sql/sql_load.cc b/sql/sql_load.cc index b144d2afda4..0e3cdaac569 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -567,7 +567,7 @@ int mysql_load(THD *thd, const sql_exchange *ex, TABLE_LIST *table_list, DBUG_RETURN(TRUE); } -#if !defined(__WIN__) && ! defined(__NETWARE__) +#if !defined(_WIN32) MY_STAT stat_info; if (!my_stat(name, &stat_info, MYF(MY_WME))) DBUG_RETURN(TRUE); diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 397b8a8a350..d7bb02bbd4e 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -2183,7 +2183,7 @@ static int add_keyword_path(String *str, const char *keyword, { char temp_path[FN_REFLEN]; strcpy(temp_path, path); -#ifdef __WIN__ +#ifdef _WIN32 /* Convert \ to / to be able to create table on unix */ char *pos, *end; size_t length= strlen(temp_path); diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 61cf204d721..c7a93a72a99 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -1959,7 +1959,7 @@ static bool plugin_load_list(MEM_ROOT *tmp_root, const char *list) list= NULL; /* terminate the loop */ /* fall through */ case ';': -#ifndef __WIN__ +#ifndef _WIN32 case ':': /* can't use this as delimiter as it may be drive letter */ #endif p[-1]= 0; diff --git a/sql/sql_profile.cc b/sql/sql_profile.cc index d8ecd2abee7..f576e693a0e 100644 --- a/sql/sql_profile.cc +++ b/sql/sql_profile.cc @@ -610,7 +610,7 @@ int PROFILING::fill_statistics_info(THD *thd_arg, TABLE_LIST *tables, Item *cond table->field[9]->store((uint32)(entry->rusage.ru_oublock - previous->rusage.ru_oublock)); table->field[9]->set_notnull(); -#elif defined(__WIN__) +#elif defined(_WIN32) ULONGLONG reads_delta = entry->io_count.ReadOperationCount - previous->io_count.ReadOperationCount; ULONGLONG writes_delta = entry->io_count.WriteOperationCount - @@ -643,7 +643,7 @@ int PROFILING::fill_statistics_info(THD *thd_arg, TABLE_LIST *tables, Item *cond table->field[13]->store((uint32)(entry->rusage.ru_minflt - previous->rusage.ru_minflt), true); table->field[13]->set_notnull(); -#elif defined(__WIN__) +#elif defined(_WIN32) /* Windows APIs don't easily distinguish between hard and soft page faults, so we just fill the 'major' column and leave the second NULL. */ diff --git a/sql/sql_profile.h b/sql/sql_profile.h index 85018a2598b..881365596ed 100644 --- a/sql/sql_profile.h +++ b/sql/sql_profile.h @@ -46,7 +46,7 @@ int make_profile_table_for_show(THD *thd, ST_SCHEMA_TABLE *schema_table); #include "sql_priv.h" #include "unireg.h" -#ifdef __WIN__ +#ifdef _WIN32 #include #endif diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 193e6beffba..53c5f6d741d 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1651,7 +1651,7 @@ static void append_directory(THD *thd, String *packet, LEX_CSTRING *dir_type, packet->append(' '); packet->append(dir_type); packet->append(STRING_WITH_LEN(" DIRECTORY='")); -#ifdef __WIN__ +#ifdef _WIN32 /* Convert \ to / to be able to create table on unix */ char *winfilename= (char*) thd->memdup(filename, length); char *pos, *end; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index cd48f58da10..e637d680973 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -59,7 +59,7 @@ #include "debug.h" // debug_crash_here() #include -#ifdef __WIN__ +#ifdef _WIN32 #include #endif diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 73fefeead50..fa4e769232d 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -3031,7 +3031,7 @@ static Sys_var_ulonglong Sys_thread_stack( static Sys_var_charptr_fscs Sys_tmpdir( "tmpdir", "Path for temporary files. Several paths may " "be specified, separated by a " -#if defined(__WIN__) +#if defined(_WIN32) "semicolon (;)" #else "colon (:)" diff --git a/sql/udf_example.c b/sql/udf_example.c index cb3f3ad1c98..14c793ee98a 100644 --- a/sql/udf_example.c +++ b/sql/udf_example.c @@ -122,13 +122,13 @@ #include #include #include -#ifdef __WIN__ +#ifdef _WIN32 typedef unsigned __int64 ulonglong; /* Microsofts 64 bit types */ typedef __int64 longlong; #else typedef unsigned long long ulonglong; typedef long long longlong; -#endif /*__WIN__*/ +#endif /*_WIN32*/ #else #include "mariadb.h" #include @@ -700,7 +700,7 @@ longlong udf_sequence(UDF_INIT *initid __attribute__((unused)), UDF_ARGS *args, ** ****************************************************************************/ -#ifdef __WIN__ +#ifdef _WIN32 #include #else #include diff --git a/sql/wsrep_sst.cc b/sql/wsrep_sst.cc index 1cce8259d5c..57c1885b777 100644 --- a/sql/wsrep_sst.cc +++ b/sql/wsrep_sst.cc @@ -729,7 +729,7 @@ static int sst_append_env_var(wsp::env& env, return -env.error(); } -#ifdef __WIN__ +#ifdef _WIN32 /* Space, single quote, ampersand, backquote, I/O redirection characters, caret, all brackets, plus, exclamation and comma @@ -803,7 +803,7 @@ static size_t estimate_cmd_len (bool* extra_args) else if (IS_REQ_ESCAPING(c)) { cmd_len++; -#ifdef __WIN__ +#ifdef _WIN32 quotation= true; #endif } @@ -832,7 +832,7 @@ static size_t estimate_cmd_len (bool* extra_args) else if (IS_REQ_ESCAPING(c)) { cmd_len++; -#ifdef __WIN__ +#ifdef _WIN32 quotation= true; #endif } @@ -888,7 +888,7 @@ static void copy_orig_argv (char* cmd_str) else if (IS_REQ_ESCAPING(c)) { plain= false; -#ifdef __WIN__ +#ifdef _WIN32 quotation= true; #endif } @@ -928,7 +928,7 @@ static void copy_orig_argv (char* cmd_str) c = *arg++; if (IS_REQ_ESCAPING(c)) { -#ifdef __WIN__ +#ifdef _WIN32 *cmd_str++ = c; #else *cmd_str++ = '\\'; @@ -968,7 +968,7 @@ static void copy_orig_argv (char* cmd_str) else if (IS_REQ_ESCAPING(c)) { plain= false; -#ifdef __WIN__ +#ifdef _WIN32 quotation= true; #endif } @@ -999,7 +999,7 @@ static void copy_orig_argv (char* cmd_str) { if (IS_REQ_ESCAPING(c)) { -#ifdef __WIN__ +#ifdef _WIN32 *cmd_str++ = c; #else *cmd_str++ = '\\'; diff --git a/storage/connect/CMakeLists.txt b/storage/connect/CMakeLists.txt index a41ed86371d..a2cd035d336 100644 --- a/storage/connect/CMakeLists.txt +++ b/storage/connect/CMakeLists.txt @@ -82,6 +82,7 @@ ELSE(NOT UNIX) # Connect does not work with clang-cl RETURN() ENDIF() + add_definitions(-D__WIN__) ENDIF(UNIX) diff --git a/storage/federatedx/ha_federatedx.cc b/storage/federatedx/ha_federatedx.cc index bea741fa7b2..99513d70950 100644 --- a/storage/federatedx/ha_federatedx.cc +++ b/storage/federatedx/ha_federatedx.cc @@ -1466,7 +1466,7 @@ static void fill_server(MEM_ROOT *mem_root, FEDERATEDX_SERVER *server, database.length(my_casedn_str(system_charset_info, database.c_ptr_safe())); } -#ifndef __WIN__ +#ifndef _WIN32 /* TODO: there is no unix sockets under windows so the engine should be revised about using sockets in such environment. diff --git a/storage/heap/hp_write.c b/storage/heap/hp_write.c index 670f628a2d5..5469784c8c1 100644 --- a/storage/heap/hp_write.c +++ b/storage/heap/hp_write.c @@ -17,7 +17,7 @@ /* Write a record to heap-databas */ #include "heapdef.h" -#ifdef __WIN__ +#ifdef _WIN32 #include #endif diff --git a/storage/innobase/buf/buf0dump.cc b/storage/innobase/buf/buf0dump.cc index eb0b04c55fa..1a95de2b045 100644 --- a/storage/innobase/buf/buf0dump.cc +++ b/storage/innobase/buf/buf0dump.cc @@ -256,7 +256,7 @@ buf_dump( #ifdef _WIN32 /* use my_fopen() for correct permissions during bootstrap*/ f = my_fopen(tmp_filename, O_RDWR|O_TRUNC|O_CREAT, 0); -#elif defined(__GLIBC__) || defined(__WIN__) || O_CLOEXEC == 0 +#elif defined(__GLIBC__) || O_CLOEXEC == 0 f = fopen(tmp_filename, "w" STR_O_CLOEXEC); #else { diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 5f7bef3ae70..53c7eae7c09 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -13294,7 +13294,7 @@ inline int ha_innobase::delete_table(const char* name, enum_sql_command sqlcom) if (is_part) { char par_case_name[FN_REFLEN]; -#ifndef __WIN__ +#ifndef _WIN32 /* Check for the table using lower case name, including the partition separator "P" */ diff --git a/storage/innobase/include/univ.i b/storage/innobase/include/univ.i index 05289c05c86..5bfed89b6d7 100644 --- a/storage/innobase/include/univ.i +++ b/storage/innobase/include/univ.i @@ -487,7 +487,7 @@ it is read or written. */ # define UNIV_PREFETCH_RW(addr) ((void) 0) # endif /* COMPILER_HINTS */ -# elif defined __WIN__ && defined COMPILER_HINTS +# elif defined _WIN32 && defined COMPILER_HINTS # include # define UNIV_EXPECT(expr,value) (expr) # define UNIV_LIKELY_NULL(expr) (expr) diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc index 1ad3cbf7a68..3b365bd86a2 100644 --- a/storage/innobase/row/row0mysql.cc +++ b/storage/innobase/row/row0mysql.cc @@ -3749,11 +3749,11 @@ row_rename_table_for_mysql( /* We look for pattern #P# to see if the table is partitioned MySQL table. */ -#ifdef __WIN__ +#ifdef _WIN32 is_part = strstr((char *)old_name, (char *)"#p#"); #else is_part = strstr((char *)old_name, (char *)"#P#"); -#endif /* __WIN__ */ +#endif /* _WIN32 */ /* MariaDB partition engine hard codes the file name separator as "#P#" and "#SP#". The text case is fixed even if @@ -3773,7 +3773,7 @@ row_rename_table_for_mysql( case them in the system table. */ if (!table && is_part && lower_case_table_names == 1) { char par_case_name[MAX_FULL_NAME_LEN + 1]; -#ifndef __WIN__ +#ifndef _WIN32 /* Check for the table using lower case name, including the partition separator "P" */ diff --git a/storage/maria/aria_chk.c b/storage/maria/aria_chk.c index cd679a1c80f..728b574c98c 100644 --- a/storage/maria/aria_chk.c +++ b/storage/maria/aria_chk.c @@ -505,7 +505,7 @@ static void usage(void) maria_chk very silent.\n\ -t, --tmpdir=path Path for temporary files. Multiple paths can be\n\ specified, separated by "); -#if defined( __WIN__) || defined(__NETWARE__) +#if defined( _WIN32) printf("semicolon (;)"); #else printf("colon (:)"); diff --git a/storage/maria/aria_dump_log.c b/storage/maria/aria_dump_log.c index 8e065e9ff9d..17af368c424 100644 --- a/storage/maria/aria_dump_log.c +++ b/storage/maria/aria_dump_log.c @@ -19,7 +19,7 @@ extern void translog_example_table_init(); static const char *load_default_groups[]= { "aria_dump_log",0 }; static void get_options(int *argc,char * * *argv); #ifndef DBUG_OFF -#if defined(__WIN__) +#if defined(_WIN32) const char *default_dbug_option= "d:t:i:O,\\aria_dump_log.trace"; #else const char *default_dbug_option= "d:t:i:o,/tmp/aria_dump_log.trace"; diff --git a/storage/maria/aria_read_log.c b/storage/maria/aria_read_log.c index 51bfa879702..c0c76ed5590 100644 --- a/storage/maria/aria_read_log.c +++ b/storage/maria/aria_read_log.c @@ -24,7 +24,7 @@ static const char *load_default_groups[]= { "aria_read_log",0 }; static void get_options(int *argc,char * * *argv); #ifndef DBUG_OFF -#if defined(__WIN__) +#if defined(_WIN32) const char *default_dbug_option= "d:t:O,\\aria_read_log.trace"; #else const char *default_dbug_option= "d:t:o,/tmp/aria_read_log.trace"; @@ -273,7 +273,7 @@ static struct my_option my_long_options[] = 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"tmpdir", 't', "Path for temporary files. Multiple paths can be specified, " "separated by " -#if defined( __WIN__) || defined(__NETWARE__) +#if defined( _WIN32) "semicolon (;)" #else "colon (:)" diff --git a/storage/maria/ma_control_file.c b/storage/maria/ma_control_file.c index 65b8b0922aa..d71f92c2eac 100644 --- a/storage/maria/ma_control_file.c +++ b/storage/maria/ma_control_file.c @@ -226,7 +226,7 @@ static int lock_control_file(const char *name, my_bool do_retry) @todo BUG We should explore my_sopen(_SH_DENYWRD) to open or create the file under Windows. */ -#ifndef __WIN__ +#ifndef _WIN32 uint retry= 0; uint retry_count= do_retry ? MARIA_MAX_CONTROL_FILE_LOCK_RETRY : 0; @@ -581,7 +581,7 @@ int ma_control_file_end(void) if (control_file_fd < 0) /* already closed */ DBUG_RETURN(0); -#ifndef __WIN__ +#ifndef _WIN32 (void) my_lock(control_file_fd, F_UNLCK, 0L, F_TO_EOF, MYF(MY_SEEK_NOT_DONE | MY_FORCE_LOCK)); #endif diff --git a/storage/maria/ma_create.c b/storage/maria/ma_create.c index a7ade46f8a4..df189c61043 100644 --- a/storage/maria/ma_create.c +++ b/storage/maria/ma_create.c @@ -23,12 +23,8 @@ #include "trnman.h" #include "ma_crypt.h" -#if defined(MSDOS) || defined(__WIN__) -#ifdef __WIN__ +#ifdef _WIN32 #include -#else -#include /* Prototype for getpid */ -#endif #endif #include diff --git a/storage/maria/ma_info.c b/storage/maria/ma_info.c index f0b04e020c2..f31113d8384 100644 --- a/storage/maria/ma_info.c +++ b/storage/maria/ma_info.c @@ -16,7 +16,7 @@ /* Return useful base information for an open table */ #include "maria_def.h" -#ifdef __WIN__ +#ifdef _WIN32 #include #endif diff --git a/storage/maria/ma_locking.c b/storage/maria/ma_locking.c index 200a728626f..d8f815b2a50 100644 --- a/storage/maria/ma_locking.c +++ b/storage/maria/ma_locking.c @@ -220,7 +220,7 @@ int maria_lock_database(MARIA_HA *info, int lock_type) break; /* Impossible */ } } -#ifdef __WIN__ +#ifdef _WIN32 else { /* @@ -320,7 +320,7 @@ int _ma_writeinfo(register MARIA_HA *info, uint operation) &share->state, MA_STATE_INFO_WRITE_DONT_MOVE_OFFSET))) olderror=my_errno; -#ifdef __WIN__ +#ifdef _WIN32 if (maria_flush) { _commit(share->kfile.file); diff --git a/storage/maria/ma_loghandler.c b/storage/maria/ma_loghandler.c index e2956d7ca3c..11bdd68fc03 100644 --- a/storage/maria/ma_loghandler.c +++ b/storage/maria/ma_loghandler.c @@ -29,7 +29,7 @@ Also there is no need to flush filesystem changes ,i.e to sync() directories. */ -#ifdef __WIN__ +#ifdef _WIN32 #define sync_dir(A,B) 0 #else #define sync_dir(A,B) mysql_file_sync(A,B) @@ -3673,7 +3673,7 @@ my_bool translog_init_with_table(const char *directory, /* Directory to store files */ unpack_dirname(log_descriptor.directory, directory); -#ifndef __WIN__ +#ifndef _WIN32 if ((log_descriptor.directory_fd= my_open(log_descriptor.directory, O_RDONLY, MYF(MY_WME))) < 0) { diff --git a/storage/maria/ma_open.c b/storage/maria/ma_open.c index 49fd0dcc7af..f84f0b8e938 100644 --- a/storage/maria/ma_open.c +++ b/storage/maria/ma_open.c @@ -26,12 +26,8 @@ #include "ma_crypt.h" #include "s3_func.h" -#if defined(MSDOS) || defined(__WIN__) -#ifdef __WIN__ +#ifdef _WIN32 #include -#else -#include /* Prototype for getpid */ -#endif #endif static void setup_key_functions(MARIA_KEYDEF *keyinfo); diff --git a/storage/maria/ma_pagecache.c b/storage/maria/ma_pagecache.c index bf646115bd9..986cacddf0c 100644 --- a/storage/maria/ma_pagecache.c +++ b/storage/maria/ma_pagecache.c @@ -589,7 +589,7 @@ static my_thread_id pagecache_thread_id; ((uint) (((char*)(h)-(char *) p->hash_link_root)/ \ sizeof(PAGECACHE_HASH_LINK))) -#if (defined(PAGECACHE_TIMEOUT) && !defined(__WIN__)) || defined(PAGECACHE_DEBUG) +#if (defined(PAGECACHE_TIMEOUT) && !defined(_WIN32)) || defined(PAGECACHE_DEBUG) static int pagecache_pthread_cond_wait(mysql_cond_t *cond, mysql_mutex_t *mutex); #else @@ -5561,7 +5561,7 @@ static void pagecache_dump(PAGECACHE *pagecache) #endif /* defined(PAGECACHE_TIMEOUT) */ -#if defined(PAGECACHE_TIMEOUT) && !defined(__WIN__) +#if defined(PAGECACHE_TIMEOUT) && !defined(_WIN32) static int pagecache_pthread_cond_wait(mysql_cond_t *cond, @@ -5623,7 +5623,7 @@ static int pagecache_pthread_cond_wait(mysql_cond_t *cond, return rc; } #endif -#endif /* defined(PAGECACHE_TIMEOUT) && !defined(__WIN__) */ +#endif /* defined(PAGECACHE_TIMEOUT) && !defined(_WIN32) */ #if defined(PAGECACHE_DEBUG) diff --git a/storage/maria/ma_sort.c b/storage/maria/ma_sort.c index 8153ec701a0..b9d6fffda86 100644 --- a/storage/maria/ma_sort.c +++ b/storage/maria/ma_sort.c @@ -20,7 +20,7 @@ #include "ma_fulltext.h" #include -#if defined(MSDOS) || defined(__WIN__) +#if defined(_WIN32) #include #else #include diff --git a/storage/maria/unittest/ma_pagecache_consist.c b/storage/maria/unittest/ma_pagecache_consist.c index 29fa29ca035..ff4a2bcb33a 100644 --- a/storage/maria/unittest/ma_pagecache_consist.c +++ b/storage/maria/unittest/ma_pagecache_consist.c @@ -339,7 +339,7 @@ int main(int argc __attribute__((unused)), MY_INIT(argv[0]); #ifndef DBUG_OFF -#if defined(__WIN__) +#if defined(_WIN32) default_dbug_option= "d:t:i:O,\\test_pagecache_consist.trace"; #else default_dbug_option= "d:t:i:o,/tmp/test_pagecache_consist.trace"; diff --git a/storage/maria/unittest/ma_pagecache_rwconsist.c b/storage/maria/unittest/ma_pagecache_rwconsist.c index a3303eb65a4..24c30245bac 100644 --- a/storage/maria/unittest/ma_pagecache_rwconsist.c +++ b/storage/maria/unittest/ma_pagecache_rwconsist.c @@ -210,7 +210,7 @@ int main(int argc __attribute__((unused)), MY_INIT(argv[0]); #ifndef DBUG_OFF -#if defined(__WIN__) +#if defined(_WIN32) default_dbug_option= "d:t:i:O,\\test_pagecache_consist.trace"; #else default_dbug_option= "d:t:i:O,/tmp/test_pagecache_consist.trace"; diff --git a/storage/maria/unittest/ma_pagecache_rwconsist2.c b/storage/maria/unittest/ma_pagecache_rwconsist2.c index 2a0f76b478f..c92bec3ca41 100644 --- a/storage/maria/unittest/ma_pagecache_rwconsist2.c +++ b/storage/maria/unittest/ma_pagecache_rwconsist2.c @@ -206,7 +206,7 @@ int main(int argc __attribute__((unused)), MY_INIT(argv[0]); #ifndef DBUG_OFF -#if defined(__WIN__) +#if defined(_WIN32) default_dbug_option= "d:t:i:O,\\test_pagecache_consist.trace"; #else default_dbug_option= "d:t:i:O,/tmp/test_pagecache_consist.trace"; diff --git a/storage/maria/unittest/ma_pagecache_single.c b/storage/maria/unittest/ma_pagecache_single.c index 4cd62c52d86..c4e2c53d235 100644 --- a/storage/maria/unittest/ma_pagecache_single.c +++ b/storage/maria/unittest/ma_pagecache_single.c @@ -730,7 +730,7 @@ int main(int argc __attribute__((unused)), MY_INIT(argv[0]); #ifndef DBUG_OFF -#if defined(__WIN__) +#if defined(_WIN32) default_dbug_option= "d:t:i:O,\\test_pagecache_single.trace"; #else default_dbug_option= "d:t:i:o,/tmp/test_pagecache_single.trace"; diff --git a/storage/maria/unittest/ma_test_loghandler-t.c b/storage/maria/unittest/ma_test_loghandler-t.c index 198ea5b2afb..ccda66af755 100644 --- a/storage/maria/unittest/ma_test_loghandler-t.c +++ b/storage/maria/unittest/ma_test_loghandler-t.c @@ -185,7 +185,7 @@ int main(int argc __attribute__((unused)), char *argv[]) bzero(long_tr_id, 6); #ifndef DBUG_OFF -#if defined(__WIN__) +#if defined(_WIN32) default_dbug_option= "d:t:i:O,\\ma_test_loghandler.trace"; #else default_dbug_option= "d:t:i:o,/tmp/ma_test_loghandler.trace"; diff --git a/storage/maria/unittest/ma_test_loghandler_first_lsn-t.c b/storage/maria/unittest/ma_test_loghandler_first_lsn-t.c index 8806571cabf..21f6b7d7b44 100644 --- a/storage/maria/unittest/ma_test_loghandler_first_lsn-t.c +++ b/storage/maria/unittest/ma_test_loghandler_first_lsn-t.c @@ -54,7 +54,7 @@ int main(int argc __attribute__((unused)), char *argv[]) bzero(long_tr_id, 6); #ifndef DBUG_OFF -#if defined(__WIN__) +#if defined(_WIN32) default_dbug_option= "d:t:i:O,\\ma_test_loghandler.trace"; #else default_dbug_option= "d:t:i:o,/tmp/ma_test_loghandler.trace"; diff --git a/storage/maria/unittest/ma_test_loghandler_max_lsn-t.c b/storage/maria/unittest/ma_test_loghandler_max_lsn-t.c index 65b926376ae..391d785159a 100644 --- a/storage/maria/unittest/ma_test_loghandler_max_lsn-t.c +++ b/storage/maria/unittest/ma_test_loghandler_max_lsn-t.c @@ -52,7 +52,7 @@ int main(int argc __attribute__((unused)), char *argv[]) bzero(long_tr_id, 6); #ifndef DBUG_OFF -#if defined(__WIN__) +#if defined(_WIN32) default_dbug_option= "d:t:i:O,\\ma_test_loghandler.trace"; #else default_dbug_option= "d:t:i:o,/tmp/ma_test_loghandler.trace"; diff --git a/storage/maria/unittest/ma_test_loghandler_multithread-t.c b/storage/maria/unittest/ma_test_loghandler_multithread-t.c index cb4d2bc70ba..ec097ede036 100644 --- a/storage/maria/unittest/ma_test_loghandler_multithread-t.c +++ b/storage/maria/unittest/ma_test_loghandler_multithread-t.c @@ -292,7 +292,7 @@ int main(int argc __attribute__((unused)), long_buffer[i]= (i & 0xFF); #ifndef DBUG_OFF -#if defined(__WIN__) +#if defined(_WIN32) default_dbug_option= "d:t:i:O,\\ma_test_loghandler.trace"; #else default_dbug_option= "d:t:i:o,/tmp/ma_test_loghandler.trace"; diff --git a/storage/maria/unittest/ma_test_loghandler_noflush-t.c b/storage/maria/unittest/ma_test_loghandler_noflush-t.c index 3aafe5db9b4..46b3a8e71aa 100644 --- a/storage/maria/unittest/ma_test_loghandler_noflush-t.c +++ b/storage/maria/unittest/ma_test_loghandler_noflush-t.c @@ -53,7 +53,7 @@ int main(int argc __attribute__((unused)), char *argv[]) bzero(long_tr_id, 6); #ifndef DBUG_OFF -#if defined(__WIN__) +#if defined(_WIN32) default_dbug_option= "d:t:i:O,\\ma_test_loghandler.trace"; #else default_dbug_option= "d:t:i:o,/tmp/ma_test_loghandler.trace"; diff --git a/storage/maria/unittest/ma_test_loghandler_nologs-t.c b/storage/maria/unittest/ma_test_loghandler_nologs-t.c index 913bd4ef5b6..b95d8bee24c 100644 --- a/storage/maria/unittest/ma_test_loghandler_nologs-t.c +++ b/storage/maria/unittest/ma_test_loghandler_nologs-t.c @@ -54,7 +54,7 @@ int main(int argc __attribute__((unused)), char *argv[]) bzero(long_tr_id, 6); #ifndef DBUG_OFF -#if defined(__WIN__) +#if defined(_WIN32) default_dbug_option= "d:t:i:O,\\ma_test_loghandler.trace"; #else default_dbug_option= "d:t:i:o,/tmp/ma_test_loghandler.trace"; diff --git a/storage/maria/unittest/ma_test_loghandler_pagecache-t.c b/storage/maria/unittest/ma_test_loghandler_pagecache-t.c index f09a78e5fa8..892a773b475 100644 --- a/storage/maria/unittest/ma_test_loghandler_pagecache-t.c +++ b/storage/maria/unittest/ma_test_loghandler_pagecache-t.c @@ -57,7 +57,7 @@ int main(int argc __attribute__((unused)), char *argv[]) bzero(long_tr_id, 6); #ifndef DBUG_OFF -#if defined(__WIN__) +#if defined(_WIN32) default_dbug_option= "d:t:i:O,\\ma_test_loghandler_pagecache.trace"; #else default_dbug_option= "d:t:i:o,/tmp/ma_test_loghandler_pagecache.trace"; diff --git a/storage/maria/unittest/ma_test_loghandler_purge-t.c b/storage/maria/unittest/ma_test_loghandler_purge-t.c index e1eeca2fc9b..07b50f197de 100644 --- a/storage/maria/unittest/ma_test_loghandler_purge-t.c +++ b/storage/maria/unittest/ma_test_loghandler_purge-t.c @@ -55,7 +55,7 @@ int main(int argc __attribute__((unused)), char *argv[]) bzero(long_tr_id, 6); #ifndef DBUG_OFF -#if defined(__WIN__) +#if defined(_WIN32) default_dbug_option= "d:t:i:O,\\ma_test_loghandler.trace"; #else default_dbug_option= "d:t:i:o,/tmp/ma_test_loghandler.trace"; diff --git a/storage/maria/unittest/test_file.c b/storage/maria/unittest/test_file.c index 8c9a5f66a2f..853f5352fca 100644 --- a/storage/maria/unittest/test_file.c +++ b/storage/maria/unittest/test_file.c @@ -44,7 +44,7 @@ int test_file(PAGECACHE_FILE file, char *file_name, int step= 0; int res= 1; /* ok */ -#ifdef __WIN__ +#ifdef _WIN32 /* On Windows, the info returned by stat(), specifically file length is not necessarily current, because this is the behavior of diff --git a/storage/myisam/mi_create.c b/storage/myisam/mi_create.c index 51354e0e8b5..140d8abe26f 100644 --- a/storage/myisam/mi_create.c +++ b/storage/myisam/mi_create.c @@ -21,7 +21,7 @@ #include "sp_defs.h" #include -#ifdef __WIN__ +#ifdef _WIN32 #include #endif #include diff --git a/storage/myisam/mi_extra.c b/storage/myisam/mi_extra.c index 67cb714e7bf..4f3326098f6 100644 --- a/storage/myisam/mi_extra.c +++ b/storage/myisam/mi_extra.c @@ -279,51 +279,6 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) mi_print_error(info->s, HA_ERR_CRASHED); mi_mark_crashed(info); /* Fatal error found */ } -#ifdef __WIN__REMOVE_OBSOLETE_WORKAROUND - /* Close the isam and data files as Win32 can't drop an open table */ - if (info->opt_flag & (READ_CACHE_USED | WRITE_CACHE_USED)) - { - info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED); - error=end_io_cache(&info->rec_cache); - } - if (info->lock_type != F_UNLCK && ! info->was_locked) - { - info->was_locked=info->lock_type; - if (mi_lock_database(info,F_UNLCK)) - error=my_errno; - info->lock_type = F_UNLCK; - } - if (share->kfile >= 0) - { - /* - We don't need to call _mi_decrement_open_count() if we are - dropping the table, as the files will be removed anyway. If we - are aborted before the files is removed, it's better to not - call it as in that case the automatic repair on open will add - the missing index entries - */ - if (function != HA_EXTRA_PREPARE_FOR_DROP) - _mi_decrement_open_count(info); - if (mysql_file_close(share->kfile,MYF(0))) - error=my_errno; - } - { - LIST *list_element ; - for (list_element=myisam_open_list ; - list_element ; - list_element=list_element->next) - { - MI_INFO *tmpinfo=(MI_INFO*) list_element->data; - if (tmpinfo->s == info->s) - { - if (tmpinfo->dfile >= 0 && mysql_file_close(tmpinfo->dfile, MYF(0))) - error = my_errno; - tmpinfo->dfile= -1; - } - } - } - share->kfile= -1; /* Files aren't open anymore */ -#endif mysql_mutex_unlock(&share->intern_lock); mysql_mutex_unlock(&THR_LOCK_myisam); break; diff --git a/storage/myisam/mi_info.c b/storage/myisam/mi_info.c index 50cb5439472..9e1a5e416de 100644 --- a/storage/myisam/mi_info.c +++ b/storage/myisam/mi_info.c @@ -17,7 +17,7 @@ /* Return useful base information for an open table */ #include "myisamdef.h" -#ifdef __WIN__ +#ifdef _WIN32 #include #endif diff --git a/storage/myisam/mi_log.c b/storage/myisam/mi_log.c index 9b8405d0a9c..bc9607fb342 100644 --- a/storage/myisam/mi_log.c +++ b/storage/myisam/mi_log.c @@ -19,7 +19,7 @@ */ #include "myisamdef.h" -#ifdef __WIN__ +#ifdef _WIN32 #include #endif diff --git a/storage/myisam/mi_open.c b/storage/myisam/mi_open.c index 3db424ea997..b80c2b69f16 100644 --- a/storage/myisam/mi_open.c +++ b/storage/myisam/mi_open.c @@ -33,7 +33,7 @@ #include #include -#ifdef __WIN__ +#ifdef _WIN32 #include #endif diff --git a/storage/myisam/myisamchk.c b/storage/myisam/myisamchk.c index 18b729a3d6f..a5777527e54 100644 --- a/storage/myisam/myisamchk.c +++ b/storage/myisam/myisamchk.c @@ -356,7 +356,7 @@ static void usage(void) -?, --help Display this help and exit.\n\ -t, --tmpdir=path Path for temporary files. Multiple paths can be\n\ specified, separated by "); -#if defined( __WIN__) +#if defined( _WIN32) printf("semicolon (;)"); #else printf("colon (:)"); diff --git a/storage/myisam/sort.c b/storage/myisam/sort.c index 6fe38a3fd04..fe0c0f8f02e 100644 --- a/storage/myisam/sort.c +++ b/storage/myisam/sort.c @@ -19,7 +19,7 @@ */ #include "fulltext.h" -#if defined(__WIN__) +#if defined(_WIN32) #include #else #include diff --git a/storage/rocksdb/ut0counter.h b/storage/rocksdb/ut0counter.h index 3a7ee85d01c..7b1885810c3 100644 --- a/storage/rocksdb/ut0counter.h +++ b/storage/rocksdb/ut0counter.h @@ -28,7 +28,7 @@ Created 2012/04/12 by Sunny Bains /** Default number of slots to use in ib_counter_t */ #define IB_N_SLOTS 64 -#ifdef __WIN__ +#ifdef _WIN32 #define get_curr_thread_id() GetCurrentThreadId() #else #define get_curr_thread_id() pthread_self() diff --git a/storage/sphinx/ha_sphinx.cc b/storage/sphinx/ha_sphinx.cc index e2f1909e8e2..3c5b23f559f 100644 --- a/storage/sphinx/ha_sphinx.cc +++ b/storage/sphinx/ha_sphinx.cc @@ -39,7 +39,7 @@ #include #include // include client for INSERT table (sort of redoing federated..) -#ifndef __WIN__ +#ifndef _WIN32 // UNIX-specific #include #include @@ -959,7 +959,7 @@ static char * sphDup ( const char * sSrc, int iLen=-1 ) static void sphLogError ( const char * sFmt, ... ) { // emit timestamp -#ifdef __WIN__ +#ifdef _WIN32 SYSTEMTIME t; GetLocalTime ( &t ); @@ -983,7 +983,7 @@ static void sphLogError ( const char * sFmt, ... ) fprintf ( stderr, "%02d%02d%02d %2d:%02d:%02d SphinxSE: internal error: ", pParsed->tm_year % 100, pParsed->tm_mon + 1, pParsed->tm_mday, pParsed->tm_hour, pParsed->tm_min, pParsed->tm_sec); -#endif // __WIN__ +#endif // _WIN32 // emit message va_list ap; @@ -1194,7 +1194,7 @@ static CSphSEShare * get_share ( const char * table_name, TABLE * table ) #if MYSQL_VERSION_ID>=50120 pShare = (CSphSEShare*) sphinx_hash_search ( &sphinx_open_tables, (const uchar *) table_name, strlen(table_name) ); #else -#ifdef __WIN__ +#ifdef _WIN32 pShare = (CSphSEShare*) sphinx_hash_search ( &sphinx_open_tables, (const byte *) table_name, strlen(table_name) ); #else pShare = (CSphSEShare*) sphinx_hash_search ( &sphinx_open_tables, table_name, strlen(table_name) ); @@ -2128,7 +2128,7 @@ int ha_sphinx::open ( const char * name, int, uint ) int ha_sphinx::Connect ( const char * sHost, ushort uPort ) { struct sockaddr_in sin; -#ifndef __WIN__ +#ifndef _WIN32 struct sockaddr_un saun; #endif @@ -2197,7 +2197,7 @@ int ha_sphinx::Connect ( const char * sHost, ushort uPort ) } } else { -#ifndef __WIN__ +#ifndef _WIN32 iDomain = AF_UNIX; iSockaddrSize = sizeof(saun); pSockaddr = (struct sockaddr *) &saun; diff --git a/storage/sphinx/snippets_udf.cc b/storage/sphinx/snippets_udf.cc index ab2764407d8..8b87d9dce04 100644 --- a/storage/sphinx/snippets_udf.cc +++ b/storage/sphinx/snippets_udf.cc @@ -17,7 +17,7 @@ #include #include -#ifndef __WIN__ +#ifndef _WIN32 #include #include #else @@ -91,7 +91,7 @@ void sphUnalignedWrite ( void * pPtr, const T & tVal ) #define SafeDeleteArray(_arg) { if ( _arg ) delete [] ( _arg ); (_arg) = NULL; } #define Min(a,b) ((a)<(b)?(a):(b)) -#ifndef __WIN__ +#ifndef _WIN32 typedef unsigned int DWORD; #endif inline DWORD sphF2DW ( float f ) { union { float f; uint32 d; } u; u.f = f; return u.d; } @@ -361,7 +361,7 @@ bool CSphUrl::Parse ( const char * sUrl, int iLen ) int CSphUrl::Connect() { struct sockaddr_in sin; -#ifndef __WIN__ +#ifndef _WIN32 struct sockaddr_un saun; #endif @@ -428,7 +428,7 @@ int CSphUrl::Connect() } } else { -#ifndef __WIN__ +#ifndef _WIN32 iDomain = AF_UNIX; iSockaddrSize = sizeof(saun); pSockaddr = (struct sockaddr *) &saun; diff --git a/storage/spider/hs_client/auto_addrinfo.hpp b/storage/spider/hs_client/auto_addrinfo.hpp index 5262ad11d4a..26e5dee933e 100644 --- a/storage/spider/hs_client/auto_addrinfo.hpp +++ b/storage/spider/hs_client/auto_addrinfo.hpp @@ -9,7 +9,7 @@ #ifndef DENA_AUTO_ADDRINFO_HPP #define DENA_AUTO_ADDRINFO_HPP -#ifndef __WIN__ +#ifndef _WIN32 #include #endif diff --git a/storage/spider/hs_client/auto_file.hpp b/storage/spider/hs_client/auto_file.hpp index ddd1f8c9196..44903f5fc4a 100644 --- a/storage/spider/hs_client/auto_file.hpp +++ b/storage/spider/hs_client/auto_file.hpp @@ -10,7 +10,7 @@ #define DENA_AUTO_FILE_HPP /* -#ifndef __WIN__ +#ifndef _WIN32 #include #endif */ diff --git a/storage/spider/hs_client/socket.cpp b/storage/spider/hs_client/socket.cpp index e4541ce7273..9a2ecddedd7 100644 --- a/storage/spider/hs_client/socket.cpp +++ b/storage/spider/hs_client/socket.cpp @@ -9,7 +9,7 @@ #include #include -#ifndef __WIN__ +#ifndef _WIN32 #include #include #endif @@ -43,7 +43,7 @@ namespace dena { void ignore_sigpipe() { -#if defined(SIGPIPE) && !defined(__WIN__) +#if defined(SIGPIPE) && !defined(_WIN32) if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) { fatal_abort("SIGPIPE SIG_IGN"); } @@ -80,7 +80,7 @@ socket_args::set(const config& conf) void socket_args::set_unix_domain(const char *path) { -#ifndef __WIN__ +#ifndef _WIN32 family = AF_UNIX; addr = sockaddr_storage(); addrlen = sizeof(sockaddr_un); @@ -112,7 +112,7 @@ socket_set_timeout(auto_file& fd, const socket_args& args, String& err_r) if (!args.nonblocking) { #if defined(SO_SNDTIMEO) && defined(SO_RCVTIMEO) if (args.recv_timeout != 0) { -#ifndef __WIN__ +#ifndef _WIN32 struct timeval tv; tv.tv_sec = args.recv_timeout; tv.tv_usec = 0; @@ -120,7 +120,7 @@ socket_set_timeout(auto_file& fd, const socket_args& args, String& err_r) int tv = args.recv_timeout * 1000; #endif if (setsockopt(fd.get(), SOL_SOCKET, SO_RCVTIMEO, -#ifndef __WIN__ +#ifndef _WIN32 (const void *) &tv, #else (const char *) &tv, @@ -130,7 +130,7 @@ socket_set_timeout(auto_file& fd, const socket_args& args, String& err_r) } } if (args.send_timeout != 0) { -#ifndef __WIN__ +#ifndef _WIN32 struct timeval tv; tv.tv_sec = args.send_timeout; tv.tv_usec = 0; @@ -138,7 +138,7 @@ socket_set_timeout(auto_file& fd, const socket_args& args, String& err_r) int tv = args.send_timeout * 1000; #endif if (setsockopt(fd.get(), SOL_SOCKET, SO_SNDTIMEO, -#ifndef __WIN__ +#ifndef _WIN32 (const void *) &tv, #else (const char *) &tv, @@ -157,7 +157,7 @@ socket_set_options(auto_file& fd, const socket_args& args, String& err_r) { if (args.timeout != 0 && !args.nonblocking) { #if defined(SO_SNDTIMEO) && defined(SO_RCVTIMEO) -#ifndef __WIN__ +#ifndef _WIN32 struct timeval tv; tv.tv_sec = args.timeout; tv.tv_usec = 0; @@ -165,7 +165,7 @@ socket_set_options(auto_file& fd, const socket_args& args, String& err_r) int tv = args.timeout * 1000; #endif if (setsockopt(fd.get(), SOL_SOCKET, SO_RCVTIMEO, -#ifndef __WIN__ +#ifndef _WIN32 (const void *) &tv, #else (const char *) &tv, @@ -173,14 +173,14 @@ socket_set_options(auto_file& fd, const socket_args& args, String& err_r) sizeof(tv)) != 0) { return errno_string("setsockopt SO_RCVTIMEO", errno, err_r); } -#ifndef __WIN__ +#ifndef _WIN32 tv.tv_sec = args.timeout; tv.tv_usec = 0; #else tv = args.timeout * 1000; #endif if (setsockopt(fd.get(), SOL_SOCKET, SO_SNDTIMEO, -#ifndef __WIN__ +#ifndef _WIN32 (const void *) &tv, #else (const char *) &tv, @@ -190,7 +190,7 @@ socket_set_options(auto_file& fd, const socket_args& args, String& err_r) } #endif } -#ifndef __WIN__ +#ifndef _WIN32 if (args.nonblocking && fcntl(fd.get(), F_SETFL, O_NONBLOCK) != 0) { return errno_string("fcntl O_NONBLOCK", errno, err_r); } @@ -198,7 +198,7 @@ socket_set_options(auto_file& fd, const socket_args& args, String& err_r) if (args.sndbuf != 0) { const int v = args.sndbuf; if (setsockopt(fd.get(), SOL_SOCKET, SO_SNDBUF, -#ifndef __WIN__ +#ifndef _WIN32 (const void *) &v, #else (const char *) &v, @@ -210,7 +210,7 @@ socket_set_options(auto_file& fd, const socket_args& args, String& err_r) if (args.rcvbuf != 0) { const int v = args.rcvbuf; if (setsockopt(fd.get(), SOL_SOCKET, SO_RCVBUF, -#ifndef __WIN__ +#ifndef _WIN32 (const void *) &v, #else (const char *) &v, @@ -242,7 +242,7 @@ socket_connect(auto_file& fd, const socket_args& args, String& err_r) if (connect(fd.get(), reinterpret_cast(&args.addr), args.addrlen) != 0) { if (!args.nonblocking -#ifndef __WIN__ +#ifndef _WIN32 || errno != EINPROGRESS #endif ) { @@ -260,7 +260,7 @@ socket_bind(auto_file& fd, const socket_args& args, String& err_r) return errno_string("socket", errno, err_r); } if (args.reuseaddr) { -#ifndef __WIN__ +#ifndef _WIN32 if (args.family == AF_UNIX) { const sockaddr_un *const ap = reinterpret_cast(&args.addr); @@ -271,7 +271,7 @@ socket_bind(auto_file& fd, const socket_args& args, String& err_r) #endif int v = 1; if (setsockopt(fd.get(), SOL_SOCKET, SO_REUSEADDR, -#ifndef __WIN__ +#ifndef _WIN32 (const void *) &v, #else (const char *) &v, @@ -279,7 +279,7 @@ socket_bind(auto_file& fd, const socket_args& args, String& err_r) sizeof(v)) != 0) { return errno_string("setsockopt SO_REUSEADDR", errno, err_r); } -#ifndef __WIN__ +#ifndef _WIN32 } #endif } @@ -290,7 +290,7 @@ socket_bind(auto_file& fd, const socket_args& args, String& err_r) if (listen(fd.get(), args.listen_backlog) != 0) { return errno_string("listen", errno, err_r); } -#ifndef __WIN__ +#ifndef _WIN32 if (args.nonblocking && fcntl(fd.get(), F_SETFL, O_NONBLOCK) != 0) { return errno_string("fcntl O_NONBLOCK", errno, err_r); } diff --git a/strings/my_vsnprintf.c b/strings/my_vsnprintf.c index aefca1fb3ee..8417e07a6b0 100644 --- a/strings/my_vsnprintf.c +++ b/strings/my_vsnprintf.c @@ -933,7 +933,7 @@ const char* my_strerror(char *buf, size_t len, int nr) this choice is not advertised, use the default (POSIX/XSI). Testing for __GNUC__ is not sufficient to determine whether this choice exists. */ -#if defined(__WIN__) +#if defined(_WIN32) strerror_s(buf, len, nr); #elif ((defined _POSIX_C_SOURCE && (_POSIX_C_SOURCE >= 200112L)) || \ (defined _XOPEN_SOURCE && (_XOPEN_SOURCE >= 600))) && \ diff --git a/tests/list_test.c b/tests/list_test.c index 42d4f962b19..6c915d470b7 100644 --- a/tests/list_test.c +++ b/tests/list_test.c @@ -14,7 +14,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ -#ifdef __WIN__ +#ifdef _WIN32 #include #endif #include diff --git a/tests/nonblock-wrappers.h b/tests/nonblock-wrappers.h index 78851854442..19737c8d04a 100644 --- a/tests/nonblock-wrappers.h +++ b/tests/nonblock-wrappers.h @@ -22,7 +22,7 @@ Used to test the non-blocking calls using mysql_client_test. */ -#ifndef __WIN__ +#ifndef _WIN32 #include #else #include @@ -35,7 +35,7 @@ static int wait_for_mysql(MYSQL *mysql, int status) { -#ifdef __WIN__ +#ifdef _WIN32 fd_set rs, ws, es; int res; struct timeval tv, *timeout; diff --git a/tests/showdb_test.c b/tests/showdb_test.c index 267e32d51d7..e6b8989e36c 100644 --- a/tests/showdb_test.c +++ b/tests/showdb_test.c @@ -15,7 +15,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ -#ifdef __WIN__ +#ifdef _WIN32 #include #endif #include diff --git a/tests/ssl_test.c b/tests/ssl_test.c index 6102fc7fd4e..d15d553b67a 100644 --- a/tests/ssl_test.c +++ b/tests/ssl_test.c @@ -15,7 +15,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ -#ifdef __WIN__ +#ifdef _WIN32 #include #endif #include diff --git a/tests/thread_test.c b/tests/thread_test.c index 0fa92d505a3..a40b4d20870 100644 --- a/tests/thread_test.c +++ b/tests/thread_test.c @@ -28,7 +28,7 @@ static pthread_mutex_t LOCK_thread_count; static char *database,*host,*user,*password,*unix_socket,*query; uint tcp_port; -#ifndef __WIN__ +#ifndef _WIN32 void *test_thread(void *arg __attribute__((unused))) #else unsigned __stdcall test_thread(void *arg __attribute__((unused))) diff --git a/unittest/mytap/tap.c b/unittest/mytap/tap.c index 65608e0de05..86edea11411 100644 --- a/unittest/mytap/tap.c +++ b/unittest/mytap/tap.c @@ -345,7 +345,7 @@ int exit_status() return EXIT_SUCCESS; } -#if defined(__WIN__) || defined(__NETWARE__) +#if defined(_WIN32) #include #else #include @@ -357,7 +357,7 @@ int exit_status() static ulong start_timer(void) { -#if defined(__WIN__) || defined(__NETWARE__) +#if defined(_WIN32) return clock(); #else struct tms tms_tmp; diff --git a/vio/viosocket.c b/vio/viosocket.c index f84d0e0738b..f63c76c9c79 100644 --- a/vio/viosocket.c +++ b/vio/viosocket.c @@ -25,7 +25,7 @@ */ #include "vio_priv.h" -#ifdef __WIN__ +#ifdef _WIN32 #include #include #include @@ -300,7 +300,7 @@ int vio_socket_shutdown(Vio *vio, int how) int vio_blocking(Vio *vio, my_bool set_blocking_mode, my_bool *old_mode) { int r= 0; -#if defined(__WIN__) || !defined(NO_FCNTL_NONBLOCK) +#if defined(_WIN32) || !defined(NO_FCNTL_NONBLOCK) my_socket sd= mysql_socket_getfd(vio->mysql_socket); #endif DBUG_ENTER("vio_blocking"); @@ -309,7 +309,7 @@ int vio_blocking(Vio *vio, my_bool set_blocking_mode, my_bool *old_mode) DBUG_PRINT("enter", ("set_blocking_mode: %d old_mode: %d", (int) set_blocking_mode, (int) *old_mode)); -#if !defined(__WIN__) +#if !defined(_WIN32) #if !defined(NO_FCNTL_NONBLOCK) if (sd >= 0) { @@ -331,7 +331,7 @@ int vio_blocking(Vio *vio, my_bool set_blocking_mode, my_bool *old_mode) #else r= set_blocking_mode ? 0 : 1; #endif /* !defined(NO_FCNTL_NONBLOCK) */ -#else /* !defined(__WIN__) */ +#else /* !defined(_WIN32) */ if (vio->type != VIO_TYPE_NAMEDPIPE) { ulong arg; @@ -351,7 +351,7 @@ int vio_blocking(Vio *vio, my_bool set_blocking_mode, my_bool *old_mode) } else r= MY_TEST(!(vio->fcntl_mode & O_NONBLOCK)) != set_blocking_mode; -#endif /* !defined(__WIN__) */ +#endif /* !defined(_WIN32) */ DBUG_PRINT("exit", ("%d", r)); DBUG_RETURN(r); } From f456e716feac2fe9a2b1eb5247128c271e1a4e83 Mon Sep 17 00:00:00 2001 From: Monty Date: Wed, 2 Jun 2021 18:29:30 +0300 Subject: [PATCH 016/251] Make maria.repair more resiliant for different failures This is because on different compilation and server configurations the memory usage is different and the query can get killed in different places with different error messages as a result. Reviewer: None (trival change) --- mysql-test/suite/maria/repair.result | 7 ------- mysql-test/suite/maria/repair.test | 2 ++ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/mysql-test/suite/maria/repair.result b/mysql-test/suite/maria/repair.result index 296f251aa36..722d9f28712 100644 --- a/mysql-test/suite/maria/repair.result +++ b/mysql-test/suite/maria/repair.result @@ -29,12 +29,5 @@ CREATE TABLE t1 (i INT) ENGINE=Aria; INSERT INTO t1 VALUES (1); SET max_session_mem_used=50000; REPAIR LOCAL TABLE t1 USE_FRM; -Table Op Msg_type Msg_text -t1 repair error Failed to open partially repaired table -Warnings: -Error 1290 The MariaDB server is running with the --max-thread-mem-used=50000 option so it cannot execute this statement REPAIR LOCAL TABLE t1; -Table Op Msg_type Msg_text -test.t1 repair Error The MariaDB server is running with the --max-thread-mem-used=50000 option so it cannot execute this statement -test.t1 repair error Corrupt DROP TABLE t1; diff --git a/mysql-test/suite/maria/repair.test b/mysql-test/suite/maria/repair.test index 13165269b76..571f861c512 100644 --- a/mysql-test/suite/maria/repair.test +++ b/mysql-test/suite/maria/repair.test @@ -36,6 +36,8 @@ DROP TABLE t1; CREATE TABLE t1 (i INT) ENGINE=Aria; INSERT INTO t1 VALUES (1); SET max_session_mem_used=50000; +--disable_result_log REPAIR LOCAL TABLE t1 USE_FRM; REPAIR LOCAL TABLE t1; +--enable_result_log DROP TABLE t1; From be84f9cea764a8cdfaeeeb04c9147271b36c29ab Mon Sep 17 00:00:00 2001 From: Monty Date: Mon, 7 Jun 2021 13:48:56 +0300 Subject: [PATCH 017/251] Record in test suite that temporary tables only uses write locks --- mysql-test/main/temp_table.result | 12 ++++++++++++ mysql-test/main/temp_table.test | 14 ++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/mysql-test/main/temp_table.result b/mysql-test/main/temp_table.result index 64a5d9b681b..0e443cb71dd 100644 --- a/mysql-test/main/temp_table.result +++ b/mysql-test/main/temp_table.result @@ -619,3 +619,15 @@ ERROR 42S02: Unknown table 'test.t2' # # End of 10.5 tests # +# +# Record that temporary table locks are always WRITE locks +# +CREATE TEMPORARY TABLE t1 (a INT); +LOCK TABLE t1 READ; +TRUNCATE TABLE t1; +TRUNCATE TABLE t1; +UNLOCK TABLES; +DROP TABLE t1; +# +# End of 10.6 tests +# diff --git a/mysql-test/main/temp_table.test b/mysql-test/main/temp_table.test index ccaa5fb93e8..4f1bb3c5568 100644 --- a/mysql-test/main/temp_table.test +++ b/mysql-test/main/temp_table.test @@ -681,3 +681,17 @@ drop temporary table t2; --echo # End of 10.5 tests --echo # +--echo # +--echo # Record that temporary table locks are always WRITE locks +--echo # + +CREATE TEMPORARY TABLE t1 (a INT); +LOCK TABLE t1 READ; +TRUNCATE TABLE t1; +TRUNCATE TABLE t1; +UNLOCK TABLES; +DROP TABLE t1; + +--echo # +--echo # End of 10.6 tests +--echo # From b1009ddfc9ea0c2f013d4789d3e3d7b3a13bc239 Mon Sep 17 00:00:00 2001 From: Monty Date: Mon, 7 Jun 2021 18:15:39 +0300 Subject: [PATCH 018/251] MDEV-25778 Overrun buffer in to_string_native() Problem was that str->alloc(length) needed a buffer of length+1 as decimals2string() will add an end null. --- mysql-test/main/strings.result | 9 +++++++++ mysql-test/main/strings.test | 9 +++++++++ sql/my_decimal.cc | 2 +- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/mysql-test/main/strings.result b/mysql-test/main/strings.result index 7b71b593a97..1653812fb77 100644 --- a/mysql-test/main/strings.result +++ b/mysql-test/main/strings.result @@ -8,3 +8,12 @@ CHANGE MASTER TO master_user='user',master_password='pwd'; ERROR HY000: \042D\0442\0443 \043E\043F\0435\0440\0430\0446\0438\044E \043D\0435\0432\043E\0437\043C\043E\0436\043D\043E \0432\044B\043F\043E\043B\043D\0438\0442\044C \043F\0440\0438 \0440\0430\0431\043E\0442\0430\044E\0449\0435\043C \043F\043E\0442\043E\043A\0435 \043F\043E\0434\0447\0438\043D\0435\043D\043D\043E\0433\043E \0441\0435\0440\0432\0435\0440\0430 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa STOP SLAVE; RESET SLAVE ALL; +# +# MDEV-25778 Overrun buffer in to_string_native() +# +CREATE TABLE t1 (a DECIMAL(15,11) ZEROFILL); +INSERT INTO t1 (a) VALUES (0.1),(0.2); +SELECT length(ENCRYPT(a)) AS f, COUNT(*) FROM t1 GROUP BY f; +f COUNT(*) +13 2 +DROP TABLE t1; diff --git a/mysql-test/main/strings.test b/mysql-test/main/strings.test index 33ac6b116d5..7daa764afea 100644 --- a/mysql-test/main/strings.test +++ b/mysql-test/main/strings.test @@ -15,3 +15,12 @@ START SLAVE sql_thread; CHANGE MASTER TO master_user='user',master_password='pwd'; STOP SLAVE; RESET SLAVE ALL; + +--echo # +--echo # MDEV-25778 Overrun buffer in to_string_native() +--echo # + +CREATE TABLE t1 (a DECIMAL(15,11) ZEROFILL); +INSERT INTO t1 (a) VALUES (0.1),(0.2); +SELECT length(ENCRYPT(a)) AS f, COUNT(*) FROM t1 GROUP BY f; +DROP TABLE t1; diff --git a/sql/my_decimal.cc b/sql/my_decimal.cc index ac86ff71b64..54b038ccb2d 100644 --- a/sql/my_decimal.cc +++ b/sql/my_decimal.cc @@ -115,7 +115,7 @@ int my_decimal::to_string_native(String *str, uint fixed_prec, uint fixed_dec, ? (fixed_prec + ((fixed_prec == fixed_dec) ? 1 : 0) + 1) : my_decimal_string_length(this)); int result; - if (str->alloc(length)) + if (str->alloc(length+1)) // Alloc also space for \0 return check_result(mask, E_DEC_OOM); result= decimal2string(this, (char*) str->ptr(), &length, (int)fixed_prec, fixed_dec, From 233590a48d78fb1c7e320c7131c4543c10a4face Mon Sep 17 00:00:00 2001 From: Monty Date: Mon, 7 Jun 2021 18:28:27 +0300 Subject: [PATCH 019/251] MDEV-25754 ASAN: stack-buffer-overflow in Field_newdate::val_str() Problem was that Field_newdate() didn't allocate a string big enough for the result. --- mysql-test/main/strings.result | 10 ++++++++++ mysql-test/main/strings.test | 9 +++++++++ sql/field.cc | 4 ++-- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/mysql-test/main/strings.result b/mysql-test/main/strings.result index 1653812fb77..b327381f8bf 100644 --- a/mysql-test/main/strings.result +++ b/mysql-test/main/strings.result @@ -17,3 +17,13 @@ SELECT length(ENCRYPT(a)) AS f, COUNT(*) FROM t1 GROUP BY f; f COUNT(*) 13 2 DROP TABLE t1; +# +# MDEV-25754 ASAN: stack-buffer-overflow in Field_newdate::val_str +# +CREATE TABLE t1 (d DATE); +INSERT INTO t1 VALUES ('1920-03-02'),('2020-12-01'); +SELECT LENGTH(CONCAT_WS(d, ' ')) FROM t1; +LENGTH(CONCAT_WS(d, ' ')) +1 +1 +DROP TABLE t1; diff --git a/mysql-test/main/strings.test b/mysql-test/main/strings.test index 7daa764afea..d0785cfb072 100644 --- a/mysql-test/main/strings.test +++ b/mysql-test/main/strings.test @@ -24,3 +24,12 @@ CREATE TABLE t1 (a DECIMAL(15,11) ZEROFILL); INSERT INTO t1 (a) VALUES (0.1),(0.2); SELECT length(ENCRYPT(a)) AS f, COUNT(*) FROM t1 GROUP BY f; DROP TABLE t1; + +--echo # +--echo # MDEV-25754 ASAN: stack-buffer-overflow in Field_newdate::val_str +--echo # + +CREATE TABLE t1 (d DATE); +INSERT INTO t1 VALUES ('1920-03-02'),('2020-12-01'); +SELECT LENGTH(CONCAT_WS(d, ' ')) FROM t1; +DROP TABLE t1; diff --git a/sql/field.cc b/sql/field.cc index eaa7dc7bf05..e149835cc2d 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -6751,7 +6751,7 @@ String *Field_newdate::val_str(String *val_buffer, String *val_ptr __attribute__((unused))) { DBUG_ASSERT(marked_for_read()); - val_buffer->alloc(field_length); + val_buffer->alloc(field_length+1); val_buffer->length(field_length); uint32 tmp=(uint32) uint3korr(ptr); int part; @@ -6923,7 +6923,7 @@ longlong Field_datetime0::val_int(void) String *Field_datetime0::val_str(String *val_buffer, String *val_ptr __attribute__((unused))) { - val_buffer->alloc(field_length); + val_buffer->alloc(field_length+1); val_buffer->length(field_length); DBUG_ASSERT(marked_for_read()); From 310dff5d847b3c117ab6bca8e6ccbcc8bca818d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 7 Jun 2021 19:07:45 +0300 Subject: [PATCH 020/251] MDEV-25783: Change buffer records are lost under heavy load ibuf_read_merge_pages(): Disable some code that was added in MDEV-20394 in order to avoid a server hang if the change buffer is corrupted, presumably due to the race condition in recovery that was later fixed in MDEV-24449. The code will still be available in debug builds when the command line option --debug=d,ibuf_merge_corruption is specified. Due to MDEV-19514, the impact of this code is much worse starting with the 10.5 series. In older versions, the code was only enabled during a shutdown with innodb_fast_shutdown=0, but in 10.5 it was active during the normal operation of the server. --- storage/innobase/ibuf/ibuf0ibuf.cc | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/storage/innobase/ibuf/ibuf0ibuf.cc b/storage/innobase/ibuf/ibuf0ibuf.cc index 3c7f2de2a67..9288a496735 100644 --- a/storage/innobase/ibuf/ibuf0ibuf.cc +++ b/storage/innobase/ibuf/ibuf0ibuf.cc @@ -2296,9 +2296,11 @@ bool ibuf_delete_rec(const page_id_t page_id, btr_pcur_t* pcur, static void ibuf_read_merge_pages(const uint32_t* space_ids, const uint32_t* page_nos, ulint n_stored) { +#ifndef DBUG_OFF mem_heap_t* heap = mem_heap_create(512); ulint dops[IBUF_OP_COUNT]; memset(dops, 0, sizeof(dops)); +#endif for (ulint i = 0; i < n_stored; i++) { const ulint space_id = space_ids[i]; @@ -2331,6 +2333,28 @@ tablespace_deleted: goto tablespace_deleted; } } +#ifndef DBUG_OFF + DBUG_EXECUTE_IF("ibuf_merge_corruption", goto work_around;); + continue; + + /* The following code works around a hang when the + change buffer is corrupted, likely due to the race + condition in crash recovery that was fixed in + MDEV-24449. But, it also introduces corruption by + itself in the following scenario: + + (1) We merged buffered changes in buf_page_get_gen() + (2) We committed the mini-transaction + (3) Redo log and the page with the merged changes is written + (4) A write completion callback thread evicts the page. + (5) Other threads buffer changes for that page. + (6) We will wrongly discard those newly buffered changes below. + + This code will be available in debug builds, so that + users may try to fix a shutdown hang that occurs due + to a corrupted change buffer. */ + +work_around: /* Prevent an infinite loop, by removing entries from the change buffer also in the case the bitmap bits were wrongly clear even though buffered changes exist. */ @@ -2377,10 +2401,13 @@ done: ibuf_mtr_commit(&mtr); btr_pcur_close(&pcur); mem_heap_empty(heap); +#endif } +#ifndef DBUG_OFF ibuf_add_ops(ibuf.n_discarded_ops, dops); mem_heap_free(heap); +#endif } /*********************************************************************//** From eed419b487dd6f555cdfd92aa0756fdec1b9060f Mon Sep 17 00:00:00 2001 From: Monty Date: Mon, 7 Jun 2021 15:38:38 +0300 Subject: [PATCH 021/251] Fixed a DBUG_ASSERT when running zerofill() on aria tables This happended when an aria table was already used by the system before running zerofill, which could happen with Aria system tables. Fixed by using a proper page type when reading pages in zerofill --- storage/maria/ma_check.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/storage/maria/ma_check.c b/storage/maria/ma_check.c index e1c85cd2d44..5b37cac74d5 100644 --- a/storage/maria/ma_check.c +++ b/storage/maria/ma_check.c @@ -3413,6 +3413,9 @@ static my_bool maria_zerofill_index(HA_CHECK *param, MARIA_HA *info, my_bool zero_lsn= (share->base.born_transactional && !(param->testflag & T_ZEROFILL_KEEP_LSN)); int error= 1; + enum pagecache_page_type page_type= (share->base.born_transactional ? + PAGECACHE_LSN_PAGE : + PAGECACHE_PLAIN_PAGE); DBUG_ENTER("maria_zerofill_index"); if (!(param->testflag & T_SILENT)) @@ -3427,7 +3430,7 @@ static my_bool maria_zerofill_index(HA_CHECK *param, MARIA_HA *info, if (!(buff= pagecache_read(share->pagecache, &share->kfile, page, DFLT_INIT_HITS, 0, - PAGECACHE_PLAIN_PAGE, PAGECACHE_LOCK_WRITE, + page_type, PAGECACHE_LOCK_WRITE, &page_link.link))) { pagecache_unlock_by_link(share->pagecache, page_link.link, @@ -3504,6 +3507,9 @@ static my_bool maria_zerofill_data(HA_CHECK *param, MARIA_HA *info, uint block_size= share->block_size; MARIA_FILE_BITMAP *bitmap= &share->bitmap; my_bool zero_lsn= !(param->testflag & T_ZEROFILL_KEEP_LSN), error; + enum pagecache_page_type read_page_type= (share->base.born_transactional ? + PAGECACHE_LSN_PAGE : + PAGECACHE_PLAIN_PAGE); DBUG_ENTER("maria_zerofill_data"); /* This works only with BLOCK_RECORD files */ @@ -3527,7 +3533,7 @@ static my_bool maria_zerofill_data(HA_CHECK *param, MARIA_HA *info, if (!(buff= pagecache_read(share->pagecache, &info->dfile, page, 1, 0, - PAGECACHE_PLAIN_PAGE, PAGECACHE_LOCK_WRITE, + read_page_type, PAGECACHE_LOCK_WRITE, &page_link.link))) { _ma_check_print_error(param, From bf5c050fd28f616d789a02b0fbd6fd8ff53c78d3 Mon Sep 17 00:00:00 2001 From: Monty Date: Mon, 7 Jun 2021 17:40:30 +0300 Subject: [PATCH 022/251] MDEV-25866 Upgrade from pre-10.5.10 to 10.5.10 causes CHECK errors on encrypted Aria tables Hard to do a test case, but tested by hand and verified that mysql_upgrade will update the encrypted MariaDB tables. --- storage/maria/ha_maria.cc | 20 ++++++++++++++++++++ storage/maria/ha_maria.h | 1 + 2 files changed, 21 insertions(+) diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 79d32886659..5bf6754ff9d 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -4198,6 +4198,26 @@ int ha_maria::find_unique_row(uchar *record, uint constrain_no) return rc; } + +/** + Check if a table needs to be repaired +*/ + +int ha_maria::check_for_upgrade(HA_CHECK_OPT *check) +{ + if (table->s->mysql_version && table->s->mysql_version <= 100509 && + (file->s->base.extra_options & MA_EXTRA_OPTIONS_ENCRYPTED)) + { + /* + Encrypted tables before 10.5.9 had a bug where LSN was not + stored on the pages. These must be repaired! + */ + return HA_ADMIN_NEEDS_ALTER; + } + return HA_ADMIN_OK; +} + + struct st_mysql_storage_engine maria_storage_engine= { MYSQL_HANDLERTON_INTERFACE_VERSION }; diff --git a/storage/maria/ha_maria.h b/storage/maria/ha_maria.h index b2c664a072d..6b4302145dd 100644 --- a/storage/maria/ha_maria.h +++ b/storage/maria/ha_maria.h @@ -144,6 +144,7 @@ public: int check(THD * thd, HA_CHECK_OPT * check_opt) override; int analyze(THD * thd, HA_CHECK_OPT * check_opt) override; int repair(THD * thd, HA_CHECK_OPT * check_opt) override; + int check_for_upgrade(HA_CHECK_OPT *check_opt) override; bool check_and_repair(THD * thd) override final; bool is_crashed() const override final; bool is_changed() const; From 5ba4c4200ce1f9bce8c2fc1de5d97a131d3c2f37 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Sun, 6 Jun 2021 22:22:03 +0200 Subject: [PATCH 023/251] MDEV-25870 Windows - fix ARM64 cross-compilation --- cmake/os/Windows.cmake | 8 ++++++++ cmake/package_name.cmake | 5 ++++- extra/wolfssl/CMakeLists.txt | 4 ++-- include/my_byteorder.h | 4 ++-- include/my_rdtsc.h | 4 +++- mysys/CMakeLists.txt | 2 +- mysys/my_delete.c | 5 +++-- mysys/stacktrace.c | 6 +++++- storage/innobase/handler/ha_innodb.cc | 2 +- storage/innobase/include/univ.i | 19 +++++++++++++------ storage/rocksdb/CMakeLists.txt | 3 +++ 11 files changed, 45 insertions(+), 17 deletions(-) diff --git a/cmake/os/Windows.cmake b/cmake/os/Windows.cmake index 73463ef2833..232560ff7b1 100644 --- a/cmake/os/Windows.cmake +++ b/cmake/os/Windows.cmake @@ -24,6 +24,14 @@ INCLUDE (CheckCSourceRuns) INCLUDE (CheckSymbolExists) INCLUDE (CheckTypeSize) +IF(MSVC) + IF(CMAKE_CXX_COMPILER_ARCHITECTURE_ID STREQUAL ARM64) + SET(MSVC_ARM64 1) + SET(MSVC_INTEL 0) + ELSE() + SET(MSVC_INTEL 1) + ENDIF() +ENDIF() # avoid running system checks by using pre-cached check results # system checks are expensive on VS since every tiny program is to be compiled in diff --git a/cmake/package_name.cmake b/cmake/package_name.cmake index d14bf1f526e..21a08401a44 100644 --- a/cmake/package_name.cmake +++ b/cmake/package_name.cmake @@ -38,7 +38,10 @@ IF(NOT VERSION) SET(NEED_DASH_BETWEEN_PLATFORM_AND_MACHINE 0) SET(DEFAULT_PLATFORM "win") IF(64BIT) - SET(DEFAULT_MACHINE "x64") + STRING(TOLOWER "${CMAKE_C_COMPILER_ARCHITECTURE_ID}" DEFAULT_MACHINE) + IF(NOT DEFAULT_MACHINE) + SET(DEFAULT_MACHINE "x64") + ENDIF() ELSE() SET(DEFAULT_MACHINE "32") ENDIF() diff --git a/extra/wolfssl/CMakeLists.txt b/extra/wolfssl/CMakeLists.txt index c99fb155dd6..c3cd0d52fbf 100644 --- a/extra/wolfssl/CMakeLists.txt +++ b/extra/wolfssl/CMakeLists.txt @@ -1,4 +1,4 @@ -IF(MSVC) +IF(MSVC_INTEL) PROJECT(wolfssl C ASM_MASM) ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64") PROJECT(wolfssl C ASM) @@ -7,7 +7,7 @@ ELSE() ENDIF() IF(CMAKE_SIZEOF_VOID_P MATCHES 8) -IF(MSVC) +IF(MSVC_INTEL) SET(WOLFSSL_INTELASM ON) SET(WOLFSSL_X86_64_BUILD 1) SET(HAVE_INTEL_RDSEED 1) diff --git a/include/my_byteorder.h b/include/my_byteorder.h index abdf19a3632..a70330ca47c 100644 --- a/include/my_byteorder.h +++ b/include/my_byteorder.h @@ -31,10 +31,10 @@ format (low byte first). There are 'korr' (assume 'corrector') variants for integer types, but 'get' (assume 'getter') for floating point types. */ -#if (defined(__i386__) || defined(_WIN32)) && !defined(WITH_UBSAN) +#if (defined(__i386__) || defined(_M_IX86)) && !defined(WITH_UBSAN) #define MY_BYTE_ORDER_ARCH_OPTIMIZED #include "byte_order_generic_x86.h" -#elif defined(__x86_64__) && !defined(WITH_UBSAN) +#elif (defined(__x86_64__) || defined (_M_X64)) && !defined(WITH_UBSAN) #include "byte_order_generic_x86_64.h" #else #include "byte_order_generic.h" diff --git a/include/my_rdtsc.h b/include/my_rdtsc.h index 33d722764d4..5a6f4a87012 100644 --- a/include/my_rdtsc.h +++ b/include/my_rdtsc.h @@ -130,8 +130,10 @@ static inline ulonglong my_timer_cycles(void) { # if __has_builtin(__builtin_readcyclecounter) && !defined (__aarch64__) return __builtin_readcyclecounter(); -# elif defined _WIN32 || defined __i386__ || defined __x86_64__ +# elif defined _M_IX86 || defined _M_X64 || defined __i386__ || defined __x86_64__ return __rdtsc(); +#elif defined _M_ARM64 + return _ReadStatusReg(ARM64_CNTVCT); # elif defined(__INTEL_COMPILER) && defined(__ia64__) && defined(HAVE_IA64INTRIN_H) return (ulonglong) __getReg(_IA64_REG_AR_ITC); /* (3116) */ #elif defined(__GNUC__) && defined(__ia64__) diff --git a/mysys/CMakeLists.txt b/mysys/CMakeLists.txt index 5a4eeeba603..269369360f1 100644 --- a/mysys/CMakeLists.txt +++ b/mysys/CMakeLists.txt @@ -58,7 +58,7 @@ IF (WIN32) my_win_popen.cc) ENDIF() -IF(MSVC) +IF(MSVC_INTEL) SET(MYSYS_SOURCES ${MYSYS_SOURCES} crc32/crc32_x86.c) IF(CMAKE_SIZEOF_VOID_P EQUAL 8) SET (MYSYS_SOURCES ${MYSYS_SOURCES} crc32/crc32c_amd64.cc) diff --git a/mysys/my_delete.c b/mysys/my_delete.c index b9b0e112077..d322f302ea7 100644 --- a/mysys/my_delete.c +++ b/mysys/my_delete.c @@ -80,7 +80,8 @@ int my_delete(const char *name, myf MyFlags) a file to unique name. Symbolic link are deleted without renaming. Directories are not deleted. - */ +*/ +#include static int my_win_unlink(const char *name) { HANDLE handle= INVALID_HANDLE_VALUE; @@ -166,7 +167,7 @@ static int my_win_unlink(const char *name) goto error; } - tsc= __rdtsc(); + tsc= my_timer_cycles(); my_snprintf(unique_filename,sizeof(unique_filename),"%s.%llx.deleted", name, tsc); if (!MoveFile(name, unique_filename)) diff --git a/mysys/stacktrace.c b/mysys/stacktrace.c index 250d0bdbea2..844d8a0b28f 100644 --- a/mysys/stacktrace.c +++ b/mysys/stacktrace.c @@ -587,8 +587,12 @@ void my_print_stacktrace(uchar* unused1, ulong unused2, my_bool silent) frame.AddrFrame.Offset= context.Rbp; frame.AddrPC.Offset= context.Rip; frame.AddrStack.Offset= context.Rsp; +#elif defined(_M_ARM64) + machine= IMAGE_FILE_MACHINE_ARM64; + frame.AddrFrame.Offset= context.Fp; + frame.AddrPC.Offset= context.Pc; + frame.AddrStack.Offset= context.Sp; #else - /*There is currently no need to support IA64*/ #pragma error ("unsupported architecture") #endif diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 53c7eae7c09..ce469e49bce 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -2475,7 +2475,7 @@ __forceinline unsigned int nlz (ulonglong x) return (unsigned int) n ^ m; #endif #elif defined(_M_ARM64) - return _CountLeadingZeros(x); + return _CountLeadingZeros64(x); #endif } #else diff --git a/storage/innobase/include/univ.i b/storage/innobase/include/univ.i index 5bfed89b6d7..eb32e91298d 100644 --- a/storage/innobase/include/univ.i +++ b/storage/innobase/include/univ.i @@ -487,14 +487,21 @@ it is read or written. */ # define UNIV_PREFETCH_RW(addr) ((void) 0) # endif /* COMPILER_HINTS */ -# elif defined _WIN32 && defined COMPILER_HINTS -# include +# elif defined _MSC_VER && defined COMPILER_HINTS # define UNIV_EXPECT(expr,value) (expr) # define UNIV_LIKELY_NULL(expr) (expr) -// __MM_HINT_T0 - (temporal data) -// prefetch data into all levels of the cache hierarchy. -# define UNIV_PREFETCH_R(addr) _mm_prefetch((char *) addr, _MM_HINT_T0) -# define UNIV_PREFETCH_RW(addr) _mm_prefetch((char *) addr, _MM_HINT_T0) +# if defined _M_IX86 || defined _M_X64 + // __MM_HINT_T0 - (temporal data) + // prefetch data into all levels of the cache hierarchy. +# define UNIV_PREFETCH_R(addr) _mm_prefetch((char *) addr, _MM_HINT_T0) +# define UNIV_PREFETCH_RW(addr) _mm_prefetch((char *) addr, _MM_HINT_T0) +# elif defined _M_ARM64 +# define UNIV_PREFETCH_R(addr) __prefetch(addr) +# define UNIV_PREFETCH_RW(addr) __prefetch(addr) +# else +# define UNIV_PREFETCH_R ((void) 0) +# define UNIV_PREFETCH_RW(addr) ((void) 0) +# endif #else /* Dummy versions of the macros */ # define UNIV_EXPECT(expr,value) (expr) diff --git a/storage/rocksdb/CMakeLists.txt b/storage/rocksdb/CMakeLists.txt index c2fc8de8149..be687478b9b 100644 --- a/storage/rocksdb/CMakeLists.txt +++ b/storage/rocksdb/CMakeLists.txt @@ -42,6 +42,9 @@ endif() IF (WIN32 AND CMAKE_SIZEOF_VOID_P EQUAL 4) SKIP_ROCKSDB_PLUGIN("32-Bit Windows are temporarily disabled") ENDIF() +IF(MSVC_ARM64) + SKIP_ROCKSDB_PLUGIN("Windows ARM64 not supported") +ENDIF() # This plugin needs recent C++ compilers (it is using C++11 features) # Skip build for the old compilers From 4927bf25346229ed5be936575daa29e38eb895de Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Mon, 7 Jun 2021 16:50:55 +0200 Subject: [PATCH 024/251] MDEV-25870 Windows - MSI generation cleanup, fix ARM64 - Support building ARM64 packages - require InstallerVersion 5.0 -required for arm64, also it is there already on Windows 7 --- win/packaging/CMakeLists.txt | 143 ++++++++++++++---------------- win/packaging/ca/CMakeLists.txt | 3 +- win/packaging/create_msi.cmake | 5 +- win/packaging/mysql_server.wxs.in | 2 +- 4 files changed, 72 insertions(+), 81 deletions(-) diff --git a/win/packaging/CMakeLists.txt b/win/packaging/CMakeLists.txt index d11053fa1dd..2c8f0c309eb 100644 --- a/win/packaging/CMakeLists.txt +++ b/win/packaging/CMakeLists.txt @@ -13,95 +13,99 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA -IF(NOT WIN32) - RETURN() +SET(CAN_BUILD_MSI 1) +MACRO(CANT_BUILD_MSI reason) + IF(BUILD_RELEASE) + MESSAGE(FATAL_ERROR "Can't build MSI package - ${reason}") + ENDIF() + SET(CAN_BUILD_MSI 0) +ENDMACRO() + +IF (NOT CMAKE_C_COMPILER_ARCHITECTURE_ID) + CANT_BUILD_MSI("Can't determine compiler architecture") ENDIF() -IF(MSVC_VERSION LESS 1600) - RETURN() -ENDIF() -SET(MANUFACTURER "MariaDB Corporation Ab") +STRING(TOLOWER "${CMAKE_C_COMPILER_ARCHITECTURE_ID}" WIX_ARCH) + SET(WIX_BIN_PATHS) -FOREACH(WIX_VER 3.9 3.10 3.11) +FOREACH(WIX_VER 3.14 3.13 3.12 3.11) LIST(APPEND WIX_BIN_PATHS "$ENV{ProgramFiles}/WiX Toolset v${WIX_VER}/bin") LIST(APPEND WIX_BIN_PATHS "$ENV{ProgramFiles} (x86)/WiX Toolset v${WIX_VER}/bin") ENDFOREACH() - FIND_PATH(WIX_DIR heat.exe ${WIX_BIN_PATHS}) -SET(CPACK_WIX_PACKAGE_BASE_NAME "MariaDB") -IF(CMAKE_SIZEOF_VOID_P EQUAL 4) - SET(CPACK_WIX_UPGRADE_CODE "49EB7A6A-1CEF-4A1E-9E89-B9A4993963E3") - SET(CPACK_WIX_PACKAGE_NAME "MariaDB ${MAJOR_VERSION}.${MINOR_VERSION}") -ELSE() - SET(CPACK_WIX_UPGRADE_CODE "2331E7BD-EE58-431B-9E18-B2B918BCEB1B") - SET(CPACK_WIX_PACKAGE_NAME "MariaDB ${MAJOR_VERSION}.${MINOR_VERSION} (x64)") -ENDIF() - -IF(WIX_DIR) -IF(CMAKE_SIZEOF_VOID_P EQUAL 8) - SET(WIX_ARCH_SUFFIX "x64") -ELSE() - SET(WIX_ARCH_SUFFIX "x86") -ENDIF() -# Need some Wix SDK libraries to link with customaction -IF(MSVC_VERSION EQUAL 1600 OR MSVC_VERSION EQUAL 1700 ) - SET(WIX_MSVC_SUFFIX "VS2010") -ELSEIF(MSVC_VERSION EQUAL 1800) - SET(WIX_MSVC_SUFFIX "VS2013") -ELSE() - SET(WIX_MSVC_SUFFIX "VS2015") +IF(NOT WIX_DIR) + CANT_BUILD_MSI("WiX version 3.11 or later not found") ENDIF() -FIND_LIBRARY(WIX_WCAUTIL_LIBRARY - NAMES wcautil${WIX_ARCH_SUFFIX} wcautil${WIX_MSVC_SUFFIX}${WIX_ARCH_SUFFIX} +GET_FILENAME_COMPONENT(WIX_SDK_DIR ../SDK/ ABSOLUTE BASE_DIR ${WIX_DIR} CACHE) +FIND_LIBRARY(WIX_WCAUTIL_LIBRARY wcautil - PATHS - ${WIX_DIR}/../SDK/${WIX_MSVC_SUFFIX}/lib/${WIX_ARCH_SUFFIX} + PATHS + ${WIX_SDK_DIR}/VS2017/lib/${WIX_ARCH} + ${WIX_SDK_DIR}/VS2015/lib/${WIX_ARCH} ) +IF(NOT WIX_WCAUTIL_LIBRARY) + CANT_BUILD_MSI("wcautil.lib not found for ${WIX_ARCH}") +ENDIF() + FIND_LIBRARY(WIX_DUTIL_LIBRARY - NAMES dutil${WIX_ARCH_SUFFIX} dutil PATHS - ${WIX_DIR}/../SDK/${WIX_MSVC_SUFFIX}/lib/${WIX_ARCH_SUFFIX} + ${WIX_SDK_DIR}/VS2017/lib/${WIX_ARCH} + ${WIX_SDK_DIR}/VS2015/lib/${WIX_ARCH} ) -ENDIF() IF(NOT WIX_DUTIL_LIBRARY) - MESSAGE(STATUS "Cannot find wix 3, installer project will not be generated") - IF(BUILD_RELEASE) - MESSAGE(FATAL_ERROR - "Can't find Wix. It is necessary for producing official package") - ENDIF() - RETURN() + CANT_BUILD_MSI("dutil.lib not found for ${WIX_ARCH}") ENDIF() -ADD_SUBDIRECTORY(ca) - -# extra.wxs.in needs DATADIR_MYSQL_FILES and DATADIR_PERFORMANCE_SCHEMA_FILES, i.e -# Wix-compatible file lists for ${builddir}\sql\data\{mysql,performance_schema} - -FOREACH(dir mysql performance_schema) - FILE(GLOB files ${CMAKE_BINARY_DIR}/sql/data/${dir}/*) - SET(filelist) - FOREACH(f ${files}) - IF(NOT f MATCHES ".rule") - FILE(TO_NATIVE_PATH "${f}" file_native_path) - GET_FILENAME_COMPONENT(file_name "${f}" NAME) - SET(filelist -"${filelist} -") - ENDIF() - ENDFOREACH() - STRING(TOUPPER ${dir} DIR_UPPER) - SET(DATADIR_${DIR_UPPER}_FILES "${filelist}") -ENDFOREACH() +FIND_PATH(WIX_INCLUDE_DIR + wcautil.h PATHS + ${WIX_SDK_DIR}/VS2017/inc + ${WIX_SDK_DIR}/VS2015/inc + ${WIX_SDK_DIR}/inc) +IF(NOT WIX_INCLUDE_DIR) + CANT_BUILD_MSI("wcautil.h not found for ${WIX_ARCH}") +ENDIF() FIND_PROGRAM(CANDLE_EXECUTABLE candle ${WIX_DIR}) +IF(NOT CANDLE_EXECUTABLE) + CANT_BUILD_MSI("candle.exe not found") +ENDIF() + FIND_PROGRAM(LIGHT_EXECUTABLE light ${WIX_DIR}) +IF(NOT LIGHT_EXECUTABLE) + CANT_BUILD_MSI("light.exe not found") +ENDIF() + +SET(CPACK_WIX_PACKAGE_BASE_NAME "MariaDB") + +SET(CPACK_WIX_UPGRADE_CODE_arm64 "5AA9B79C-643C-4151-811D-B6845AA5DB28") +SET(CPACK_WIX_UPGRADE_CODE_x86 "49EB7A6A-1CEF-4A1E-9E89-B9A4993963E3") +SET(CPACK_WIX_UPGRADE_CODE_x64 "2331E7BD-EE58-431B-9E18-B2B918BCEB1B") + +SET(CPACK_WIX_UPGRADE_CODE ${CPACK_WIX_UPGRADE_CODE_${WIX_ARCH}}) +IF(NOT CPACK_WIX_UPGRADE_CODE) + MESSAGE_ONCE("unknown upgrade code for arch ${WIX_ARCH}") + CANT_BUILD_MSI("unknown upgrade code for arch ${WIX_ARCH}") +ENDIF() + +IF(WIX_ARCH STREQUAL "x86") + SET(CPACK_WIX_PACKAGE_NAME "MariaDB ${MAJOR_VERSION}.${MINOR_VERSION}") +ELSE() + SET(CPACK_WIX_PACKAGE_NAME "MariaDB ${MAJOR_VERSION}.${MINOR_VERSION} (${WIX_ARCH})") +ENDIF() + +IF(CAN_BUILD_MSI) + +ADD_SUBDIRECTORY(ca) +SET(MANUFACTURER "MariaDB Corporation Ab") + + # WiX wants the license text as rtf; if there is no rtf license, # we create a fake one from the plain text COPYING file. @@ -161,17 +165,6 @@ IF(THIRD_PARTY_FEATURE_CONDITION) SET(THIRD_PARTY_FEATURE_CONDITION "${THIRD_PARTY_FEATURE_CONDITION}") ENDIF() -IF(NOT CPACK_WIX_UI) - SET(CPACK_WIX_UI "MyWixUI_Mondo") -ENDIF() - -IF(CMAKE_SIZEOF_VOID_P EQUAL 8) - SET(WixWin64 " Win64='yes'") -ELSE() - SET(WixWin64) -ENDIF() - - IF(CMAKE_GENERATOR MATCHES "Visual Studio") SET(CONFIG_PARAM "-DCMAKE_INSTALL_CONFIG_NAME=${CMAKE_CFG_INTDIR}") ENDIF() @@ -209,10 +202,12 @@ ADD_CUSTOM_TARGET( -DWIXCA_LOCATION="$" -DMSVC_CRT_TYPE="${MSVC_CRT_TYPE}" -DDYNAMIC_UCRT_LINK="${DYNAMIC_UCRT_LINK}" + -DPlatform="${WIX_ARCH}" -P ${CMAKE_CURRENT_SOURCE_DIR}/create_msi.cmake ) ADD_DEPENDENCIES(MSI wixca) +ENDIF(CAN_BUILD_MSI) IF(CMAKE_GENERATOR MATCHES "Visual Studio") SET(CPACK_CONFIG_PARAM -C $(Configuration)) diff --git a/win/packaging/ca/CMakeLists.txt b/win/packaging/ca/CMakeLists.txt index 326bab47de4..368a844f830 100644 --- a/win/packaging/ca/CMakeLists.txt +++ b/win/packaging/ca/CMakeLists.txt @@ -13,10 +13,9 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA -INCLUDE_DIRECTORIES(${WIX_DIR}/../SDK/${WIX_MSVC_SUFFIX}/inc) SET(WIXCA_SOURCES CustomAction.cpp CustomAction.def) -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/sql ${CMAKE_CURRENT_SOURCE_DIR}) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/sql ${CMAKE_CURRENT_SOURCE_DIR} ${WIX_INCLUDE_DIR}) # Custom action should not depend on C runtime, since we do not know if CRT is installed. FORCE_STATIC_CRT() diff --git a/win/packaging/create_msi.cmake b/win/packaging/create_msi.cmake index cb1a9654987..ab88c7fbc50 100644 --- a/win/packaging/create_msi.cmake +++ b/win/packaging/create_msi.cmake @@ -30,15 +30,12 @@ FOREACH(third_party ${WITH_THIRD_PARTY}) ENDFOREACH() +SET(CANDLE_ARCH -arch ${Platform}) IF(CMAKE_SIZEOF_VOID_P EQUAL 8) - SET(CANDLE_ARCH -arch x64) SET(Win64 " Win64='yes'") - SET(Platform x64) SET(PlatformProgramFilesFolder ProgramFiles64Folder) SET(CA_QUIET_EXEC CAQuietExec64) ELSE() - SET(CANDLE_ARCH -arch x86) - SET(Platform x86) SET(PlatformProgramFilesFolder ProgramFilesFolder) SET(CA_QUIET_EXEC CAQuietExec) SET(Win64) diff --git a/win/packaging/mysql_server.wxs.in b/win/packaging/mysql_server.wxs.in index 80dcc365e56..c1bcc0c9012 100644 --- a/win/packaging/mysql_server.wxs.in +++ b/win/packaging/mysql_server.wxs.in @@ -12,7 +12,7 @@ Keywords='Installer' Description='MariaDB Server' Manufacturer='@MANUFACTURER@' - InstallerVersion='301' + InstallerVersion='500' Languages='1033' Compressed='yes' SummaryCodepage='1252' From 8149e4d0a139b901c8902b5b9fae371cef47275f Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Mon, 7 Jun 2021 15:08:18 -0700 Subject: [PATCH 025/251] MDEV-25682 Explain shows an execution plan different from actually executed If a select query contained an ORDER BY clause that followed a LIMIT clause or an ORDER BY clause or ORDER BY with LIMIT the EXPLAIN output for the query showed an execution plan different from that was actually executed. Approved by Roman Nozdrin --- mysql-test/main/order_by.result | 25 +++++++++++++++++++++++++ mysql-test/main/order_by.test | 16 ++++++++++++++++ sql/item_subselect.cc | 2 ++ sql/sql_select.cc | 2 +- 4 files changed, 44 insertions(+), 1 deletion(-) diff --git a/mysql-test/main/order_by.result b/mysql-test/main/order_by.result index f4e88d6e6e3..c8f63f881cc 100644 --- a/mysql-test/main/order_by.result +++ b/mysql-test/main/order_by.result @@ -3460,6 +3460,31 @@ SET max_length_for_sort_data=@save_max_length_for_sort_data; SET max_sort_length= @save_max_sort_length; SET sql_select_limit= @save_sql_select_limit; DROP TABLE t1; +# +# MDEV-25682: EXPLAIN for SELECT with ORDER BY after [ORDER BY] LIMIT +# +create table t1 (a int); +insert into t1 values (3), (7), (1); +explain (select a from t1 limit 2) order by a desc; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 +NULL UNIT RESULT ALL NULL NULL NULL NULL NULL Using filesort +(select a from t1 limit 2) order by a desc; +a +7 +3 +create table t2 (a int, b int); +insert into t2 values (3,70), (7,10), (1,40), (4,30); +explain (select b,a from t2 order by a limit 3) order by b desc; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 4 Using filesort +NULL UNIT RESULT ALL NULL NULL NULL NULL NULL Using filesort +(select b,a from t2 order by a limit 3) order by b desc; +b a +70 3 +40 1 +30 4 +drop table t1,t2; # End of 10.2 tests # # MDEV-16214: Incorrect plan taken by the optimizer , uses INDEX instead of ref access with ORDER BY diff --git a/mysql-test/main/order_by.test b/mysql-test/main/order_by.test index 74884144a98..08d5982b220 100644 --- a/mysql-test/main/order_by.test +++ b/mysql-test/main/order_by.test @@ -2293,6 +2293,22 @@ SET max_sort_length= @save_max_sort_length; SET sql_select_limit= @save_sql_select_limit; DROP TABLE t1; +--echo # +--echo # MDEV-25682: EXPLAIN for SELECT with ORDER BY after [ORDER BY] LIMIT +--echo # + +create table t1 (a int); +insert into t1 values (3), (7), (1); +explain (select a from t1 limit 2) order by a desc; +(select a from t1 limit 2) order by a desc; + +create table t2 (a int, b int); +insert into t2 values (3,70), (7,10), (1,40), (4,30); +explain (select b,a from t2 order by a limit 3) order by b desc; +(select b,a from t2 order by a limit 3) order by b desc; + +drop table t1,t2; + --echo # End of 10.2 tests --echo # diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 9f43561151d..352d80da92c 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -274,6 +274,8 @@ bool Item_subselect::fix_fields(THD *thd_param, Item **ref) res= TRUE; goto end; } + if (sl == unit->first_select() && !sl->next_select()) + unit->fake_select_lex= 0; } } diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 6c090ea5352..7f4c6d24b8d 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -26370,7 +26370,7 @@ bool mysql_explain_union(THD *thd, SELECT_LEX_UNIT *unit, select_result *result) sl->options|= SELECT_DESCRIBE; } - if (unit->is_unit_op()) + if (unit->is_unit_op() || unit->fake_select_lex) { if (unit->union_needs_tmp_table() && unit->fake_select_lex) { From bb28bffc3ed179a9912aced2b873e43999111887 Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Mon, 7 Jun 2021 19:51:57 -0700 Subject: [PATCH 026/251] Ported the test case for MDEV-25682 from 10.2 No fix for this bug is needed starting from version 10.4. --- mysql-test/main/order_by.result | 25 +++++++++++++++++++++++++ mysql-test/main/order_by.test | 16 ++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/mysql-test/main/order_by.result b/mysql-test/main/order_by.result index 826daf0542f..129bd8928f2 100644 --- a/mysql-test/main/order_by.result +++ b/mysql-test/main/order_by.result @@ -3536,6 +3536,31 @@ SET max_length_for_sort_data=@save_max_length_for_sort_data; SET max_sort_length= @save_max_sort_length; SET sql_select_limit= @save_sql_select_limit; DROP TABLE t1; +# +# MDEV-25682: EXPLAIN for SELECT with ORDER BY after [ORDER BY] LIMIT +# +create table t1 (a int); +insert into t1 values (3), (7), (1); +explain (select a from t1 limit 2) order by a desc; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY ALL NULL NULL NULL NULL 2 Using filesort +2 DERIVED t1 ALL NULL NULL NULL NULL 3 +(select a from t1 limit 2) order by a desc; +a +7 +3 +create table t2 (a int, b int); +insert into t2 values (3,70), (7,10), (1,40), (4,30); +explain (select b,a from t2 order by a limit 3) order by b desc; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY ALL NULL NULL NULL NULL 3 Using filesort +2 DERIVED t2 ALL NULL NULL NULL NULL 4 Using filesort +(select b,a from t2 order by a limit 3) order by b desc; +b a +70 3 +40 1 +30 4 +drop table t1,t2; # End of 10.2 tests # # MDEV-16214: Incorrect plan taken by the optimizer , uses INDEX instead of ref access with ORDER BY diff --git a/mysql-test/main/order_by.test b/mysql-test/main/order_by.test index 1bf353fd69d..0bf0311a642 100644 --- a/mysql-test/main/order_by.test +++ b/mysql-test/main/order_by.test @@ -2294,6 +2294,22 @@ SET max_sort_length= @save_max_sort_length; SET sql_select_limit= @save_sql_select_limit; DROP TABLE t1; +--echo # +--echo # MDEV-25682: EXPLAIN for SELECT with ORDER BY after [ORDER BY] LIMIT +--echo # + +create table t1 (a int); +insert into t1 values (3), (7), (1); +explain (select a from t1 limit 2) order by a desc; +(select a from t1 limit 2) order by a desc; + +create table t2 (a int, b int); +insert into t2 values (3,70), (7,10), (1,40), (4,30); +explain (select b,a from t2 order by a limit 3) order by b desc; +(select b,a from t2 order by a limit 3) order by b desc; + +drop table t1,t2; + --echo # End of 10.2 tests --echo # From dfa2d0bc13362b949b1b1699955583f74e7db90a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 7 Jun 2021 17:46:59 +0300 Subject: [PATCH 027/251] MDEV-25869 Change buffer entries are lost on InnoDB restart buf_read_ibuf_merge_pages(): If space->size is 0, invoke fil_space_get_size() to determine the size of the tablespace by reading the header page. Only after that proceed to delete any entries that are beyond the end of the tablespace. Otherwise, we could be deleting valid entries that actually need to be applied. This fixes a regression that had been introduced in commit b80df9eba23b4eb9694e770a41135127c6dbc5df (MDEV-21069), which aimed to avoid crashes during DROP TABLE of corrupted tables. --- storage/innobase/buf/buf0rea.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/storage/innobase/buf/buf0rea.cc b/storage/innobase/buf/buf0rea.cc index ad583e577c4..6b68e9f8fa5 100644 --- a/storage/innobase/buf/buf0rea.cc +++ b/storage/innobase/buf/buf0rea.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2015, 2020, MariaDB Corporation. +Copyright (c) 2015, 2021, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -806,13 +806,18 @@ tablespace_deleted: continue; } - if (UNIV_UNLIKELY(page_nos[i] >= space->size)) { + ulint size = space->size; + if (!size) { + size = fil_space_get_size(space->id); + } + + if (UNIV_UNLIKELY(page_nos[i] >= size)) { do { ibuf_delete_recs(page_id_t(space_ids[i], page_nos[i])); } while (++i < n_stored && space_ids[i - 1] == space_ids[i] - && page_nos[i] >= space->size); + && page_nos[i] >= size); i--; next: fil_space_release(space); From b8d38c5e39d526e006f4e8e8977ac4c6166bc4c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 8 Jun 2021 15:03:50 +0300 Subject: [PATCH 028/251] dict_index_build_internal_clust(): Catch MDEV-20131 on CREATE TABLE --- storage/innobase/dict/dict0dict.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc index 59851acdaab..1ffeb8d1e16 100644 --- a/storage/innobase/dict/dict0dict.cc +++ b/storage/innobase/dict/dict0dict.cc @@ -2318,8 +2318,8 @@ dict_index_build_internal_clust( ulint i; ibool* indexed; - ut_ad(dict_index_is_clust(index)); - ut_ad(!dict_index_is_ibuf(index)); + ut_ad(index->is_primary()); + ut_ad(!index->has_virtual()); ut_ad(mutex_own(&dict_sys.mutex)); From 8b02e02b27f4a9dcb12a2b5d60e54ec0e9baeb44 Mon Sep 17 00:00:00 2001 From: mkaruza Date: Fri, 4 Jun 2021 09:40:46 +0200 Subject: [PATCH 029/251] MDEV-25698 SIGSEGV in wsrep_should_replicate_ddl MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If temporary internal table is in use `hton` will not be set. Skip check if DDL should be replicated in this case. Reviewed-by: Jan Lindström --- mysql-test/suite/galera/r/galera_wsrep_mode.result | 4 ++++ mysql-test/suite/galera/t/galera_wsrep_mode.test | 8 ++++++++ sql/wsrep_mysqld.cc | 3 +++ 3 files changed, 15 insertions(+) diff --git a/mysql-test/suite/galera/r/galera_wsrep_mode.result b/mysql-test/suite/galera/r/galera_wsrep_mode.result index 2c8dac6ffc8..89fd4c1bbb3 100644 --- a/mysql-test/suite/galera/r/galera_wsrep_mode.result +++ b/mysql-test/suite/galera/r/galera_wsrep_mode.result @@ -10,3 +10,7 @@ Warning 1290 WSREP: wsrep_mode = REQUIRED_PRIMARY_KEY enabled. Table should have CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; DROP TABLE t1; SET GLOBAL wsrep_mode = default; +SET GLOBAL wsrep_mode = STRICT_REPLICATION; +CREATE VIEW v AS SELECT * FROM JSON_TABLE ('{"a":0}',"$" COLUMNS (a DECIMAL(1,1) path '$.a')) foo; +DROP VIEW v; +SET GLOBAL wsrep_mode = default; diff --git a/mysql-test/suite/galera/t/galera_wsrep_mode.test b/mysql-test/suite/galera/t/galera_wsrep_mode.test index d6dc86a2713..a8e192123bd 100644 --- a/mysql-test/suite/galera/t/galera_wsrep_mode.test +++ b/mysql-test/suite/galera/t/galera_wsrep_mode.test @@ -15,3 +15,11 @@ CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; DROP TABLE t1; SET GLOBAL wsrep_mode = default; + + +# MDEV-25698 SIGSEGV in wsrep_should_replicate_ddl + +SET GLOBAL wsrep_mode = STRICT_REPLICATION; +CREATE VIEW v AS SELECT * FROM JSON_TABLE ('{"a":0}',"$" COLUMNS (a DECIMAL(1,1) path '$.a')) foo; +DROP VIEW v; +SET GLOBAL wsrep_mode = default; diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index b953854479d..b72ed2ac352 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -2229,6 +2229,9 @@ bool wsrep_should_replicate_ddl(THD* thd, const handlerton *hton) if (!wsrep_check_mode(WSREP_MODE_STRICT_REPLICATION)) return true; + if (!hton) + return true; + switch (hton->db_type) { case DB_TYPE_INNODB: From 29e8c154172bd6b9dccd9757fddace93be6ad194 Mon Sep 17 00:00:00 2001 From: Anel Husakovic Date: Mon, 3 May 2021 09:43:43 +0200 Subject: [PATCH 030/251] MDEV-25857: MTR should report at least last test that was executed in case of shutdown and not-completed - Report the test name in case not all tests are completed and server closed the connection - Rerport the failure of the last test with the server log in case of server shutdown. - Ignore stackdump files (obtained on Windows). Reviewed by: wlad@mariadb.com --- .gitignore | 1 + mysql-test/mysql-test-run.pl | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/.gitignore b/.gitignore index 2cf801d6290..4de9edac44b 100644 --- a/.gitignore +++ b/.gitignore @@ -505,6 +505,7 @@ _UpgradeReport_Files/ Backup*/ UpgradeLog*.XML UpgradeLog*.htm +*.stackdump # SQL Server files *.mdf diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index fa68a017ff2..13369982daf 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -509,6 +509,12 @@ sub main { } if ( not @$completed ) { + my $test_name= mtr_grab_file($path_current_testlog); + $test_name =~ s/^CURRENT_TEST:\s//; + my $tinfo = My::Test->new(name => $test_name); + $tinfo->{result}= 'MTR_RES_FAILED'; + $tinfo->{logfile}=$path_current_testlog; + mtr_report_test($tinfo); mtr_error("Test suite aborted"); } @@ -5080,6 +5086,15 @@ sub mysqld_start ($$) { $opt_start_timeout, $mysqld->{'proc'}, $warn_seconds)) { my $mname= $mysqld->name(); + # Report failure about the last test case before exit + my $test_name= mtr_grab_file($path_current_testlog); + $test_name =~ s/^CURRENT_TEST:\s//; + my $tinfo = My::Test->new(name => $test_name); + $tinfo->{result}= 'MTR_RES_FAILED'; + $tinfo->{failures}= 1; + $tinfo->{logfile}=get_log_from_proc($mysqld->{'proc'}, $tinfo->{name}); + report_option('verbose', 1); + mtr_report_test($tinfo); mtr_error("Failed to start mysqld $mname with command $exe"); } From 75a65d3201a4486af96cf3277b6c5a4ba460eef7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 9 Jun 2021 14:23:20 +0300 Subject: [PATCH 031/251] MDEV-25886 CHECK TABLE crash with DB_MISSING_HISTORY if innodb_read_only Occasionally, the test innodb.alter_copy would fail in MariaDB 10.6.1, reporting DB_MISSING_HISTORY during CHECK TABLE. It started to occur during the development of MDEV-25180, which introduced purge_sys.stop_SYS(). If we delay purge more during DDL operations, then the test would almost always fail. The reason is that during startup we will restore a purge view, and CHECK TABLE would still use REPEATABLE READ even though innodb_read_only is set and other isolation levels than READ UNCOMMITTED are not guaranteed to work. ha_innobase::check(): Use READ UNCOMMITTED isolation level if innodb_read_only is set or innodb_force_recovery exceeds 3. dict_set_corrupted(): Do not update the persistent data dictionary if innodb_force_recovery exceeds 3. --- storage/innobase/dict/dict0dict.cc | 2 +- storage/innobase/handler/ha_innodb.cc | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc index 10b878c0e49..1d0e2af3cd6 100644 --- a/storage/innobase/dict/dict0dict.cc +++ b/storage/innobase/dict/dict0dict.cc @@ -5425,7 +5425,7 @@ dict_set_corrupted( /* If this is read only mode, do not update SYS_INDEXES, just mark it as corrupted in memory */ - if (srv_read_only_mode) { + if (high_level_read_only) { index->type |= DICT_CORRUPT; goto func_exit; } diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 4e63edc65c2..65039919793 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -14796,10 +14796,9 @@ ha_innobase::check( /* We must run the index record counts at an isolation level >= READ COMMITTED, because a dirty read can see a wrong number - of records in some index; to play safe, we use always - REPEATABLE READ here (except when undo logs are unavailable) */ - m_prebuilt->trx->isolation_level = srv_force_recovery - >= SRV_FORCE_NO_UNDO_LOG_SCAN + of records in some index; to play safe, we normally use + REPEATABLE READ here */ + m_prebuilt->trx->isolation_level = high_level_read_only ? TRX_ISO_READ_UNCOMMITTED : TRX_ISO_REPEATABLE_READ; From c872125a664842ecfb66c60f69b3a87390aec23d Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Sat, 22 May 2021 15:53:33 +0300 Subject: [PATCH 032/251] MDEV-25630: Crash with window function in left expr of IN subquery * Make Item_in_optimizer::fix_fields inherit the with_window_func attribute of the subquery's left expression (the subquery itself cannot have window functions that are aggregated in this select) * Make Item_cache_wrapper::Item_cache_wrapper() inherit with_window_func attribute of the item it is caching. --- mysql-test/r/win.result | 19 +++++++++++++++++++ .../encryption/r/tempfiles_encrypted.result | 19 +++++++++++++++++++ mysql-test/t/win.test | 14 ++++++++++++++ sql/item.cc | 1 + sql/item_cmpfunc.cc | 3 +++ 5 files changed, 56 insertions(+) diff --git a/mysql-test/r/win.result b/mysql-test/r/win.result index dd74c5c77fd..8a31dcc0634 100644 --- a/mysql-test/r/win.result +++ b/mysql-test/r/win.result @@ -3892,5 +3892,24 @@ id rn 1 1 drop table t1; # +# MDEV-25630: Crash with window function in left expr of IN subquery +# +CREATE TABLE t1 (i int); +INSERT INTO t1 VALUES (1),(2),(3); +SELECT lag(i) over (ORDER BY i) IN ( SELECT 1 FROM t1 a) FROM t1; +lag(i) over (ORDER BY i) IN ( SELECT 1 FROM t1 a) +NULL +1 +0 +DROP TABLE t1; +CREATE TABLE t1 (i int); +INSERT INTO t1 VALUES (1),(2),(3); +SELECT sum(i) over () IN ( SELECT 1 FROM t1 a) FROM t1; +sum(i) over () IN ( SELECT 1 FROM t1 a) +0 +0 +0 +DROP TABLE t1; +# # End of 10.2 tests # diff --git a/mysql-test/suite/encryption/r/tempfiles_encrypted.result b/mysql-test/suite/encryption/r/tempfiles_encrypted.result index 27eedc45028..3c81d7b6046 100644 --- a/mysql-test/suite/encryption/r/tempfiles_encrypted.result +++ b/mysql-test/suite/encryption/r/tempfiles_encrypted.result @@ -3898,6 +3898,25 @@ id rn 1 1 drop table t1; # +# MDEV-25630: Crash with window function in left expr of IN subquery +# +CREATE TABLE t1 (i int); +INSERT INTO t1 VALUES (1),(2),(3); +SELECT lag(i) over (ORDER BY i) IN ( SELECT 1 FROM t1 a) FROM t1; +lag(i) over (ORDER BY i) IN ( SELECT 1 FROM t1 a) +NULL +1 +0 +DROP TABLE t1; +CREATE TABLE t1 (i int); +INSERT INTO t1 VALUES (1),(2),(3); +SELECT sum(i) over () IN ( SELECT 1 FROM t1 a) FROM t1; +sum(i) over () IN ( SELECT 1 FROM t1 a) +0 +0 +0 +DROP TABLE t1; +# # End of 10.2 tests # # diff --git a/mysql-test/t/win.test b/mysql-test/t/win.test index 57214ab0165..c07a81f17da 100644 --- a/mysql-test/t/win.test +++ b/mysql-test/t/win.test @@ -2542,6 +2542,20 @@ order by rn desc; drop table t1; +--echo # +--echo # MDEV-25630: Crash with window function in left expr of IN subquery +--echo # + +CREATE TABLE t1 (i int); +INSERT INTO t1 VALUES (1),(2),(3); +SELECT lag(i) over (ORDER BY i) IN ( SELECT 1 FROM t1 a) FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 (i int); +INSERT INTO t1 VALUES (1),(2),(3); +SELECT sum(i) over () IN ( SELECT 1 FROM t1 a) FROM t1; +DROP TABLE t1; + --echo # --echo # End of 10.2 tests --echo # diff --git a/sql/item.cc b/sql/item.cc index be64edca9a1..d7a3659a2ce 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -8203,6 +8203,7 @@ Item_cache_wrapper::Item_cache_wrapper(THD *thd, Item *item_arg): name= item_arg->name; name_length= item_arg->name_length; with_subselect= orig_item->with_subselect; + with_window_func= orig_item->with_window_func; if ((expr_value= Item_cache::get_cache(thd, orig_item))) expr_value->setup(thd, orig_item); diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 7b7604053e3..8a2c532f621 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -1416,6 +1416,9 @@ bool Item_in_optimizer::fix_fields(THD *thd, Item **ref) maybe_null=1; with_subselect= 1; with_sum_func= with_sum_func || args[1]->with_sum_func; + with_window_func= args[0]->with_window_func; + // The subquery cannot have window functions aggregated in this select + DBUG_ASSERT(!args[1]->with_window_func); with_field= with_field || args[1]->with_field; with_param= args[0]->with_param || args[1]->with_param; used_tables_and_const_cache_join(args[1]); From dbe3161b6dab7640f7705d68f36cbd84240e80d1 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Wed, 9 Jun 2021 12:34:23 +0200 Subject: [PATCH 033/251] Remove WolfSSL workaround for old version. We're already on 4.4.6 --- extra/wolfssl/user_settings.h.in | 2 +- mysql-test/suite.pm | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/extra/wolfssl/user_settings.h.in b/extra/wolfssl/user_settings.h.in index e381e87ce71..911c466372e 100644 --- a/extra/wolfssl/user_settings.h.in +++ b/extra/wolfssl/user_settings.h.in @@ -20,7 +20,7 @@ #define WOLFSSL_AES_COUNTER #define NO_WOLFSSL_STUB #define OPENSSL_ALL -#undef WOLFSSL_ALLOW_TLSV10 /* see https://github.com/wolfSSL/wolfssl/issues/2960 */ +#define WOLFSSL_ALLOW_TLSV10 #define NO_OLD_TIMEVAL_NAME /* FP_MAX_BITS is set high solely to satisfy ssl_8k_key.test diff --git a/mysql-test/suite.pm b/mysql-test/suite.pm index 8ff2e95c083..905c3460d46 100644 --- a/mysql-test/suite.pm +++ b/mysql-test/suite.pm @@ -74,8 +74,6 @@ sub skip_combinations { $skip{'main/ssl_verify_ip.test'} = 'x509v3 support required' unless $openssl_ver ge "1.0.2"; - $skip{'main/tls_version1.test'} = 'https://github.com/wolfSSL/wolfssl/issues/2960' - if $ssl_lib =~ /WolfSSL 4.4.0/; %skip; } From b81803f0657b1693ac42643ae39ff25ccc42db36 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Wed, 9 Jun 2021 13:27:00 +0200 Subject: [PATCH 034/251] MDEV-22221: MariaDB with WolfSSL doesn't support AES-GCM cipher for SSL Enable AES-GCM for SSL (only). AES-GCM for encryption plugins remains disabled (aes-t fails, on some bug in GCM or CTR padding) --- extra/wolfssl/CMakeLists.txt | 1 + extra/wolfssl/user_settings.h.in | 1 + include/mysql/service_my_crypt.h | 2 +- mysql-test/main/wolfssl.opt | 1 + mysql-test/main/wolfssl.test | 6 ++++++ 5 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 mysql-test/main/wolfssl.opt create mode 100644 mysql-test/main/wolfssl.test diff --git a/extra/wolfssl/CMakeLists.txt b/extra/wolfssl/CMakeLists.txt index c99fb155dd6..908e27734b9 100644 --- a/extra/wolfssl/CMakeLists.txt +++ b/extra/wolfssl/CMakeLists.txt @@ -134,6 +134,7 @@ IF(WOLFSSL_X86_64_BUILD) SET(USE_INTEL_SPEEDUP 1) LIST(APPEND WOLFCRYPT_SOURCES ${WOLFCRYPT_SRCDIR}/aes_asm.S + ${WOLFCRYPT_SRCDIR}/aes_gcm_asm.S ${WOLFCRYPT_SRCDIR}/sha512_asm.S ${WOLFCRYPT_SRCDIR}/sha256_asm.S) ADD_DEFINITIONS(-maes -msse4.2 -mpclmul) diff --git a/extra/wolfssl/user_settings.h.in b/extra/wolfssl/user_settings.h.in index 911c466372e..4adb27142d9 100644 --- a/extra/wolfssl/user_settings.h.in +++ b/extra/wolfssl/user_settings.h.in @@ -17,6 +17,7 @@ #define WC_RSA_BLINDING #define HAVE_TLS_EXTENSIONS #define HAVE_AES_ECB +#define HAVE_AESGCM #define WOLFSSL_AES_COUNTER #define NO_WOLFSSL_STUB #define OPENSSL_ALL diff --git a/include/mysql/service_my_crypt.h b/include/mysql/service_my_crypt.h index 930d12a7dd1..2a232117ca1 100644 --- a/include/mysql/service_my_crypt.h +++ b/include/mysql/service_my_crypt.h @@ -45,7 +45,7 @@ extern "C" { /* The max key length of all supported algorithms */ #define MY_AES_MAX_KEY_LENGTH 32 -#define MY_AES_CTX_SIZE 640 +#define MY_AES_CTX_SIZE 656 enum my_aes_mode { MY_AES_ECB, MY_AES_CBC diff --git a/mysql-test/main/wolfssl.opt b/mysql-test/main/wolfssl.opt new file mode 100644 index 00000000000..812dba7bcbd --- /dev/null +++ b/mysql-test/main/wolfssl.opt @@ -0,0 +1 @@ +--ssl_cipher=ECDHE-RSA-AES256-GCM-SHA384 \ No newline at end of file diff --git a/mysql-test/main/wolfssl.test b/mysql-test/main/wolfssl.test new file mode 100644 index 00000000000..d9afc43901f --- /dev/null +++ b/mysql-test/main/wolfssl.test @@ -0,0 +1,6 @@ +# +# Various tests that require WolfSSL +# +--source include/have_ssl_communication.inc +--source include/not_embedded.inc +SELECT @@ssl_cipher; From 6a4e5bf1f5a64ec47e18ca6016420c9590509282 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 9 Jun 2021 12:31:02 +0300 Subject: [PATCH 035/251] MDEV-25852: Orphan #sql*.ibd files are left behind The implementation of MDEV-24626 was not entirely correct. We could occasionally fail to remove some *.ibd files on recovery. deferred_spaces: Keep track of FILE_DELETE records. deferred_spaces.add(): Do not allow duplicate file names. recv_rename_files(): Preserve some of renamed_spaces entries for deferred_spaces.reinit_all(). Thanks to Thirunarayanan Balathandayuthapani for noticing that deferred_spaces.add() must filter out duplicate file names, as well as some debugging help. --- storage/innobase/log/log0recv.cc | 106 +++++++++++++++++++++++++------ 1 file changed, 87 insertions(+), 19 deletions(-) diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc index 12ec2e29bfb..69214139fda 100644 --- a/storage/innobase/log/log0recv.cc +++ b/storage/innobase/log/log0recv.cc @@ -597,6 +597,8 @@ static struct lsn_t lsn; /** File name from the FILE_ record */ std::string file_name; + /** whether a FILE_DELETE record was encountered */ + mutable bool deleted; }; using map= std::map, @@ -638,11 +640,39 @@ static struct char *fil_path= fil_make_filepath(nullptr, {filename, strlen(filename)}, IBD, false); - const item defer= {lsn, fil_path}; - auto p= defers.emplace(space, defer); - if (!p.second && p.first->second.lsn <= defer.lsn) - p.first->second= defer; + const item defer{lsn, fil_path, false}; ut_free(fil_path); + + /* The file name must be unique. Keep the one with the latest LSN. */ + auto d= defers.begin(); + + while (d != defers.end()) + { + if (d->second.file_name != defer.file_name) + ++d; + else if (d->first == space) + { + /* Neither the file name nor the tablespace ID changed. + Update the LSN if needed. */ + if (d->second.lsn < lsn) + d->second.lsn= lsn; + return; + } + else if (d->second.lsn < lsn) + defers.erase(d++); + else + { + ut_ad(d->second.lsn != lsn); + return; /* A later tablespace already has this name. */ + } + } + + auto p= defers.emplace(space, defer); + if (!p.second && p.first->second.lsn <= lsn) + { + p.first->second.lsn= lsn; + p.first->second.file_name= defer.file_name; + } } void remove(uint32_t space) @@ -684,20 +714,42 @@ retry: const uint32_t space_id{d->first}; recv_sys_t::map::iterator p{recv_sys.pages.lower_bound({space_id,0})}; - if (p == recv_sys.pages.end() || p->first.space() != space_id) + if (d->second.deleted || + p == recv_sys.pages.end() || p->first.space() != space_id) { - /* No pages were recovered. We create a dummy tablespace, - and let dict_drop_index_tree() delete the file. */ + /* We found a FILE_DELETE record for the tablespace, or + there were no buffered records. Either way, we must create a + dummy tablespace with the latest known name, + for dict_drop_index_tree(). */ + while (p != recv_sys.pages.end() && p->first.space() == space_id) + { + recv_sys_t::map::iterator r= p++; + r->second.log.clear(); + recv_sys.pages.erase(r); + } recv_spaces_t::iterator it{recv_spaces.find(space_id)}; if (it != recv_spaces.end()) - create(it, d->second.file_name, static_cast + { + const std::string *name= &d->second.file_name; + if (d->second.deleted) + { + const auto r= renamed_spaces.find(space_id); + if (r != renamed_spaces.end()) + name= &r->second; + bool exists; + os_file_type_t ftype; + if (!os_file_status(name->c_str(), &exists, &ftype) || !exists) + goto processed; + } + create(it, *name, static_cast (1U << FSP_FLAGS_FCRC32_POS_MARKER | - FSP_FLAGS_FCRC32_PAGE_SSIZE()), nullptr, 0); + FSP_FLAGS_FCRC32_PAGE_SSIZE()), nullptr, 0); + } } else fail= recv_sys.recover_deferred(p, d->second.file_name, free_block); - auto e= d++; - defers.erase(e); +processed: + defers.erase(d++); if (fail) break; if (free_block) @@ -791,11 +843,13 @@ bool recv_sys_t::recover_deferred(recv_sys_t::map::iterator &p, space->release(); return false; } + goto fail; } block->unfix(); } +fail: ib::error() << "Cannot apply log to " << first << " of corrupted file '" << name << "'"; return true; @@ -1034,9 +1088,11 @@ fil_name_process(char* name, ulint len, ulint space_id, if (deleted) { /* Got FILE_DELETE */ + if (auto d = deferred_spaces.find(static_cast( + space_id))) { + d->deleted = true; + } - deferred_spaces.remove( - static_cast(space_id)); if (!p.second && f.status != file_name_t::DELETED) { f.status = file_name_t::DELETED; if (f.space != NULL) { @@ -2988,10 +3044,10 @@ void recv_sys_t::apply(bool last_batch) auto d= deferred_spaces.defers.find(space_id); if (d != deferred_spaces.defers.end()) { - if (recover_deferred(p, d->second.file_name, free_block)) + if (d->second.deleted) { - if (!srv_force_recovery) - set_corrupt_fs(); + /* For deleted files we must preserve the entry in deferred_spaces */ +erase_for_space: while (p != pages.end() && p->first.space() == space_id) { map::iterator r= p++; @@ -2999,7 +3055,15 @@ void recv_sys_t::apply(bool last_batch) pages.erase(r); } } - deferred_spaces.defers.erase(d); + else if (recover_deferred(p, d->second.file_name, free_block)) + { + if (!srv_force_recovery) + set_corrupt_fs(); + deferred_spaces.defers.erase(d); + goto erase_for_space; + } + else + deferred_spaces.defers.erase(d); if (!free_block) goto next_free_block; p= pages.lower_bound(page_id); @@ -3685,12 +3749,16 @@ static dberr_t recv_rename_files() dberr_t err= DB_SUCCESS; - for (const auto &r : renamed_spaces) + for (auto i= renamed_spaces.begin(); i != renamed_spaces.end(); ) { + const auto &r= *i; const uint32_t id= r.first; fil_space_t *space= fil_space_t::get(id); if (!space) + { + i++; continue; + } ut_ad(UT_LIST_GET_LEN(space->chain) == 1); char *old= space->chain.start->name; if (r.second != old) @@ -3743,8 +3811,8 @@ done: recv_sys.set_corrupt_fs(); break; } + renamed_spaces.erase(i++); } - renamed_spaces.clear(); return err; } From 3f78fbc582ed4c1187fa1a42189fd6d26bc041c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 9 Jun 2021 16:58:52 +0300 Subject: [PATCH 036/251] MDEV-25180 fixup: Assertion table->def_trx_id == trx->id... failed in row_merge_drop_indexes() We must invoke online_retry_drop_indexes() before ha_innobase_inplace_ctx::trx->id is assigned. --- storage/innobase/handler/handler0alter.cc | 29 ++++++++++++++++------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 493403c3287..471ff1574d6 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -8073,6 +8073,12 @@ err_exit: == ALTER_OPTIONS && !alter_options_need_rebuild(ha_alter_info, table))) { + DBUG_ASSERT(!m_prebuilt->trx->dict_operation_lock_mode); + if (ha_alter_info->handler_flags & ~INNOBASE_INPLACE_IGNORE) { + online_retry_drop_indexes(m_prebuilt->table, + m_user_thd); + } + if (heap) { ha_alter_info->handler_ctx = new ha_innobase_inplace_ctx( @@ -8089,14 +8095,6 @@ err_exit: alt_opt.page_compression_level); } - DBUG_ASSERT(m_prebuilt->trx->dict_operation_lock_mode == 0); - if (ha_alter_info->handler_flags & ~(INNOBASE_INPLACE_IGNORE)) { - - online_retry_drop_indexes( - m_prebuilt->table, m_user_thd); - - } - if ((ha_alter_info->handler_flags & ALTER_DROP_VIRTUAL_COLUMN) && prepare_inplace_drop_virtual(ha_alter_info, table)) { @@ -11119,7 +11117,22 @@ ha_innobase::commit_inplace_alter_table( ut_ad(trx_state_eq(trx, TRX_STATE_ACTIVE)); ut_ad(!new_clustered || trx->has_logged()); + /* The SQL layer recovery of ALTER TABLE will invoke + innodb_check_version() to know whether our trx->id, which we + reported via ha_innobase::table_version() after + ha_innobase::prepare_inplace_alter_table(), was committed. + If this trx was committed (the log write below completed), + we will be able to recover our trx->id to + dict_table_t::def_trx_id from the data dictionary tables. + + For this logic to work, purge_sys.stop_SYS() and + purge_sys.resume_SYS() will ensure that the DB_TRX_ID that we + wrote to the SYS_ tables will be preserved until the SQL layer + has durably marked the ALTER TABLE operation as completed. + + During recovery, the purge of InnoDB transaction history will + not start until innodb_ddl_recovery_done(). */ ha_alter_info->inplace_alter_table_committed = purge_sys.resume_SYS; purge_sys.stop_SYS(); From 1bd681c8b3c5213ce1f7976940a7dc38b48a0d39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 9 Jun 2021 17:02:55 +0300 Subject: [PATCH 037/251] MDEV-25506 (3 of 3): Do not delete .ibd files before commit This is a complete rewrite of DROP TABLE, also as part of other DDL, such as ALTER TABLE, CREATE TABLE...SELECT, TRUNCATE TABLE. The background DROP TABLE queue hack is removed. If a transaction needs to drop and create a table by the same name (like TRUNCATE TABLE does), it must first rename the table to an internal #sql-ib name. No committed version of the data dictionary will include any #sql-ib tables, because whenever a transaction renames a table to a #sql-ib name, it will also drop that table. Either the rename will be rolled back, or the drop will be committed. Data files will be unlinked after the transaction has been committed and a FILE_RENAME record has been durably written. The file will actually be deleted when the detached file handle returned by fil_delete_tablespace() will be closed, after the latches have been released. It is possible that a purge of the delete of the SYS_INDEXES record for the clustered index will execute fil_delete_tablespace() concurrently with the DDL transaction. In that case, the thread that arrives later will wait for the other thread to finish. HTON_TRUNCATE_REQUIRES_EXCLUSIVE_USE: A new handler flag. ha_innobase::truncate() now requires that all other references to the table be released in advance. This was implemented by Monty. ha_innobase::delete_table(): If CREATE TABLE..SELECT is detected, we will "hijack" the current transaction, drop the table in the current transaction and commit the current transaction. This essentially fixes MDEV-21602. There is a FIXME comment about making the check less failure-prone. ha_innobase::truncate(), ha_innobase::delete_table(): Implement a fast path for temporary tables. We will no longer allow temporary tables to use the adaptive hash index. dict_table_t::mdl_name: The original table name for the purpose of acquiring MDL in purge, to prevent a race condition between a DDL transaction that is dropping a table, and purge processing undo log records of DML that had executed before the DDL operation. For #sql-backup- tables during ALTER TABLE...ALGORITHM=COPY, the dict_table_t::mdl_name will differ from dict_table_t::name. dict_table_t::parse_name(): Use mdl_name instead of name. dict_table_rename_in_cache(): Update mdl_name. For the internal FTS_ tables of FULLTEXT INDEX, purge would acquire MDL on the FTS_ table name, but not on the main table, and therefore it would be able to run concurrently with a DDL transaction that is dropping the table. Previously, the DROP TABLE queue hack prevented a race between purge and DDL. For now, we introduce purge_sys.stop_FTS() to prevent purge from opening any table, while a DDL transaction that may drop FTS_ tables is in progress. The function fts_lock_table(), which will be invoked before the dictionary is locked, will wait for purge to release any table handles. trx_t::drop_table_statistics(): Drop statistics for the table. This replaces dict_stats_drop_index(). We will drop or rename persistent statistics atomically as part of DDL transactions. On lock conflict for dropping statistics, we will fail instantly with DB_LOCK_WAIT_TIMEOUT, because we will be holding the exclusive data dictionary latch. trx_t::commit_cleanup(): Separated from trx_t::commit_in_memory(). Relax an assertion around fts_commit() and allow DB_LOCK_WAIT_TIMEOUT in addition to DB_DUPLICATE_KEY. The call to fts_commit() is entirely misplaced here and may obviously break the consistency of transactions that affect FULLTEXT INDEX. It needs to be fixed separately. dict_table_t::n_foreign_key_checks_running: Remove (MDEV-21175). The counter was a work-around for missing meta-data locking (MDL) on the SQL layer, and not really needed in MariaDB. ER_TABLE_IN_FK_CHECK: Replaced with ER_UNUSED_28. HA_ERR_TABLE_IN_FK_CHECK: Remove. row_ins_check_foreign_constraints(): Do not acquire dict_sys.latch either. The SQL-layer MDL will protect us. This was reviewed by Thirunarayanan Balathandayuthapani and tested by Matthias Leich. --- include/handler_ername.h | 3 +- include/my_base.h | 2 +- mysql-test/include/check-testcase.test | 5 +- mysql-test/main/partition_alter.test | 11 +- .../suite/gcol/r/innodb_virtual_stats.result | 52 - .../suite/innodb/include/show_i_s_tables.inc | 1 - .../innodb/include/show_i_s_tablespaces.inc | 2 +- .../innodb/r/drop_table_background.result | 25 - .../suite/innodb/r/innodb-index-online.result | 18 - .../suite/innodb/r/innodb-table-online.result | 13 - .../suite/innodb/r/innodb-wl5522-debug.result | 1 + .../suite/innodb/r/innodb_defrag_stats.result | 132 +- .../r/innodb_skip_innodb_is_tables.result | 2 - .../innodb/r/innodb_stats_drop_locked.result | 41 +- ...innodb_stats_rename_table_if_exists.result | 55 +- .../suite/innodb/r/log_file_name.result | 2 + mysql-test/suite/innodb/r/monitor.result | 2 - .../suite/innodb/r/rename_table_debug.result | 31 - mysql-test/suite/innodb/r/truncate.result | 10 + mysql-test/suite/innodb/r/xa_recovery.result | 8 +- .../t/default_row_format_compatibility.test | 7 +- .../suite/innodb/t/drop_table_background.test | 48 - .../suite/innodb/t/innodb-wl5522-debug.test | 1 + mysql-test/suite/innodb/t/innodb-wl5522.test | 4 + .../suite/innodb/t/innodb-wl5980-alter.test | 2 +- .../suite/innodb/t/innodb_defrag_stats.test | 104 +- .../innodb/t/innodb_stats_drop_locked.test | 50 +- .../innodb_stats_rename_table_if_exists.test | 21 +- .../suite/innodb/t/instant_alter_import.test | 1 + mysql-test/suite/innodb/t/log_file_name.test | 4 +- .../suite/innodb/t/rename_table_debug.test | 41 - mysql-test/suite/innodb/t/table_flags.test | 4 - mysql-test/suite/innodb/t/truncate.test | 12 + mysql-test/suite/innodb/t/xa_recovery.test | 10 +- .../suite/innodb_fts/r/crash_recovery.result | 7 +- .../suite/innodb_fts/r/misc_debug.result | 7 +- .../suite/innodb_fts/t/crash_recovery.test | 23 +- mysql-test/suite/innodb_fts/t/misc_debug.test | 7 +- .../innodb_zip/r/wl5522_debug_zip.result | 1 + mysql-test/suite/innodb_zip/t/restart.test | 20 - .../suite/innodb_zip/t/wl5522_debug_zip.test | 1 + .../suite/parts/inc/partition_crash.inc | 4 +- .../t/partition_basic_symlink_innodb.test | 30 +- .../parts/t/partition_debug_sync_innodb.test | 6 +- .../suite/sys_vars/r/sysvars_innodb.result | 12 - sql/handler.cc | 4 - sql/handler.h | 4 +- sql/share/errmsg-utf8.txt | 4 +- sql/sql_base.cc | 9 +- sql/sql_truncate.cc | 24 +- storage/innobase/CMakeLists.txt | 1 + storage/innobase/btr/btr0btr.cc | 36 +- storage/innobase/btr/btr0cur.cc | 30 +- storage/innobase/btr/btr0sea.cc | 41 +- storage/innobase/dict/dict0crea.cc | 38 +- storage/innobase/dict/dict0dict.cc | 59 +- storage/innobase/dict/dict0load.cc | 15 +- storage/innobase/dict/dict0mem.cc | 2 +- storage/innobase/dict/dict0stats.cc | 662 +++------- storage/innobase/dict/drop.cc | 256 ++++ storage/innobase/fil/fil0crypt.cc | 7 +- storage/innobase/fil/fil0fil.cc | 193 ++- storage/innobase/fsp/fsp0file.cc | 16 +- storage/innobase/fts/fts0fts.cc | 250 ++-- storage/innobase/handler/ha_innodb.cc | 670 +++++----- storage/innobase/handler/ha_innodb.h | 30 - storage/innobase/handler/handler0alter.cc | 1047 ++++++--------- storage/innobase/include/btr0btr.h | 6 +- storage/innobase/include/btr0sea.h | 4 +- storage/innobase/include/btr0sea.ic | 10 +- storage/innobase/include/db0err.h | 2 - storage/innobase/include/dict0mem.h | 47 +- storage/innobase/include/dict0mem.ic | 7 +- storage/innobase/include/dict0stats.h | 106 +- storage/innobase/include/dict0types.h | 3 + storage/innobase/include/fil0fil.h | 34 +- storage/innobase/include/fts0fts.h | 38 +- storage/innobase/include/ha_prototypes.h | 2 +- storage/innobase/include/row0mysql.h | 60 +- storage/innobase/include/srv0mon.h | 2 - storage/innobase/include/trx0purge.h | 14 +- storage/innobase/include/trx0trx.h | 39 +- storage/innobase/lock/lock0lock.cc | 27 +- storage/innobase/os/os0file.cc | 6 +- storage/innobase/row/row0ins.cc | 33 +- storage/innobase/row/row0merge.cc | 2 +- storage/innobase/row/row0mysql.cc | 1118 ++--------------- storage/innobase/row/row0purge.cc | 16 +- storage/innobase/row/row0uins.cc | 50 +- storage/innobase/row/row0upd.cc | 12 - storage/innobase/srv/srv0mon.cc | 10 - storage/innobase/srv/srv0srv.cc | 47 +- storage/innobase/srv/srv0start.cc | 8 - storage/innobase/trx/trx0purge.cc | 5 +- storage/innobase/trx/trx0roll.cc | 3 + storage/innobase/trx/trx0trx.cc | 28 +- storage/innobase/ut/ut0ut.cc | 2 - .../r/innodb_i_s_tables_disabled.result | 2 - 98 files changed, 2180 insertions(+), 3804 deletions(-) delete mode 100644 mysql-test/suite/innodb/r/drop_table_background.result delete mode 100644 mysql-test/suite/innodb/r/rename_table_debug.result delete mode 100644 mysql-test/suite/innodb/t/drop_table_background.test delete mode 100644 mysql-test/suite/innodb/t/rename_table_debug.test create mode 100644 storage/innobase/dict/drop.cc diff --git a/include/handler_ername.h b/include/handler_ername.h index fe55062e6fb..d03790b8e64 100644 --- a/include/handler_ername.h +++ b/include/handler_ername.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2013 SkySQL Ab +/* Copyright (c) 2013, 2021, 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 @@ -74,7 +74,6 @@ { "HA_ERR_INDEX_COL_TOO_LONG", HA_ERR_INDEX_COL_TOO_LONG, "" }, { "HA_ERR_INDEX_CORRUPT", HA_ERR_INDEX_CORRUPT, "" }, { "HA_ERR_UNDO_REC_TOO_BIG", HA_ERR_UNDO_REC_TOO_BIG, "" }, -{ "HA_ERR_TABLE_IN_FK_CHECK", HA_ERR_TABLE_IN_FK_CHECK, "" }, { "HA_ERR_ROW_NOT_VISIBLE", HA_ERR_ROW_NOT_VISIBLE, "" }, { "HA_ERR_ABORTED_BY_USER", HA_ERR_ABORTED_BY_USER, "" }, { "HA_ERR_DISK_FULL", HA_ERR_DISK_FULL, "" }, diff --git a/include/my_base.h b/include/my_base.h index 7db8156e9b8..053bf3fbb69 100644 --- a/include/my_base.h +++ b/include/my_base.h @@ -513,7 +513,7 @@ enum ha_base_keytype { #define HA_ERR_INDEX_CORRUPT 180 /* Index corrupted */ #define HA_ERR_UNDO_REC_TOO_BIG 181 /* Undo log record too big */ #define HA_FTS_INVALID_DOCID 182 /* Invalid InnoDB Doc ID */ -#define HA_ERR_TABLE_IN_FK_CHECK 183 /* Table being used in foreign key check */ +/* #define HA_ERR_TABLE_IN_FK_CHECK 183 */ /* Table being used in foreign key check */ #define HA_ERR_TABLESPACE_EXISTS 184 /* The tablespace existed in storage engine */ #define HA_ERR_TOO_MANY_FIELDS 185 /* Table has too many columns */ #define HA_ERR_ROW_IN_WRONG_PARTITION 186 /* Row in wrong partition */ diff --git a/mysql-test/include/check-testcase.test b/mysql-test/include/check-testcase.test index e984c4dc497..60b376a2836 100644 --- a/mysql-test/include/check-testcase.test +++ b/mysql-test/include/check-testcase.test @@ -97,10 +97,7 @@ call mtr.check_testcase(); let $datadir=`select @@datadir`; list_files $datadir mysql_upgrade_info; -list_files_write_file $datadir.tempfiles.txt $datadir/test #sql*; ---replace_regex /#sql-ib[1-9][0-9]*\.ibd\n// -cat_file $datadir.tempfiles.txt; -remove_file $datadir.tempfiles.txt; +list_files $datadir/test #sql*; list_files $datadir/mysql #sql*; # diff --git a/mysql-test/main/partition_alter.test b/mysql-test/main/partition_alter.test index cca25d0989f..804b43dc3c2 100644 --- a/mysql-test/main/partition_alter.test +++ b/mysql-test/main/partition_alter.test @@ -86,11 +86,7 @@ show create table t1; --error ER_CONSTRAINT_FAILED insert t1 values (2, '2020-01-03', 20); drop table t1; ---let $regexp=/#sql-ib[0-9a-f]+\.ibd\n// ---list_files_write_file $datadir.files.txt $datadir/test ---replace_regex $regexp ---cat_file $datadir.files.txt ---remove_file $datadir.files.txt +--list_files $datadir/test # MyISAM, different execution path create table t1(id int, d date not null, b bool not null default 0, primary key(id,d)) @@ -106,10 +102,7 @@ show create table t1; --error ER_CONSTRAINT_FAILED insert t1 values (2, '2020-01-03', 20); drop table t1; ---list_files_write_file $datadir.files.txt $datadir/test ---replace_regex $regexp ---cat_file $datadir.files.txt ---remove_file $datadir.files.txt +--list_files $datadir/test # # MDEV-13097 Online alter of a partitioned MyISAM table with auto_increment diff --git a/mysql-test/suite/gcol/r/innodb_virtual_stats.result b/mysql-test/suite/gcol/r/innodb_virtual_stats.result index c0f595263df..74a0480883d 100644 --- a/mysql-test/suite/gcol/r/innodb_virtual_stats.result +++ b/mysql-test/suite/gcol/r/innodb_virtual_stats.result @@ -38,10 +38,6 @@ idxa n_diff_pfx01 a idxa n_diff_pfx02 a,DB_ROW_ID idxa n_leaf_pages Number of leaf pages in the index idxa size Number of pages in the index -idxb n_diff_pfx01 b -idxb n_diff_pfx02 b,DB_ROW_ID -idxb n_leaf_pages Number of leaf pages in the index -idxb size Number of pages in the index vidxcd n_diff_pfx01 c vidxcd n_diff_pfx02 c,d vidxcd n_diff_pfx03 c,d,DB_ROW_ID @@ -58,14 +54,6 @@ index_name stat_name stat_description GEN_CLUST_INDEX n_diff_pfx01 DB_ROW_ID GEN_CLUST_INDEX n_leaf_pages Number of leaf pages in the index GEN_CLUST_INDEX size Number of pages in the index -idxb n_diff_pfx01 b -idxb n_diff_pfx02 b,DB_ROW_ID -idxb n_leaf_pages Number of leaf pages in the index -idxb size Number of pages in the index -vidxcd n_diff_pfx01 d -vidxcd n_diff_pfx02 d,DB_ROW_ID -vidxcd n_leaf_pages Number of leaf pages in the index -vidxcd size Number of pages in the index ALTER TABLE t ADD INDEX vidxe (e), ALGORITHM=INPLACE; select count(*) from t; count(*) @@ -77,18 +65,6 @@ index_name stat_name stat_description GEN_CLUST_INDEX n_diff_pfx01 DB_ROW_ID GEN_CLUST_INDEX n_leaf_pages Number of leaf pages in the index GEN_CLUST_INDEX size Number of pages in the index -idxb n_diff_pfx01 b -idxb n_diff_pfx02 b,DB_ROW_ID -idxb n_leaf_pages Number of leaf pages in the index -idxb size Number of pages in the index -vidxcd n_diff_pfx01 d -vidxcd n_diff_pfx02 d,DB_ROW_ID -vidxcd n_leaf_pages Number of leaf pages in the index -vidxcd size Number of pages in the index -vidxe n_diff_pfx01 e -vidxe n_diff_pfx02 e,DB_ROW_ID -vidxe n_leaf_pages Number of leaf pages in the index -vidxe size Number of pages in the index ALTER TABLE t ADD COLUMN f INT GENERATED ALWAYS AS(a + a), ADD INDEX vidxf (f), ALGORITHM=INPLACE; select count(*) from t; count(*) @@ -100,22 +76,6 @@ index_name stat_name stat_description GEN_CLUST_INDEX n_diff_pfx01 DB_ROW_ID GEN_CLUST_INDEX n_leaf_pages Number of leaf pages in the index GEN_CLUST_INDEX size Number of pages in the index -idxb n_diff_pfx01 b -idxb n_diff_pfx02 b,DB_ROW_ID -idxb n_leaf_pages Number of leaf pages in the index -idxb size Number of pages in the index -vidxcd n_diff_pfx01 d -vidxcd n_diff_pfx02 d,DB_ROW_ID -vidxcd n_leaf_pages Number of leaf pages in the index -vidxcd size Number of pages in the index -vidxe n_diff_pfx01 e -vidxe n_diff_pfx02 e,DB_ROW_ID -vidxe n_leaf_pages Number of leaf pages in the index -vidxe size Number of pages in the index -vidxf n_diff_pfx01 f -vidxf n_diff_pfx02 f,DB_ROW_ID -vidxf n_leaf_pages Number of leaf pages in the index -vidxf size Number of pages in the index ALTER TABLE t DROP INDEX vidxcd; SELECT index_name, stat_name, stat_description FROM mysql.innodb_index_stats @@ -124,16 +84,4 @@ index_name stat_name stat_description GEN_CLUST_INDEX n_diff_pfx01 DB_ROW_ID GEN_CLUST_INDEX n_leaf_pages Number of leaf pages in the index GEN_CLUST_INDEX size Number of pages in the index -idxb n_diff_pfx01 b -idxb n_diff_pfx02 b,DB_ROW_ID -idxb n_leaf_pages Number of leaf pages in the index -idxb size Number of pages in the index -vidxe n_diff_pfx01 e -vidxe n_diff_pfx02 e,DB_ROW_ID -vidxe n_leaf_pages Number of leaf pages in the index -vidxe size Number of pages in the index -vidxf n_diff_pfx01 f -vidxf n_diff_pfx02 f,DB_ROW_ID -vidxf n_leaf_pages Number of leaf pages in the index -vidxf size Number of pages in the index DROP TABLE t; diff --git a/mysql-test/suite/innodb/include/show_i_s_tables.inc b/mysql-test/suite/innodb/include/show_i_s_tables.inc index 8e4a362de95..5fe34c370c8 100644 --- a/mysql-test/suite/innodb/include/show_i_s_tables.inc +++ b/mysql-test/suite/innodb/include/show_i_s_tables.inc @@ -15,6 +15,5 @@ SELECT t.name 'Table Name', WHERE t.name not like 'SYS_%' AND t.name NOT LIKE 'mysql/%' AND t.name NOT LIKE 'sys/%' - AND t.name NOT LIKE '%/#sql-ib%' ORDER BY t.name; --enable_query_log diff --git a/mysql-test/suite/innodb/include/show_i_s_tablespaces.inc b/mysql-test/suite/innodb/include/show_i_s_tablespaces.inc index 9b108da4115..a85a294860d 100644 --- a/mysql-test/suite/innodb/include/show_i_s_tablespaces.inc +++ b/mysql-test/suite/innodb/include/show_i_s_tablespaces.inc @@ -11,6 +11,6 @@ SELECT name 'Space_Name', filename 'Path' FROM information_schema.innodb_sys_tablespaces WHERE name != 'innodb_system' - AND name NOT LIKE 'mysql/%' AND name NOT LIKE '%/#sql-ib%' + AND name NOT LIKE 'mysql/%' ORDER BY space; --enable_query_log diff --git a/mysql-test/suite/innodb/r/drop_table_background.result b/mysql-test/suite/innodb/r/drop_table_background.result deleted file mode 100644 index 378f3ce00ab..00000000000 --- a/mysql-test/suite/innodb/r/drop_table_background.result +++ /dev/null @@ -1,25 +0,0 @@ -CREATE TABLE t(c0 SERIAL, c1 INT, c2 INT, c3 INT, c4 INT, -KEY(c1), KEY(c2), KEY(c2,c1), -KEY(c3), KEY(c3,c1), KEY(c3,c2), KEY(c3,c2,c1), -KEY(c4), KEY(c4,c1), KEY(c4,c2), KEY(c4,c2,c1), -KEY(c4,c3), KEY(c4,c3,c1), KEY(c4,c3,c2), KEY(c4,c3,c2,c1)) ENGINE=InnoDB; -CREATE TABLE `#mysql50##sql-ib-foo`(a SERIAL) ENGINE=InnoDB; -INSERT INTO t (c1) VALUES (1),(2),(1); -SET DEBUG_DBUG='+d,row_drop_table_add_to_background'; -CREATE TABLE target (PRIMARY KEY(c1)) ENGINE=InnoDB SELECT * FROM t; -ERROR 23000: Duplicate entry '1' for key 'PRIMARY' -SELECT * from target; -ERROR 42S02: Table 'test.target' doesn't exist -DROP TABLE t; -# restart -CREATE TABLE t (a INT) ENGINE=InnoDB; -DROP TABLE t; -DROP TABLE target; -ERROR 42S02: Unknown table 'test.target' -CREATE TABLE target (a INT) ENGINE=InnoDB; -DROP TABLE target; -SELECT * FROM `#mysql50##sql-ib-foo`; -ERROR 42S02: Table 'test.#mysql50##sql-ib-foo' doesn't exist in engine -DROP TABLE `#mysql50##sql-ib-foo`; -Warnings: -Warning 1932 Table 'test.#mysql50##sql-ib-foo' doesn't exist in engine diff --git a/mysql-test/suite/innodb/r/innodb-index-online.result b/mysql-test/suite/innodb/r/innodb-index-online.result index 6ac5e897731..92a2f57397c 100644 --- a/mysql-test/suite/innodb/r/innodb-index-online.result +++ b/mysql-test/suite/innodb/r/innodb-index-online.result @@ -8,7 +8,6 @@ SET GLOBAL innodb_monitor_enable = module_ddl; SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; name count ddl_background_drop_indexes 0 -ddl_background_drop_tables 0 ddl_online_create_index 0 ddl_pending_alter_table 0 ddl_sort_file_alter_table 0 @@ -27,7 +26,6 @@ ERROR 23000: Duplicate entry '1' for key 'PRIMARY' SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; name count ddl_background_drop_indexes 0 -ddl_background_drop_tables 0 ddl_online_create_index 0 ddl_pending_alter_table 0 ddl_sort_file_alter_table 0 @@ -81,7 +79,6 @@ SET DEBUG_SYNC = 'now WAIT_FOR scanned'; SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; name count ddl_background_drop_indexes 0 -ddl_background_drop_tables 0 ddl_online_create_index 1 ddl_pending_alter_table 1 ddl_sort_file_alter_table 0 @@ -99,7 +96,6 @@ SET DEBUG_SYNC = 'now WAIT_FOR created'; SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; name count ddl_background_drop_indexes 0 -ddl_background_drop_tables 0 ddl_online_create_index 0 ddl_pending_alter_table 1 ddl_sort_file_alter_table 0 @@ -113,7 +109,6 @@ ALTER TABLE t1 ADD UNIQUE INDEX(c2); SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; name count ddl_background_drop_indexes 0 -ddl_background_drop_tables 0 ddl_online_create_index 0 ddl_pending_alter_table 0 ddl_sort_file_alter_table 0 @@ -163,7 +158,6 @@ SET DEBUG_SYNC = 'now WAIT_FOR c2d_created'; SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; name count ddl_background_drop_indexes 0 -ddl_background_drop_tables 0 ddl_online_create_index 1 ddl_pending_alter_table 1 ddl_sort_file_alter_table 0 @@ -175,7 +169,6 @@ ERROR 70100: Query execution was interrupted SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; name count ddl_background_drop_indexes 0 -ddl_background_drop_tables 0 ddl_online_create_index 0 ddl_pending_alter_table 0 ddl_sort_file_alter_table 0 @@ -243,7 +236,6 @@ SET DEBUG_SYNC = 'now WAIT_FOR c2e_created'; SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; name count ddl_background_drop_indexes 0 -ddl_background_drop_tables 0 ddl_online_create_index 1 ddl_pending_alter_table 1 ddl_sort_file_alter_table 0 @@ -283,7 +275,6 @@ ROLLBACK; SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; name count ddl_background_drop_indexes 0 -ddl_background_drop_tables 0 ddl_online_create_index 1 ddl_pending_alter_table 1 ddl_sort_file_alter_table 0 @@ -316,7 +307,6 @@ ERROR HY000: Creating index 'c2e' required more than 'innodb_online_alter_log_ma SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; name count ddl_background_drop_indexes 1 -ddl_background_drop_tables 0 ddl_online_create_index 0 ddl_pending_alter_table 0 ddl_sort_file_alter_table 0 @@ -328,7 +318,6 @@ name pos SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; name count ddl_background_drop_indexes 1 -ddl_background_drop_tables 0 ddl_online_create_index 0 ddl_pending_alter_table 0 ddl_sort_file_alter_table 0 @@ -338,7 +327,6 @@ ALTER TABLE t1 COMMENT 'testing if c2e will be dropped'; SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; name count ddl_background_drop_indexes 0 -ddl_background_drop_tables 0 ddl_online_create_index 0 ddl_pending_alter_table 0 ddl_sort_file_alter_table 0 @@ -363,7 +351,6 @@ SET DEBUG_SYNC = 'now WAIT_FOR c2f_created'; SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; name count ddl_background_drop_indexes 0 -ddl_background_drop_tables 0 ddl_online_create_index 1 ddl_pending_alter_table 1 ddl_sort_file_alter_table 0 @@ -387,7 +374,6 @@ ROLLBACK; SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; name count ddl_background_drop_indexes 0 -ddl_background_drop_tables 0 ddl_online_create_index 1 ddl_pending_alter_table 1 ddl_sort_file_alter_table 0 @@ -400,7 +386,6 @@ ALTER TABLE t1 CHANGE c2 c22f INT; SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; name count ddl_background_drop_indexes 0 -ddl_background_drop_tables 0 ddl_online_create_index 0 ddl_pending_alter_table 0 ddl_sort_file_alter_table 0 @@ -464,7 +449,6 @@ name pos SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; name count ddl_background_drop_indexes 1 -ddl_background_drop_tables 0 ddl_online_create_index 0 ddl_pending_alter_table 0 ddl_sort_file_alter_table 0 @@ -473,7 +457,6 @@ connection default; SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; name count ddl_background_drop_indexes 1 -ddl_background_drop_tables 0 ddl_online_create_index 0 ddl_pending_alter_table 0 ddl_sort_file_alter_table 0 @@ -493,7 +476,6 @@ ALTER TABLE t1 DROP INDEX c2d, DROP INDEX c2f; SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; name count ddl_background_drop_indexes 0 -ddl_background_drop_tables 0 ddl_online_create_index 0 ddl_pending_alter_table 0 ddl_sort_file_alter_table 0 diff --git a/mysql-test/suite/innodb/r/innodb-table-online.result b/mysql-test/suite/innodb/r/innodb-table-online.result index 63313d7d7eb..8f06576f2ed 100644 --- a/mysql-test/suite/innodb/r/innodb-table-online.result +++ b/mysql-test/suite/innodb/r/innodb-table-online.result @@ -10,7 +10,6 @@ SET GLOBAL innodb_monitor_enable = module_ddl; SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; name count ddl_background_drop_indexes 0 -ddl_background_drop_tables 0 ddl_online_create_index 0 ddl_pending_alter_table 0 ddl_sort_file_alter_table 0 @@ -29,7 +28,6 @@ ERROR 23000: Duplicate entry '1' for key 'PRIMARY' SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; name count ddl_background_drop_indexes 0 -ddl_background_drop_tables 0 ddl_online_create_index 0 ddl_pending_alter_table 0 ddl_sort_file_alter_table 0 @@ -95,7 +93,6 @@ SET DEBUG_SYNC = 'now WAIT_FOR scanned'; SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; name count ddl_background_drop_indexes 0 -ddl_background_drop_tables 0 ddl_online_create_index 1 ddl_pending_alter_table 1 ddl_sort_file_alter_table 0 @@ -123,7 +120,6 @@ ALTER TABLE t1 DROP INDEX c2, ADD PRIMARY KEY(c1), ALGORITHM = INPLACE; SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; name count ddl_background_drop_indexes 0 -ddl_background_drop_tables 0 ddl_online_create_index 0 ddl_pending_alter_table 0 ddl_sort_file_alter_table 0 @@ -148,7 +144,6 @@ SET DEBUG_SYNC = 'now WAIT_FOR rebuilt'; SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; name count ddl_background_drop_indexes 0 -ddl_background_drop_tables 0 ddl_online_create_index 1 ddl_pending_alter_table 1 ddl_sort_file_alter_table 0 @@ -164,7 +159,6 @@ ERROR 70100: Query execution was interrupted SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; name count ddl_background_drop_indexes 0 -ddl_background_drop_tables 0 ddl_online_create_index 0 ddl_pending_alter_table 0 ddl_sort_file_alter_table 0 @@ -215,7 +209,6 @@ SET DEBUG_SYNC = 'now WAIT_FOR rebuilt2'; SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; name count ddl_background_drop_indexes 0 -ddl_background_drop_tables 0 ddl_online_create_index 1 ddl_pending_alter_table 1 ddl_sort_file_alter_table 0 @@ -247,7 +240,6 @@ ROLLBACK; SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; name count ddl_background_drop_indexes 0 -ddl_background_drop_tables 0 ddl_online_create_index 1 ddl_pending_alter_table 1 ddl_sort_file_alter_table 0 @@ -274,7 +266,6 @@ ERROR HY000: Creating index 'PRIMARY' required more than 'innodb_online_alter_lo SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; name count ddl_background_drop_indexes 0 -ddl_background_drop_tables 0 ddl_online_create_index 0 ddl_pending_alter_table 0 ddl_sort_file_alter_table 0 @@ -304,7 +295,6 @@ SET DEBUG_SYNC = 'now WAIT_FOR rebuilt3'; SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; name count ddl_background_drop_indexes 0 -ddl_background_drop_tables 0 ddl_online_create_index 1 ddl_pending_alter_table 1 ddl_sort_file_alter_table 2 @@ -320,7 +310,6 @@ ROLLBACK; SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; name count ddl_background_drop_indexes 0 -ddl_background_drop_tables 0 ddl_online_create_index 1 ddl_pending_alter_table 1 ddl_sort_file_alter_table 2 @@ -330,7 +319,6 @@ connection con1; SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; name count ddl_background_drop_indexes 0 -ddl_background_drop_tables 0 ddl_online_create_index 0 ddl_pending_alter_table 0 ddl_sort_file_alter_table 2 @@ -410,7 +398,6 @@ SET DEBUG_SYNC = 'now SIGNAL ddl_timed_out'; SELECT name, count FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE subsystem = 'ddl'; name count ddl_background_drop_indexes 0 -ddl_background_drop_tables 0 ddl_online_create_index 0 ddl_pending_alter_table 0 ddl_sort_file_alter_table 6 diff --git a/mysql-test/suite/innodb/r/innodb-wl5522-debug.result b/mysql-test/suite/innodb/r/innodb-wl5522-debug.result index 94d181ce448..2109d47bf4b 100644 --- a/mysql-test/suite/innodb/r/innodb-wl5522-debug.result +++ b/mysql-test/suite/innodb/r/innodb-wl5522-debug.result @@ -476,6 +476,7 @@ ALTER TABLE t1 IMPORT TABLESPACE; ERROR HY000: Index for table 't1' is corrupt; try to repair it SET SESSION debug_dbug=@saved_debug_dbug; restore: t1 .ibd and .cfg files +ALTER TABLE t1 IMPORT TABLESPACE; DROP TABLE t1; CREATE TABLE t1 ( c1 BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, diff --git a/mysql-test/suite/innodb/r/innodb_defrag_stats.result b/mysql-test/suite/innodb/r/innodb_defrag_stats.result index 598124e4ccb..c2fd378cb4b 100644 --- a/mysql-test/suite/innodb/r/innodb_defrag_stats.result +++ b/mysql-test/suite/innodb/r/innodb_defrag_stats.result @@ -1,41 +1,22 @@ -DROP TABLE if exists t1; select @@global.innodb_stats_persistent; @@global.innodb_stats_persistent 0 set global innodb_defragment_stats_accuracy = 20; -# Create table. -CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b VARCHAR(256), KEY SECOND(a, b)) ENGINE=INNODB; -# Populate data -INSERT INTO t1 VALUES(1, REPEAT('A', 256)); -INSERT INTO t1 (b) SELECT b from t1; -INSERT INTO t1 (b) SELECT b from t1; -INSERT INTO t1 (b) SELECT b from t1; -INSERT INTO t1 (b) SELECT b from t1; -INSERT INTO t1 (b) SELECT b from t1; -INSERT INTO t1 (b) SELECT b from t1; -INSERT INTO t1 (b) SELECT b from t1; -INSERT INTO t1 (b) SELECT b from t1; -INSERT INTO t1 (b) SELECT b from t1; -INSERT INTO t1 (b) SELECT b from t1; +CREATE TABLE t1(a INT PRIMARY KEY, b VARCHAR(256), KEY SECOND(a, b)) +ENGINE=INNODB; +INSERT INTO t1 SELECT seq, REPEAT('A', 256) FROM seq_1_to_1024; # Not enough page splits to trigger persistent stats write yet. -select count(stat_value) = 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_page_split'); -count(stat_value) = 0 -1 -select count(stat_value) = 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_pages_freed'); -count(stat_value) = 0 -1 -select count(stat_value) = 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_leaf_pages_defrag'); -count(stat_value) = 0 -1 -INSERT INTO t1 (b) SELECT b from t1; +select * from mysql.innodb_index_stats where table_name='t1' +and stat_name in ('n_page_split','n_pages_freed,n_leaf_pages_defrag'); +database_name table_name index_name last_update stat_name stat_value sample_size stat_description +INSERT INTO t1 SELECT seq, REPEAT('A', 256) FROM seq_1025_to_2048; # Persistent stats recorded. -select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_page_split'); +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name = 't1' and stat_name in ('n_page_split'); count(stat_value) > 0 1 -select count(stat_value) = 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_pages_freed'); -count(stat_value) = 0 -1 -select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_leaf_pages_defrag'); +select * from mysql.innodb_index_stats where table_name = 't1' and stat_name in ('n_pages_freed'); +database_name table_name index_name last_update stat_name stat_value sample_size stat_description +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name = 't1' and stat_name in ('n_leaf_pages_defrag'); count(stat_value) > 0 1 # Delete some rows. @@ -62,13 +43,12 @@ delete from t1 where a between 100 * 1 and 100 * 1 + 30; # restart # Server Restarted # Confirm persistent stats still there after restart. -select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_page_split'); +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name = 't1' and stat_name in ('n_page_split'); count(stat_value) > 0 1 -select count(stat_value) = 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_pages_freed'); -count(stat_value) = 0 -1 -select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_leaf_pages_defrag'); +select * from mysql.innodb_index_stats where table_name = 't1' and stat_name in ('n_pages_freed'); +database_name table_name index_name last_update stat_name stat_value sample_size stat_description +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name = 't1' and stat_name in ('n_leaf_pages_defrag'); count(stat_value) > 0 1 optimize table t1; @@ -77,101 +57,65 @@ test.t1 optimize status OK select sleep(2); sleep(2) 0 -select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_page_split'); +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name = 't1' and stat_name in ('n_page_split'); count(stat_value) > 0 1 -select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_pages_freed'); +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name = 't1' and stat_name in ('n_pages_freed'); count(stat_value) > 0 1 -select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_leaf_pages_defrag'); +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name = 't1' and stat_name in ('n_leaf_pages_defrag'); count(stat_value) > 0 1 set global innodb_defragment_stats_accuracy = 40; -INSERT INTO t1 (b) SELECT b from t1; -select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_page_split'); +INSERT INTO t1 SELECT seq, REPEAT('A', 256) FROM seq_2049_to_4096; +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name = 't1' and stat_name in ('n_page_split'); count(stat_value) > 0 1 -select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_pages_freed'); +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name = 't1' and stat_name in ('n_pages_freed'); count(stat_value) > 0 1 -select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_leaf_pages_defrag'); +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name = 't1' and stat_name in ('n_leaf_pages_defrag'); count(stat_value) > 0 1 -INSERT INTO t1 (b) SELECT b from t1; -select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_page_split'); +INSERT INTO t1 SELECT seq, REPEAT('A', 256) FROM seq_4097_to_8192; +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name = 't1' and stat_name in ('n_page_split'); count(stat_value) > 0 1 -select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_pages_freed'); +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name = 't1' and stat_name in ('n_pages_freed'); count(stat_value) > 0 1 -select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_leaf_pages_defrag'); +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name = 't1' and stat_name in ('n_leaf_pages_defrag'); count(stat_value) > 0 1 # Table rename should cause stats rename. rename table t1 to t2; -select sleep(1); -sleep(1) -0 -select count(stat_value) = 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_page_split'); -count(stat_value) = 0 -1 -select count(stat_value) = 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_pages_freed'); -count(stat_value) = 0 -1 -select count(stat_value) = 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_leaf_pages_defrag'); -count(stat_value) = 0 -1 -select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t2%' and stat_name in ('n_page_split'); +select * from mysql.innodb_index_stats where table_name = 't1'; +database_name table_name index_name last_update stat_name stat_value sample_size stat_description +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name = 't2' and stat_name in ('n_page_split'); count(stat_value) > 0 1 -select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t2%' and stat_name in ('n_pages_freed'); +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name = 't2' and stat_name in ('n_pages_freed'); count(stat_value) > 0 1 -select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t2%' and stat_name in ('n_leaf_pages_defrag'); +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name = 't2' and stat_name in ('n_leaf_pages_defrag'); count(stat_value) > 0 1 # Drop index should cause stats drop. drop index SECOND on t2; -select sleep(3); -sleep(3) -0 -select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t2%' and index_name = 'SECOND' and stat_name in ('n_page_split'); -count(stat_value) > 0 -1 -select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t2%' and index_name = 'SECOND' and stat_name in ('n_pages_freed'); -count(stat_value) > 0 -1 -select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t2%' and index_name = 'SECOND' and stat_name in ('n_leaf_pages_defrag'); -count(stat_value) > 0 -1 +select * from mysql.innodb_index_stats where table_name = 't2' and index_name = 'SECOND'; +database_name table_name index_name last_update stat_name stat_value sample_size stat_description # restart Server Restarted -select count(stat_value) = 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_page_split'); -count(stat_value) = 0 -1 -select count(stat_value) = 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_pages_freed'); -count(stat_value) = 0 -1 -select count(stat_value) = 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_leaf_pages_defrag'); -count(stat_value) = 0 -1 -select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t2%' and stat_name in ('n_page_split'); +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name = 't2' and stat_name in ('n_page_split'); count(stat_value) > 0 1 -select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t2%' and stat_name in ('n_pages_freed'); +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name = 't2' and stat_name in ('n_pages_freed'); count(stat_value) > 0 1 -select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t2%' and stat_name in ('n_leaf_pages_defrag'); +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name = 't2' and stat_name in ('n_leaf_pages_defrag'); count(stat_value) > 0 1 # Clean up DROP TABLE t2; -select count(stat_value) = 0 from mysql.innodb_index_stats where table_name like '%t2%' and stat_name in ('n_page_split'); -count(stat_value) = 0 -1 -select count(stat_value) = 0 from mysql.innodb_index_stats where table_name like '%t2%' and stat_name in ('n_pages_freed'); -count(stat_value) = 0 -1 -select count(stat_value) = 0 from mysql.innodb_index_stats where table_name like '%t2%' and stat_name in ('n_leaf_pages_defrag'); -count(stat_value) = 0 -1 +select * from mysql.innodb_index_stats where table_name = 't2'; +database_name table_name index_name last_update stat_name stat_value sample_size stat_description diff --git a/mysql-test/suite/innodb/r/innodb_skip_innodb_is_tables.result b/mysql-test/suite/innodb/r/innodb_skip_innodb_is_tables.result index 1f3b0750e56..49fe8e629e3 100644 --- a/mysql-test/suite/innodb/r/innodb_skip_innodb_is_tables.result +++ b/mysql-test/suite/innodb/r/innodb_skip_innodb_is_tables.result @@ -228,7 +228,6 @@ innodb_master_thread_sleeps server 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL N innodb_activity_count server 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Current server activity count innodb_master_active_loops server 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of times master thread performs its tasks when server is active innodb_master_idle_loops server 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of times master thread performs its tasks when server is idle -innodb_background_drop_table_usec server 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Time (in microseconds) spent to process drop table list innodb_log_flush_usec server 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Time (in microseconds) spent to flush log records innodb_dict_lru_usec server 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Time (in microseconds) spent to process DICT LRU list innodb_dict_lru_count_active server 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of tables evicted from DICT LRU list in the active loop @@ -245,7 +244,6 @@ dml_system_inserts dml 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 s dml_system_deletes dml 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of system rows deleted dml_system_updates dml 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of system rows updated ddl_background_drop_indexes ddl 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of indexes waiting to be dropped after failed index creation -ddl_background_drop_tables ddl 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of tables in background drop table list ddl_online_create_index ddl 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of indexes being created online ddl_pending_alter_table ddl 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of ALTER TABLE, CREATE INDEX, DROP INDEX in progress ddl_sort_file_alter_table ddl 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of sort files created during alter table diff --git a/mysql-test/suite/innodb/r/innodb_stats_drop_locked.result b/mysql-test/suite/innodb/r/innodb_stats_drop_locked.result index 3ae06c48ecb..7a6d5c46aab 100644 --- a/mysql-test/suite/innodb/r/innodb_stats_drop_locked.result +++ b/mysql-test/suite/innodb/r/innodb_stats_drop_locked.result @@ -1,7 +1,14 @@ +CREATE DATABASE unlocked; +CREATE TABLE unlocked.t1(a INT PRIMARY KEY) ENGINE=INNODB STATS_PERSISTENT=0; +CREATE DATABASE locked; +CREATE TABLE locked.t1(a INT PRIMARY KEY) ENGINE=INNODB STATS_PERSISTENT=1; +CREATE TABLE innodb_stats_drop_locked (c INT, KEY c_key (c)) +ENGINE=INNODB STATS_PERSISTENT=1; +ANALYZE TABLE innodb_stats_drop_locked; Table Op Msg_type Msg_text test.innodb_stats_drop_locked analyze status Engine-independent statistics collected test.innodb_stats_drop_locked analyze status OK -SET autocommit=0; +BEGIN; SELECT table_name FROM mysql.innodb_table_stats WHERE table_name='innodb_stats_drop_locked' FOR UPDATE; @@ -19,21 +26,23 @@ innodb_stats_drop_locked innodb_stats_drop_locked innodb_stats_drop_locked connect con1,localhost,root,,; -connection con1; ALTER TABLE innodb_stats_drop_locked DROP INDEX c_key; -Warnings: -Warning 1205 Unable to delete statistics for index c_key from mysql.innodb_index_stats because the rows are locked: Lock wait timeout. They can be deleted later using DELETE FROM mysql.innodb_index_stats WHERE database_name = 'test' AND table_name = 'innodb_stats_drop_locked' AND index_name = 'c_key'; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction SHOW CREATE TABLE innodb_stats_drop_locked; Table Create Table innodb_stats_drop_locked CREATE TABLE `innodb_stats_drop_locked` ( - `c` int(11) DEFAULT NULL + `c` int(11) DEFAULT NULL, + KEY `c_key` (`c`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 STATS_PERSISTENT=1 DROP TABLE innodb_stats_drop_locked; -SHOW TABLES; -Tables_in_test -connection default; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +DROP DATABASE unlocked; +DROP DATABASE locked; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction disconnect con1; +connection default; COMMIT; +DROP DATABASE locked; SELECT table_name FROM mysql.innodb_table_stats WHERE table_name='innodb_stats_drop_locked'; table_name @@ -48,5 +57,17 @@ innodb_stats_drop_locked innodb_stats_drop_locked innodb_stats_drop_locked innodb_stats_drop_locked -DELETE FROM mysql.innodb_index_stats WHERE database_name='test' AND table_name='innodb_stats_drop_locked'; -DELETE FROM mysql.innodb_table_stats WHERE database_name='test' AND table_name='innodb_stats_drop_locked'; +ALTER TABLE innodb_stats_drop_locked DROP INDEX c_key; +SELECT table_name FROM mysql.innodb_index_stats +WHERE table_name='innodb_stats_drop_locked'; +table_name +innodb_stats_drop_locked +innodb_stats_drop_locked +innodb_stats_drop_locked +DROP TABLE innodb_stats_drop_locked; +SELECT table_name FROM mysql.innodb_table_stats +WHERE table_name='innodb_stats_drop_locked'; +table_name +SELECT table_name FROM mysql.innodb_index_stats +WHERE table_name='innodb_stats_drop_locked'; +table_name diff --git a/mysql-test/suite/innodb/r/innodb_stats_rename_table_if_exists.result b/mysql-test/suite/innodb/r/innodb_stats_rename_table_if_exists.result index 5614b4ba490..a966f629d7e 100644 --- a/mysql-test/suite/innodb/r/innodb_stats_rename_table_if_exists.result +++ b/mysql-test/suite/innodb/r/innodb_stats_rename_table_if_exists.result @@ -1,5 +1,6 @@ -CREATE TABLE stats_rename1 (a INT, PRIMARY KEY (a)) +CREATE TABLE stats_rename1 (a INT PRIMARY KEY, b INT UNIQUE) ENGINE=INNODB STATS_PERSISTENT=1; +BEGIN; INSERT INTO mysql.innodb_table_stats SELECT database_name, @@ -10,7 +11,7 @@ clustered_index_size, sum_of_other_index_sizes FROM mysql.innodb_table_stats WHERE table_name = 'stats_rename1'; -INSERT INTO mysql.innodb_index_stats +INSERT INTO mysql.innodb_index_stats SELECT database_name, 'stats_rename2' AS table_name, @@ -22,6 +23,7 @@ sample_size, stat_description FROM mysql.innodb_index_stats WHERE table_name = 'stats_rename1'; +COMMIT; SELECT table_name, n_rows FROM mysql.innodb_table_stats WHERE table_name IN ('stats_rename1', 'stats_rename2'); @@ -44,6 +46,18 @@ table_name stats_rename1 index_name PRIMARY stat_name size stat_value 1 +table_name stats_rename1 +index_name b +stat_name n_diff_pfx01 +stat_value 0 +table_name stats_rename1 +index_name b +stat_name n_leaf_pages +stat_value 1 +table_name stats_rename1 +index_name b +stat_name size +stat_value 1 table_name stats_rename2 index_name PRIMARY stat_name n_diff_pfx01 @@ -56,7 +70,32 @@ table_name stats_rename2 index_name PRIMARY stat_name size stat_value 567 +table_name stats_rename2 +index_name b +stat_name n_diff_pfx01 +stat_value 567 +table_name stats_rename2 +index_name b +stat_name n_leaf_pages +stat_value 567 +table_name stats_rename2 +index_name b +stat_name size +stat_value 567 RENAME TABLE stats_rename1 TO stats_rename2; +ERROR 23000: Can't write; duplicate key in table 'mysql.innodb_table_stats' +BEGIN; +DELETE FROM mysql.innodb_table_stats WHERE table_name='stats_rename2'; +DELETE FROM mysql.innodb_index_stats WHERE table_name='stats_rename2'; +COMMIT; +RENAME TABLE stats_rename1 TO stats_rename2; +UPDATE mysql.innodb_index_stats SET index_name='c' +WHERE table_name='stats_rename2' AND index_name='PRIMARY'; +ALTER TABLE stats_rename2 CHANGE b d INT, RENAME INDEX b TO c; +ERROR 23000: Can't write; duplicate key in table 'mysql.innodb_index_stats' +UPDATE mysql.innodb_index_stats SET index_name='PRIMARY' +WHERE table_name='stats_rename2' AND index_name='c'; +ALTER TABLE stats_rename2 CHANGE b d INT, RENAME INDEX b TO c; SELECT table_name, n_rows FROM mysql.innodb_table_stats WHERE table_name IN ('stats_rename1', 'stats_rename2'); @@ -77,4 +116,16 @@ table_name stats_rename2 index_name PRIMARY stat_name size stat_value 1 +table_name stats_rename2 +index_name c +stat_name n_diff_pfx01 +stat_value 0 +table_name stats_rename2 +index_name c +stat_name n_leaf_pages +stat_value 1 +table_name stats_rename2 +index_name c +stat_name size +stat_value 1 DROP TABLE stats_rename2; diff --git a/mysql-test/suite/innodb/r/log_file_name.result b/mysql-test/suite/innodb/r/log_file_name.result index 8a22615eae0..766122959ab 100644 --- a/mysql-test/suite/innodb/r/log_file_name.result +++ b/mysql-test/suite/innodb/r/log_file_name.result @@ -74,6 +74,8 @@ DROP TABLE t2,t3; CREATE TABLE t0(a INT PRIMARY KEY) ENGINE=InnoDB; ERROR HY000: Can't create table `test`.`t0` (errno: 184 "Tablespace already exists") CREATE TABLE t0(a INT PRIMARY KEY) ENGINE=InnoDB; +ERROR HY000: Can't create table `test`.`t0` (errno: 184 "Tablespace already exists") +CREATE TABLE t0(a INT PRIMARY KEY) ENGINE=InnoDB; DROP TABLE t0; CREATE TABLE u1(a INT PRIMARY KEY) ENGINE=InnoDB; CREATE TABLE u2(a INT PRIMARY KEY) ENGINE=InnoDB; diff --git a/mysql-test/suite/innodb/r/monitor.result b/mysql-test/suite/innodb/r/monitor.result index 767ed7edcc5..0b2b0049f68 100644 --- a/mysql-test/suite/innodb/r/monitor.result +++ b/mysql-test/suite/innodb/r/monitor.result @@ -194,7 +194,6 @@ innodb_master_thread_sleeps disabled innodb_activity_count disabled innodb_master_active_loops disabled innodb_master_idle_loops disabled -innodb_background_drop_table_usec disabled innodb_log_flush_usec disabled innodb_dict_lru_usec disabled innodb_dict_lru_count_active disabled @@ -211,7 +210,6 @@ dml_system_inserts disabled dml_system_deletes disabled dml_system_updates disabled ddl_background_drop_indexes disabled -ddl_background_drop_tables disabled ddl_online_create_index disabled ddl_pending_alter_table disabled ddl_sort_file_alter_table disabled diff --git a/mysql-test/suite/innodb/r/rename_table_debug.result b/mysql-test/suite/innodb/r/rename_table_debug.result deleted file mode 100644 index 48211ad0aca..00000000000 --- a/mysql-test/suite/innodb/r/rename_table_debug.result +++ /dev/null @@ -1,31 +0,0 @@ -FLUSH TABLES; -CREATE TABLE t1 (a SERIAL, b INT, c INT, d INT) ENGINE=InnoDB; -INSERT INTO t1 () VALUES (); -connect con1,localhost,root,,test; -SET DEBUG_SYNC='before_rename_table_commit SIGNAL renamed WAIT_FOR ever'; -RENAME TABLE t1 TO t2; -connection default; -SET DEBUG_SYNC='now WAIT_FOR renamed'; -# restart -disconnect con1; -SELECT * FROM t1; -a b c d -1 NULL NULL NULL -CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=InnoDB; -BEGIN; -INSERT INTO t2 VALUES(1); -connect con1,localhost,root,,test; -SET DEBUG_SYNC='innodb_rename_in_cache SIGNAL committed WAIT_FOR ever'; -RENAME TABLE t1 TO t3; -connection default; -SET DEBUG_SYNC='now WAIT_FOR committed'; -COMMIT; -# restart -disconnect con1; -SELECT * FROM t1; -a b c d -1 NULL NULL NULL -SELECT * FROM t2; -a -1 -DROP TABLE t1,t2; diff --git a/mysql-test/suite/innodb/r/truncate.result b/mysql-test/suite/innodb/r/truncate.result index e12a401017f..ae1ca0f474d 100644 --- a/mysql-test/suite/innodb/r/truncate.result +++ b/mysql-test/suite/innodb/r/truncate.result @@ -50,3 +50,13 @@ Warnings: Warning 1814 Tablespace has been discarded for table `u` TRUNCATE u; DROP TABLE u; +# +# Test for a regression found during MDEV-25506 rewrite of DROP +# +CREATE TEMPORARY TABLE t1 (a INT) ENGINE=InnoDB; +LOCK TABLE t1 READ; +TRUNCATE TABLE t1; +TRUNCATE TABLE t1; +UNLOCK TABLES; +DROP TEMPORARY TABLE t1; +# End of 10.6 tests diff --git a/mysql-test/suite/innodb/r/xa_recovery.result b/mysql-test/suite/innodb/r/xa_recovery.result index ed9f19b7eb3..f61e29be20e 100644 --- a/mysql-test/suite/innodb/r/xa_recovery.result +++ b/mysql-test/suite/innodb/r/xa_recovery.result @@ -18,8 +18,9 @@ disconnect con2; connect con1,localhost,root; SELECT * FROM t1 LOCK IN SHARE MODE; connection default; +SET innodb_lock_wait_timeout=1; DROP TABLE t2; -# restart +ERROR HY000: Lock wait timeout exceeded; try restarting transaction disconnect con1; SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; SELECT * FROM t1; @@ -30,6 +31,9 @@ SELECT * FROM t1; a 1 DROP TABLE t1; +DROP TABLE t2; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +XA ROLLBACK 'y'; +DROP TABLE t2; SET GLOBAL innodb_fast_shutdown=0; # restart -XA ROLLBACK 'y'; diff --git a/mysql-test/suite/innodb/t/default_row_format_compatibility.test b/mysql-test/suite/innodb/t/default_row_format_compatibility.test index 41abc2e67bc..d256fa7946a 100644 --- a/mysql-test/suite/innodb/t/default_row_format_compatibility.test +++ b/mysql-test/suite/innodb/t/default_row_format_compatibility.test @@ -46,16 +46,15 @@ CREATE TABLE tab(a INT) ENGINE=InnoDB; # Remove the *.ibd file ALTER TABLE tab DISCARD TABLESPACE; -# Move the *.ibd,*.cfg file into orginal location +# Move the *.ibd,*.cfg file into original location --move_file $MYSQLD_DATADIR/tab.cfg $MYSQLD_DATADIR/test/tab.cfg --move_file $MYSQLD_DATADIR/tab.ibd $MYSQLD_DATADIR/test/tab.ibd --error ER_TABLE_SCHEMA_MISMATCH ALTER TABLE tab IMPORT TABLESPACE; -# Take the backup of the ibd and cfg files ---copy_file $MYSQLD_DATADIR/test/tab.cfg $MYSQLD_DATADIR/tab.cfg ---copy_file $MYSQLD_DATADIR/test/tab.ibd $MYSQLD_DATADIR/tab.ibd +--move_file $MYSQLD_DATADIR/test/tab.cfg $MYSQLD_DATADIR/tab.cfg +--move_file $MYSQLD_DATADIR/test/tab.ibd $MYSQLD_DATADIR/tab.ibd # Cleanup DROP TABLE tab; diff --git a/mysql-test/suite/innodb/t/drop_table_background.test b/mysql-test/suite/innodb/t/drop_table_background.test deleted file mode 100644 index 20101dada84..00000000000 --- a/mysql-test/suite/innodb/t/drop_table_background.test +++ /dev/null @@ -1,48 +0,0 @@ ---source include/have_innodb.inc ---source include/have_debug.inc -# Embedded server does not support restarting ---source include/not_embedded.inc - -let $MYSQLD_DATADIR=`select @@datadir`; - -CREATE TABLE t(c0 SERIAL, c1 INT, c2 INT, c3 INT, c4 INT, -KEY(c1), KEY(c2), KEY(c2,c1), -KEY(c3), KEY(c3,c1), KEY(c3,c2), KEY(c3,c2,c1), -KEY(c4), KEY(c4,c1), KEY(c4,c2), KEY(c4,c2,c1), -KEY(c4,c3), KEY(c4,c3,c1), KEY(c4,c3,c2), KEY(c4,c3,c2,c1)) ENGINE=InnoDB; - -CREATE TABLE `#mysql50##sql-ib-foo`(a SERIAL) ENGINE=InnoDB; -INSERT INTO t (c1) VALUES (1),(2),(1); - -let $n= 10; - -SET DEBUG_DBUG='+d,row_drop_table_add_to_background'; ---disable_query_log -let $i= $n; -while ($i) { - eval CREATE TABLE t$i LIKE t; - dec $i; -} -let $i= $n; -while ($i) { - eval DROP TABLE t$i; - dec $i; -} ---enable_query_log ---error ER_DUP_ENTRY -CREATE TABLE target (PRIMARY KEY(c1)) ENGINE=InnoDB SELECT * FROM t; ---error ER_NO_SUCH_TABLE -SELECT * from target; -DROP TABLE t; ---source include/shutdown_mysqld.inc ---remove_files_wildcard $MYSQLD_DATADIR/test #sql-*.ibd ---source include/start_mysqld.inc -CREATE TABLE t (a INT) ENGINE=InnoDB; -DROP TABLE t; ---error ER_BAD_TABLE_ERROR -DROP TABLE target; -CREATE TABLE target (a INT) ENGINE=InnoDB; -DROP TABLE target; ---error ER_NO_SUCH_TABLE_IN_ENGINE -SELECT * FROM `#mysql50##sql-ib-foo`; -DROP TABLE `#mysql50##sql-ib-foo`; diff --git a/mysql-test/suite/innodb/t/innodb-wl5522-debug.test b/mysql-test/suite/innodb/t/innodb-wl5522-debug.test index 165264041fb..7256e2f23e0 100644 --- a/mysql-test/suite/innodb/t/innodb-wl5522-debug.test +++ b/mysql-test/suite/innodb/t/innodb-wl5522-debug.test @@ -1014,6 +1014,7 @@ do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl"; ib_restore_tablespaces("test", "t1"); EOF +ALTER TABLE t1 IMPORT TABLESPACE; DROP TABLE t1; # diff --git a/mysql-test/suite/innodb/t/innodb-wl5522.test b/mysql-test/suite/innodb/t/innodb-wl5522.test index 7675a1305a4..9b18b29fc20 100644 --- a/mysql-test/suite/innodb/t/innodb-wl5522.test +++ b/mysql-test/suite/innodb/t/innodb-wl5522.test @@ -96,6 +96,10 @@ if ($checksum_algorithm == "strict_full_crc32") { ALTER TABLE t2 IMPORT TABLESPACE; DROP TABLE t2; +if ($error_code) { +--remove_file $MYSQLD_DATADIR/test/t2.ibd +} + SET GLOBAL innodb_file_per_table = 1; SELECT @@innodb_file_per_table; diff --git a/mysql-test/suite/innodb/t/innodb-wl5980-alter.test b/mysql-test/suite/innodb/t/innodb-wl5980-alter.test index 1a32b94c140..f57d263fb3b 100644 --- a/mysql-test/suite/innodb/t/innodb-wl5980-alter.test +++ b/mysql-test/suite/innodb/t/innodb-wl5980-alter.test @@ -6,7 +6,7 @@ --source include/have_innodb.inc SET @innodb_file_per_table_orig=@@GLOBAL.innodb_file_per_table; -LET $regexp=/FTS_[0-9a-f_]+([A-Z0-9_]+)\.([islbd]{3})/FTS_AUX_\1.\2/ /#sql-ib[1-9][0-9]*\.ibd\n//; +LET $regexp=/FTS_[0-9a-f_]+([A-Z0-9_]+)\.([islbd]{3})/FTS_AUX_\1.\2/; # Set up some variables LET $MYSQL_DATA_DIR = `select @@datadir`; diff --git a/mysql-test/suite/innodb/t/innodb_defrag_stats.test b/mysql-test/suite/innodb/t/innodb_defrag_stats.test index 2a5026a68e5..248fd24f0c8 100644 --- a/mysql-test/suite/innodb/t/innodb_defrag_stats.test +++ b/mysql-test/suite/innodb/t/innodb_defrag_stats.test @@ -1,46 +1,26 @@ --source include/have_innodb.inc +--source include/have_sequence.inc --source include/big_test.inc --source include/not_valgrind.inc --source include/not_embedded.inc ---disable_warnings -DROP TABLE if exists t1; ---enable_warnings - ---disable_query_log -let $innodb_defragment_stats_accuracy_orig=`select @@innodb_defragment_stats_accuracy`; ---enable_query_log - select @@global.innodb_stats_persistent; set global innodb_defragment_stats_accuracy = 20; ---echo # Create table. -CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b VARCHAR(256), KEY SECOND(a, b)) ENGINE=INNODB; - ---echo # Populate data -INSERT INTO t1 VALUES(1, REPEAT('A', 256)); -INSERT INTO t1 (b) SELECT b from t1; -INSERT INTO t1 (b) SELECT b from t1; -INSERT INTO t1 (b) SELECT b from t1; -INSERT INTO t1 (b) SELECT b from t1; -INSERT INTO t1 (b) SELECT b from t1; -INSERT INTO t1 (b) SELECT b from t1; -INSERT INTO t1 (b) SELECT b from t1; -INSERT INTO t1 (b) SELECT b from t1; -INSERT INTO t1 (b) SELECT b from t1; -INSERT INTO t1 (b) SELECT b from t1; +CREATE TABLE t1(a INT PRIMARY KEY, b VARCHAR(256), KEY SECOND(a, b)) +ENGINE=INNODB; +INSERT INTO t1 SELECT seq, REPEAT('A', 256) FROM seq_1_to_1024; --echo # Not enough page splits to trigger persistent stats write yet. -select count(stat_value) = 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_page_split'); -select count(stat_value) = 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_pages_freed'); -select count(stat_value) = 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_leaf_pages_defrag'); +select * from mysql.innodb_index_stats where table_name='t1' +and stat_name in ('n_page_split','n_pages_freed,n_leaf_pages_defrag'); -INSERT INTO t1 (b) SELECT b from t1; +INSERT INTO t1 SELECT seq, REPEAT('A', 256) FROM seq_1025_to_2048; --echo # Persistent stats recorded. -select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_page_split'); -select count(stat_value) = 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_pages_freed'); -select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_leaf_pages_defrag'); +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name = 't1' and stat_name in ('n_page_split'); +select * from mysql.innodb_index_stats where table_name = 't1' and stat_name in ('n_pages_freed'); +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name = 't1' and stat_name in ('n_leaf_pages_defrag'); --echo # Delete some rows. let $num_delete = 20; @@ -55,71 +35,53 @@ while ($num_delete) --echo # Server Restarted --echo # Confirm persistent stats still there after restart. -select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_page_split'); -select count(stat_value) = 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_pages_freed'); -select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_leaf_pages_defrag'); +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name = 't1' and stat_name in ('n_page_split'); +select * from mysql.innodb_index_stats where table_name = 't1' and stat_name in ('n_pages_freed'); +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name = 't1' and stat_name in ('n_leaf_pages_defrag'); optimize table t1; select sleep(2); -select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_page_split'); -select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_pages_freed'); -select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_leaf_pages_defrag'); +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name = 't1' and stat_name in ('n_page_split'); +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name = 't1' and stat_name in ('n_pages_freed'); +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name = 't1' and stat_name in ('n_leaf_pages_defrag'); set global innodb_defragment_stats_accuracy = 40; -INSERT INTO t1 (b) SELECT b from t1; +INSERT INTO t1 SELECT seq, REPEAT('A', 256) FROM seq_2049_to_4096; -select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_page_split'); -select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_pages_freed'); -select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_leaf_pages_defrag'); +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name = 't1' and stat_name in ('n_page_split'); +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name = 't1' and stat_name in ('n_pages_freed'); +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name = 't1' and stat_name in ('n_leaf_pages_defrag'); +INSERT INTO t1 SELECT seq, REPEAT('A', 256) FROM seq_4097_to_8192; -INSERT INTO t1 (b) SELECT b from t1; - -select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_page_split'); -select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_pages_freed'); -select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_leaf_pages_defrag'); +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name = 't1' and stat_name in ('n_page_split'); +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name = 't1' and stat_name in ('n_pages_freed'); +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name = 't1' and stat_name in ('n_leaf_pages_defrag'); --echo # Table rename should cause stats rename. rename table t1 to t2; -select sleep(1); +select * from mysql.innodb_index_stats where table_name = 't1'; -select count(stat_value) = 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_page_split'); -select count(stat_value) = 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_pages_freed'); -select count(stat_value) = 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_leaf_pages_defrag'); - -select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t2%' and stat_name in ('n_page_split'); -select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t2%' and stat_name in ('n_pages_freed'); -select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t2%' and stat_name in ('n_leaf_pages_defrag'); +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name = 't2' and stat_name in ('n_page_split'); +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name = 't2' and stat_name in ('n_pages_freed'); +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name = 't2' and stat_name in ('n_leaf_pages_defrag'); --echo # Drop index should cause stats drop. drop index SECOND on t2; -select sleep(3); -select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t2%' and index_name = 'SECOND' and stat_name in ('n_page_split'); -select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t2%' and index_name = 'SECOND' and stat_name in ('n_pages_freed'); -select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t2%' and index_name = 'SECOND' and stat_name in ('n_leaf_pages_defrag'); +select * from mysql.innodb_index_stats where table_name = 't2' and index_name = 'SECOND'; --source include/restart_mysqld.inc --echo Server Restarted -select count(stat_value) = 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_page_split'); -select count(stat_value) = 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_pages_freed'); -select count(stat_value) = 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name in ('n_leaf_pages_defrag'); - -select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t2%' and stat_name in ('n_page_split'); -select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t2%' and stat_name in ('n_pages_freed'); -select count(stat_value) > 0 from mysql.innodb_index_stats where table_name like '%t2%' and stat_name in ('n_leaf_pages_defrag'); +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name = 't2' and stat_name in ('n_page_split'); +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name = 't2' and stat_name in ('n_pages_freed'); +select count(stat_value) > 0 from mysql.innodb_index_stats where table_name = 't2' and stat_name in ('n_leaf_pages_defrag'); --echo # Clean up DROP TABLE t2; -select count(stat_value) = 0 from mysql.innodb_index_stats where table_name like '%t2%' and stat_name in ('n_page_split'); -select count(stat_value) = 0 from mysql.innodb_index_stats where table_name like '%t2%' and stat_name in ('n_pages_freed'); -select count(stat_value) = 0 from mysql.innodb_index_stats where table_name like '%t2%' and stat_name in ('n_leaf_pages_defrag'); - ---disable_query_log -EVAL SET GLOBAL innodb_defragment_stats_accuracy = $innodb_defragment_stats_accuracy_orig; ---enable_query_log +select * from mysql.innodb_index_stats where table_name = 't2'; diff --git a/mysql-test/suite/innodb/t/innodb_stats_drop_locked.test b/mysql-test/suite/innodb/t/innodb_stats_drop_locked.test index 07c77299451..ab4cc78b337 100644 --- a/mysql-test/suite/innodb/t/innodb_stats_drop_locked.test +++ b/mysql-test/suite/innodb/t/innodb_stats_drop_locked.test @@ -5,49 +5,42 @@ -- source include/have_innodb.inc --- disable_warnings --- disable_query_log - -DROP TABLE IF EXISTS innodb_stats_drop_locked; +CREATE DATABASE unlocked; +CREATE TABLE unlocked.t1(a INT PRIMARY KEY) ENGINE=INNODB STATS_PERSISTENT=0; +CREATE DATABASE locked; +CREATE TABLE locked.t1(a INT PRIMARY KEY) ENGINE=INNODB STATS_PERSISTENT=1; CREATE TABLE innodb_stats_drop_locked (c INT, KEY c_key (c)) ENGINE=INNODB STATS_PERSISTENT=1; - ANALYZE TABLE innodb_stats_drop_locked; --- enable_warnings --- enable_query_log - -SET autocommit=0; - +BEGIN; SELECT table_name FROM mysql.innodb_table_stats WHERE table_name='innodb_stats_drop_locked' FOR UPDATE; - SELECT table_name FROM mysql.innodb_index_stats WHERE table_name='innodb_stats_drop_locked' FOR UPDATE; -- connect (con1,localhost,root,,) - --- connection con1 - +--error ER_LOCK_WAIT_TIMEOUT ALTER TABLE innodb_stats_drop_locked DROP INDEX c_key; # the index should be gone SHOW CREATE TABLE innodb_stats_drop_locked; +--error ER_LOCK_WAIT_TIMEOUT DROP TABLE innodb_stats_drop_locked; -# the table should be gone -SHOW TABLES; - --- connection default - +DROP DATABASE unlocked; +--error ER_LOCK_WAIT_TIMEOUT +DROP DATABASE locked; -- disconnect con1 - +-- connection default COMMIT; +DROP DATABASE locked; + # the stats should be there SELECT table_name FROM mysql.innodb_table_stats @@ -56,8 +49,15 @@ WHERE table_name='innodb_stats_drop_locked'; SELECT table_name FROM mysql.innodb_index_stats WHERE table_name='innodb_stats_drop_locked'; -DELETE FROM mysql.innodb_index_stats WHERE database_name='test' AND table_name='innodb_stats_drop_locked'; -DELETE FROM mysql.innodb_table_stats WHERE database_name='test' AND table_name='innodb_stats_drop_locked'; ---disable_query_log -call mtr.add_suppression("Unable to delete statistics for table test.innodb_stats_drop_locked: Lock wait timeout. They can be deleted later using DELETE FROM mysql.innodb_index_stats WHERE database_name"); ---enable_query_log +ALTER TABLE innodb_stats_drop_locked DROP INDEX c_key; + +SELECT table_name FROM mysql.innodb_index_stats +WHERE table_name='innodb_stats_drop_locked'; + +DROP TABLE innodb_stats_drop_locked; + +SELECT table_name FROM mysql.innodb_table_stats +WHERE table_name='innodb_stats_drop_locked'; + +SELECT table_name FROM mysql.innodb_index_stats +WHERE table_name='innodb_stats_drop_locked'; diff --git a/mysql-test/suite/innodb/t/innodb_stats_rename_table_if_exists.test b/mysql-test/suite/innodb/t/innodb_stats_rename_table_if_exists.test index e5b5d1814c0..3f0b5c03b3d 100644 --- a/mysql-test/suite/innodb/t/innodb_stats_rename_table_if_exists.test +++ b/mysql-test/suite/innodb/t/innodb_stats_rename_table_if_exists.test @@ -10,9 +10,10 @@ -- vertical_results -CREATE TABLE stats_rename1 (a INT, PRIMARY KEY (a)) +CREATE TABLE stats_rename1 (a INT PRIMARY KEY, b INT UNIQUE) ENGINE=INNODB STATS_PERSISTENT=1; +BEGIN; INSERT INTO mysql.innodb_table_stats SELECT database_name, @@ -24,7 +25,7 @@ sum_of_other_index_sizes FROM mysql.innodb_table_stats WHERE table_name = 'stats_rename1'; -INSERT INTO mysql.innodb_index_stats +INSERT INTO mysql.innodb_index_stats SELECT database_name, 'stats_rename2' AS table_name, @@ -36,6 +37,7 @@ sample_size, stat_description FROM mysql.innodb_index_stats WHERE table_name = 'stats_rename1'; +COMMIT; SELECT table_name, n_rows FROM mysql.innodb_table_stats @@ -45,7 +47,22 @@ SELECT table_name, index_name, stat_name, stat_value FROM mysql.innodb_index_stats WHERE table_name IN ('stats_rename1', 'stats_rename2'); +--error ER_DUP_KEY RENAME TABLE stats_rename1 TO stats_rename2; +BEGIN; +DELETE FROM mysql.innodb_table_stats WHERE table_name='stats_rename2'; +DELETE FROM mysql.innodb_index_stats WHERE table_name='stats_rename2'; +COMMIT; +RENAME TABLE stats_rename1 TO stats_rename2; + +UPDATE mysql.innodb_index_stats SET index_name='c' +WHERE table_name='stats_rename2' AND index_name='PRIMARY'; +--error ER_DUP_KEY +ALTER TABLE stats_rename2 CHANGE b d INT, RENAME INDEX b TO c; +UPDATE mysql.innodb_index_stats SET index_name='PRIMARY' +WHERE table_name='stats_rename2' AND index_name='c'; + +ALTER TABLE stats_rename2 CHANGE b d INT, RENAME INDEX b TO c; SELECT table_name, n_rows FROM mysql.innodb_table_stats diff --git a/mysql-test/suite/innodb/t/instant_alter_import.test b/mysql-test/suite/innodb/t/instant_alter_import.test index fb187debb51..208bc423a11 100644 --- a/mysql-test/suite/innodb/t/instant_alter_import.test +++ b/mysql-test/suite/innodb/t/instant_alter_import.test @@ -79,6 +79,7 @@ select * from t1; alter table t1 import tablespace; --error ER_TABLESPACE_DISCARDED select * from t1; +--remove_file $MYSQLD_DATADIR/test/t1.ibd drop table t2; drop table t1; diff --git a/mysql-test/suite/innodb/t/log_file_name.test b/mysql-test/suite/innodb/t/log_file_name.test index 534c4e6984f..2a7ed7b494d 100644 --- a/mysql-test/suite/innodb/t/log_file_name.test +++ b/mysql-test/suite/innodb/t/log_file_name.test @@ -137,7 +137,9 @@ DROP TABLE t2,t3; --error ER_CANT_CREATE_TABLE CREATE TABLE t0(a INT PRIMARY KEY) ENGINE=InnoDB; - +--error ER_CANT_CREATE_TABLE +CREATE TABLE t0(a INT PRIMARY KEY) ENGINE=InnoDB; +--remove_file $MYSQLD_DATADIR/test/t0.ibd CREATE TABLE t0(a INT PRIMARY KEY) ENGINE=InnoDB; DROP TABLE t0; diff --git a/mysql-test/suite/innodb/t/rename_table_debug.test b/mysql-test/suite/innodb/t/rename_table_debug.test deleted file mode 100644 index 3e2de242d49..00000000000 --- a/mysql-test/suite/innodb/t/rename_table_debug.test +++ /dev/null @@ -1,41 +0,0 @@ ---source include/have_innodb.inc ---source include/have_debug.inc ---source include/have_debug_sync.inc ---source include/not_embedded.inc - -FLUSH TABLES; -LET $datadir= `SELECT @@datadir`; - -CREATE TABLE t1 (a SERIAL, b INT, c INT, d INT) ENGINE=InnoDB; -INSERT INTO t1 () VALUES (); - ---connect (con1,localhost,root,,test) -SET DEBUG_SYNC='before_rename_table_commit SIGNAL renamed WAIT_FOR ever'; ---send -RENAME TABLE t1 TO t2; ---connection default -SET DEBUG_SYNC='now WAIT_FOR renamed'; ---let $shutdown_timeout=0 ---source include/restart_mysqld.inc ---disconnect con1 -SELECT * FROM t1; - -CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=InnoDB; -BEGIN; -INSERT INTO t2 VALUES(1); - ---connect (con1,localhost,root,,test) -SET DEBUG_SYNC='innodb_rename_in_cache SIGNAL committed WAIT_FOR ever'; ---send -RENAME TABLE t1 TO t3; ---connection default -SET DEBUG_SYNC='now WAIT_FOR committed'; -COMMIT; - ---let $shutdown_timeout=0 ---source include/restart_mysqld.inc ---disconnect con1 -SELECT * FROM t1; -SELECT * FROM t2; - -DROP TABLE t1,t2; diff --git a/mysql-test/suite/innodb/t/table_flags.test b/mysql-test/suite/innodb/t/table_flags.test index f3a2c856af2..380052b9db6 100644 --- a/mysql-test/suite/innodb/t/table_flags.test +++ b/mysql-test/suite/innodb/t/table_flags.test @@ -1,7 +1,6 @@ --source include/innodb_page_size.inc # Embedded server tests do not support restarting --source include/not_embedded.inc ---source include/maybe_debug.inc --disable_query_log call mtr.add_suppression("InnoDB: Table `mysql`\\.`innodb_table_stats` not found"); @@ -31,9 +30,6 @@ let bugdir= $MYSQLTEST_VARDIR/tmp/table_flags; --let $d=$d --innodb-undo-tablespaces=0 --let $d=$d --innodb-purge-rseg-truncate-frequency=1 --let $d=$d --skip-innodb-fast-shutdown -if ($have_debug) { ---let $d=$d --debug=d,create_and_drop_garbage -} --let $restart_noprint=1 --let $restart_parameters=$d --innodb-stats-persistent=0 --source include/restart_mysqld.inc diff --git a/mysql-test/suite/innodb/t/truncate.test b/mysql-test/suite/innodb/t/truncate.test index dc2b2a81484..436fc01b5a1 100644 --- a/mysql-test/suite/innodb/t/truncate.test +++ b/mysql-test/suite/innodb/t/truncate.test @@ -67,3 +67,15 @@ RENAME TABLE t TO u; TRUNCATE u; TRUNCATE u; DROP TABLE u; + +--echo # +--echo # Test for a regression found during MDEV-25506 rewrite of DROP +--echo # +CREATE TEMPORARY TABLE t1 (a INT) ENGINE=InnoDB; +LOCK TABLE t1 READ; +TRUNCATE TABLE t1; +TRUNCATE TABLE t1; +UNLOCK TABLES; +DROP TEMPORARY TABLE t1; + +--echo # End of 10.6 tests diff --git a/mysql-test/suite/innodb/t/xa_recovery.test b/mysql-test/suite/innodb/t/xa_recovery.test index bb8e3316860..7a67cd8e8b7 100644 --- a/mysql-test/suite/innodb/t/xa_recovery.test +++ b/mysql-test/suite/innodb/t/xa_recovery.test @@ -39,10 +39,10 @@ let $wait_condition= info = 'SELECT * FROM t1 LOCK IN SHARE MODE'; --source include/wait_condition.inc +SET innodb_lock_wait_timeout=1; +--error ER_LOCK_WAIT_TIMEOUT DROP TABLE t2; ---source include/restart_mysqld.inc - disconnect con1; SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; @@ -51,8 +51,10 @@ XA ROLLBACK 'x'; SELECT * FROM t1; DROP TABLE t1; +--error ER_LOCK_WAIT_TIMEOUT +DROP TABLE t2; +XA ROLLBACK 'y'; +DROP TABLE t2; SET GLOBAL innodb_fast_shutdown=0; --source include/restart_mysqld.inc - -XA ROLLBACK 'y'; diff --git a/mysql-test/suite/innodb_fts/r/crash_recovery.result b/mysql-test/suite/innodb_fts/r/crash_recovery.result index 518e5007048..74287f509b7 100644 --- a/mysql-test/suite/innodb_fts/r/crash_recovery.result +++ b/mysql-test/suite/innodb_fts/r/crash_recovery.result @@ -33,6 +33,10 @@ connection default; disconnect ddl1; disconnect ddl2; disconnect ddl3; +SET @saved_frequency = @@GLOBAL.innodb_purge_rseg_truncate_frequency; +SET GLOBAL innodb_purge_rseg_truncate_frequency = 1; +InnoDB 0 transactions not purged +SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency; CHECK TABLE t1,t2,t3; Table Op Msg_type Msg_text test.t1 check status OK @@ -151,6 +155,5 @@ id title body 1 MySQL Tutorial DBMS stands for Database... 2 MariaDB Tutorial DB means Database ... DROP TABLE mdev19073, mdev19073_2; -SELECT * FROM information_schema.innodb_sys_tables -WHERE name LIKE 'test/%' AND name NOT LIKE 'test/#sql-ib%'; +SELECT * FROM information_schema.innodb_sys_tables WHERE name LIKE 'test/%'; TABLE_ID NAME FLAG N_COLS SPACE ROW_FORMAT ZIP_PAGE_SIZE SPACE_TYPE diff --git a/mysql-test/suite/innodb_fts/r/misc_debug.result b/mysql-test/suite/innodb_fts/r/misc_debug.result index 41f8d08ea7d..9143d3f48f0 100644 --- a/mysql-test/suite/innodb_fts/r/misc_debug.result +++ b/mysql-test/suite/innodb_fts/r/misc_debug.result @@ -20,12 +20,13 @@ DROP TABLE t; CREATE TABLE t1 (pk INT, a VARCHAR(8), PRIMARY KEY(pk), FULLTEXT KEY(a)) ENGINE=InnoDB; CREATE TABLE t2 (b INT, FOREIGN KEY(b) REFERENCES t1(pk)) ENGINE=InnoDB; -DROP TABLE t1; +DROP TABLE/*foo*/ t1; ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails SET DEBUG_DBUG="+d,fts_instrument_sync"; INSERT INTO t1 VALUES(1, "mariadb"); ALTER TABLE t1 FORCE; DROP TABLE t2, t1; +SET SESSION debug_dbug=@saved_debug_dbug; # # MDEV-25200 Index count mismatch due to aborted FULLTEXT INDEX # @@ -56,12 +57,10 @@ DROP TABLE t1; # MDEV-25663 Double free of transaction during TRUNCATE # call mtr.add_suppression("InnoDB: \\(Too many concurrent transactions\\)"); -SET DEBUG_DBUG='-d,ib_create_table_fail_too_many_trx'; CREATE TABLE t1 (b CHAR(12), FULLTEXT KEY(b)) engine=InnoDB; -SET @save_dbug= @@debug_dbug; SET debug_dbug='+d,ib_create_table_fail_too_many_trx'; TRUNCATE t1; ERROR HY000: Got error -1 "Internal error < 0 (Not system error)" from storage engine InnoDB -SET debug_dbug=@save_dbug; +SET debug_dbug=@saved_debug_dbug; DROP TABLE t1; # End of 10.3 tests diff --git a/mysql-test/suite/innodb_fts/t/crash_recovery.test b/mysql-test/suite/innodb_fts/t/crash_recovery.test index d5518b91590..229f5affe87 100644 --- a/mysql-test/suite/innodb_fts/t/crash_recovery.test +++ b/mysql-test/suite/innodb_fts/t/crash_recovery.test @@ -100,6 +100,14 @@ disconnect ddl1; disconnect ddl2; disconnect ddl3; +# Ensure that the history list length will actually be decremented by purge. +SET @saved_frequency = @@GLOBAL.innodb_purge_rseg_truncate_frequency; +SET GLOBAL innodb_purge_rseg_truncate_frequency = 1; +# Wait for purge, so that any #sql-ib.ibd files from the previous kill +# will be deleted. +source ../../innodb/include/wait_all_purged.inc; +SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency; + CHECK TABLE t1,t2,t3; DROP TABLE t1,t2,t3; @@ -245,17 +253,4 @@ SELECT * FROM mdev19073_2 WHERE MATCH (title, body) AGAINST ('Database' IN NATURAL LANGUAGE MODE); DROP TABLE mdev19073, mdev19073_2; -if (!$have_debug) -{ ---disable_query_log -# Some errors are reported despite the MDEV-24626 fix. -call mtr.add_suppression("InnoDB: Cannot (read first page of|open datafile for read-only:) '\\./test/(FTS_|#sql-(alter|backup)-).*\\.ibd'"); -call mtr.add_suppression("InnoDB: Datafile '\\./test/(FTS_|#sql-(alter|backup)-).*\\.ibd' is corrupted"); -call mtr.add_suppression("InnoDB: (The error means|Operating system error)"); -call mtr.add_suppression("InnoDB: Ignoring tablespace for test/(FTS_|#sql-(backup|alter)-).* because it could not be opened\\."); -call mtr.add_suppression("InnoDB: Expected tablespace id [1-9][0-9]* but found 0 in the file .*/test/(FTS_|#sql-(alter|backup)-).*\\.ibd"); ---enable_query_log -} - -SELECT * FROM information_schema.innodb_sys_tables -WHERE name LIKE 'test/%' AND name NOT LIKE 'test/#sql-ib%'; +SELECT * FROM information_schema.innodb_sys_tables WHERE name LIKE 'test/%'; diff --git a/mysql-test/suite/innodb_fts/t/misc_debug.test b/mysql-test/suite/innodb_fts/t/misc_debug.test index 90cb84976ce..b9b0f54e3e8 100644 --- a/mysql-test/suite/innodb_fts/t/misc_debug.test +++ b/mysql-test/suite/innodb_fts/t/misc_debug.test @@ -48,12 +48,13 @@ CREATE TABLE t1 (pk INT, a VARCHAR(8), PRIMARY KEY(pk), FULLTEXT KEY(a)) ENGINE=InnoDB; CREATE TABLE t2 (b INT, FOREIGN KEY(b) REFERENCES t1(pk)) ENGINE=InnoDB; --error ER_ROW_IS_REFERENCED_2 -DROP TABLE t1; +DROP TABLE/*foo*/ t1; SET DEBUG_DBUG="+d,fts_instrument_sync"; INSERT INTO t1 VALUES(1, "mariadb"); ALTER TABLE t1 FORCE; # Cleanup DROP TABLE t2, t1; +SET SESSION debug_dbug=@saved_debug_dbug; --echo # --echo # MDEV-25200 Index count mismatch due to aborted FULLTEXT INDEX @@ -88,13 +89,11 @@ DROP TABLE t1; --echo # MDEV-25663 Double free of transaction during TRUNCATE --echo # call mtr.add_suppression("InnoDB: \\(Too many concurrent transactions\\)"); -SET DEBUG_DBUG='-d,ib_create_table_fail_too_many_trx'; CREATE TABLE t1 (b CHAR(12), FULLTEXT KEY(b)) engine=InnoDB; -SET @save_dbug= @@debug_dbug; SET debug_dbug='+d,ib_create_table_fail_too_many_trx'; --error ER_GET_ERRNO TRUNCATE t1; -SET debug_dbug=@save_dbug; +SET debug_dbug=@saved_debug_dbug; DROP TABLE t1; --echo # End of 10.3 tests diff --git a/mysql-test/suite/innodb_zip/r/wl5522_debug_zip.result b/mysql-test/suite/innodb_zip/r/wl5522_debug_zip.result index 8708f26a653..7221358efee 100644 --- a/mysql-test/suite/innodb_zip/r/wl5522_debug_zip.result +++ b/mysql-test/suite/innodb_zip/r/wl5522_debug_zip.result @@ -111,6 +111,7 @@ ALTER TABLE t1 IMPORT TABLESPACE; ERROR HY000: Index for table 't1' is corrupt; try to repair it SET SESSION debug_dbug=@saved_debug_dbug; restore: t1 .ibd and .cfg files +ALTER TABLE t1 IMPORT TABLESPACE; DROP TABLE t1; CREATE TABLE t1 ( c1 BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, diff --git a/mysql-test/suite/innodb_zip/t/restart.test b/mysql-test/suite/innodb_zip/t/restart.test index c01b4071b6c..baef95a66d3 100644 --- a/mysql-test/suite/innodb_zip/t/restart.test +++ b/mysql-test/suite/innodb_zip/t/restart.test @@ -162,11 +162,8 @@ SELECT count(*) FROM t7_restart; --echo # --source include/shutdown_mysqld.inc ---let $regexp=/#sql-ib[0-9a-f]+\.ibd\n// - --echo ---- MYSQL_DATA_DIR/test --list_files_write_file $MYSQLD_DATADIR.files.txt $MYSQL_DATA_DIR/test ---replace_regex $regexp --replace_result #P# #p# #SP# #sp# --cat_file $MYSQLD_DATADIR.files.txt --remove_file $MYSQLD_DATADIR.files.txt @@ -174,7 +171,6 @@ SELECT count(*) FROM t7_restart; --list_files $MYSQL_TMP_DIR/alt_dir --echo ---- MYSQL_TMP_DIR/alt_dir/test --list_files_write_file $MYSQLD_DATADIR.files.txt $MYSQL_TMP_DIR/alt_dir/test ---replace_regex $regexp --replace_result #P# #p# #SP# #sp# --cat_file $MYSQLD_DATADIR.files.txt --remove_file $MYSQLD_DATADIR.files.txt @@ -263,13 +259,11 @@ SHOW CREATE TABLE t7_restart; --echo ---- MYSQL_DATA_DIR/test --list_files_write_file $MYSQLD_DATADIR.files.txt $MYSQL_DATA_DIR/test ---replace_regex $regexp --replace_result #P# #p# #SP# #sp# --cat_file $MYSQLD_DATADIR.files.txt --remove_file $MYSQLD_DATADIR.files.txt --echo ---- MYSQL_TMP_DIR/alt_dir/test --list_files_write_file $MYSQLD_DATADIR.files.txt $MYSQL_TMP_DIR/alt_dir/test ---replace_regex $regexp --replace_result #P# #p# #SP# #sp# --cat_file $MYSQLD_DATADIR.files.txt --remove_file $MYSQLD_DATADIR.files.txt @@ -320,13 +314,11 @@ RENAME TABLE t5_restart TO t55_restart; --echo ---- MYSQL_DATA_DIR/test --list_files_write_file $MYSQLD_DATADIR.files.txt $MYSQL_DATA_DIR/test ---replace_regex $regexp --replace_result #P# #p# #SP# #sp# --cat_file $MYSQLD_DATADIR.files.txt --remove_file $MYSQLD_DATADIR.files.txt --echo ---- MYSQL_TMP_DIR/alt_dir/test --list_files_write_file $MYSQLD_DATADIR.files.txt $MYSQL_TMP_DIR/alt_dir/test ---replace_regex $regexp --replace_result #P# #p# #SP# #sp# --cat_file $MYSQLD_DATADIR.files.txt --remove_file $MYSQLD_DATADIR.files.txt @@ -358,13 +350,11 @@ SHOW CREATE TABLE t77_restart; --echo ---- MYSQL_DATA_DIR/test --list_files_write_file $MYSQLD_DATADIR.files.txt $MYSQL_DATA_DIR/test ---replace_regex $regexp --replace_result #P# #p# #SP# #sp# --cat_file $MYSQLD_DATADIR.files.txt --remove_file $MYSQLD_DATADIR.files.txt --echo ---- MYSQL_TMP_DIR/alt_dir/test --list_files_write_file $MYSQLD_DATADIR.files.txt $MYSQL_TMP_DIR/alt_dir/test ---replace_regex $regexp --replace_result #P# #p# #SP# #sp# --cat_file $MYSQLD_DATADIR.files.txt --remove_file $MYSQLD_DATADIR.files.txt @@ -404,19 +394,16 @@ SHOW CREATE TABLE t77_restart; --mkdir $MYSQL_TMP_DIR/new_dir/test --echo ---- MYSQL_DATA_DIR/test --list_files_write_file $MYSQLD_DATADIR.files.txt $MYSQL_DATA_DIR/test ---replace_regex $regexp --replace_result #P# #p# #SP# #sp# --cat_file $MYSQLD_DATADIR.files.txt --remove_file $MYSQLD_DATADIR.files.txt --echo ---- MYSQL_TMP_DIR/alt_dir/test --list_files_write_file $MYSQLD_DATADIR.files.txt $MYSQL_TMP_DIR/alt_dir/test ---replace_regex $regexp --replace_result #P# #p# #SP# #sp# --cat_file $MYSQLD_DATADIR.files.txt --remove_file $MYSQLD_DATADIR.files.txt --echo ---- MYSQL_TMP_DIR/new_dir/test --list_files_write_file $MYSQLD_DATADIR.files.txt $MYSQL_TMP_DIR/new_dir/test ---replace_regex $regexp --replace_result #P# #p# #SP# #sp# --cat_file $MYSQLD_DATADIR.files.txt --remove_file $MYSQLD_DATADIR.files.txt @@ -466,19 +453,16 @@ SHOW CREATE TABLE t77_restart; --echo ---- MYSQL_DATA_DIR/test --list_files_write_file $MYSQLD_DATADIR.files.txt $MYSQL_DATA_DIR/test ---replace_regex $regexp --replace_result #P# #p# #SP# #sp# --cat_file $MYSQLD_DATADIR.files.txt --remove_file $MYSQLD_DATADIR.files.txt --echo ---- MYSQL_TMP_DIR/alt_dir/test --list_files_write_file $MYSQLD_DATADIR.files.txt $MYSQL_TMP_DIR/alt_dir/test ---replace_regex $regexp --replace_result #P# #p# #SP# #sp# --cat_file $MYSQLD_DATADIR.files.txt --remove_file $MYSQLD_DATADIR.files.txt --echo ---- MYSQL_TMP_DIR/new_dir/test --list_files_write_file $MYSQLD_DATADIR.files.txt $MYSQL_TMP_DIR/new_dir/test ---replace_regex $regexp --replace_result #P# #p# #SP# #sp# --cat_file $MYSQLD_DATADIR.files.txt --remove_file $MYSQLD_DATADIR.files.txt @@ -522,13 +506,11 @@ SHOW CREATE TABLE t77_restart; --echo ---- MYSQL_DATA_DIR/test --list_files_write_file $MYSQLD_DATADIR.files.txt $MYSQL_DATA_DIR/test ---replace_regex $regexp --replace_result #P# #p# #SP# #sp# --cat_file $MYSQLD_DATADIR.files.txt --remove_file $MYSQLD_DATADIR.files.txt --echo ---- MYSQL_TMP_DIR/new_dir/test --list_files_write_file $MYSQLD_DATADIR.files.txt $MYSQL_TMP_DIR/new_dir/test ---replace_regex $regexp --replace_result #P# #p# #SP# #sp# --cat_file $MYSQLD_DATADIR.files.txt --remove_file $MYSQLD_DATADIR.files.txt @@ -570,13 +552,11 @@ SHOW CREATE TABLE t77_restart; --echo ---- MYSQL_DATA_DIR/test --list_files_write_file $MYSQLD_DATADIR.files.txt $MYSQL_DATA_DIR/test ---replace_regex $regexp --replace_result #P# #p# #SP# #sp# --cat_file $MYSQLD_DATADIR.files.txt --remove_file $MYSQLD_DATADIR.files.txt --echo ---- MYSQL_TMP_DIR/new_dir/test --list_files_write_file $MYSQLD_DATADIR.files.txt $MYSQL_TMP_DIR/new_dir/test ---replace_regex $regexp --replace_result #P# #p# #SP# #sp# --cat_file $MYSQLD_DATADIR.files.txt --remove_file $MYSQLD_DATADIR.files.txt diff --git a/mysql-test/suite/innodb_zip/t/wl5522_debug_zip.test b/mysql-test/suite/innodb_zip/t/wl5522_debug_zip.test index 0c9bcb6cf9d..42f76a78ed9 100644 --- a/mysql-test/suite/innodb_zip/t/wl5522_debug_zip.test +++ b/mysql-test/suite/innodb_zip/t/wl5522_debug_zip.test @@ -280,6 +280,7 @@ do "$ENV{MTR_SUITE_DIR}/../innodb/include/innodb-util.pl"; ib_restore_tablespaces("test", "t1"); EOF +ALTER TABLE t1 IMPORT TABLESPACE; DROP TABLE t1; # diff --git a/mysql-test/suite/parts/inc/partition_crash.inc b/mysql-test/suite/parts/inc/partition_crash.inc index 32bf5c10423..c657ba880c9 100644 --- a/mysql-test/suite/parts/inc/partition_crash.inc +++ b/mysql-test/suite/parts/inc/partition_crash.inc @@ -6,7 +6,6 @@ --list_files_write_file $DATADIR.files.txt $DATADIR/test --replace_result #p# #P# #sp# #SP# ---replace_regex /#sql-ib[1-9][0-9]*\.ibd\n// --cat_file $DATADIR.files.txt --remove_file $DATADIR.files.txt SHOW CREATE TABLE t1; @@ -20,7 +19,7 @@ SELECT * FROM t1; --echo # State after crash (before recovery) --list_files_write_file $DATADIR.files.txt $DATADIR/test --replace_result #p# #P# #sp# #SP# #tmp# #TMP# ---replace_regex /sql-exchange.*\./sql-exchange./ /sql-shadow-[0-9a-f]*-/sql-shadow-/ /#sql-ib[1-9][0-9]*\.ibd\n// +--replace_regex /sql-exchange.*\./sql-exchange./ /sql-shadow-[0-9a-f]*-/sql-shadow-/ --cat_file $DATADIR.files.txt --remove_file $DATADIR.files.txt --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect @@ -29,7 +28,6 @@ SELECT * FROM t1; --echo # State after crash recovery --list_files_write_file $DATADIR.files.txt $DATADIR/test --replace_result #p# #P# #sp# #SP# ---replace_regex /#sql-ib[1-9][0-9]*\.ibd\n// --cat_file $DATADIR.files.txt --remove_file $DATADIR.files.txt SHOW CREATE TABLE t1; diff --git a/mysql-test/suite/parts/t/partition_basic_symlink_innodb.test b/mysql-test/suite/parts/t/partition_basic_symlink_innodb.test index e6b2f4300cc..c0e3c21a12d 100644 --- a/mysql-test/suite/parts/t/partition_basic_symlink_innodb.test +++ b/mysql-test/suite/parts/t/partition_basic_symlink_innodb.test @@ -93,17 +93,9 @@ SHOW WARNINGS; --echo # Verifying .frm, .par, .isl & .ibd files --echo ---- MYSQLD_DATADIR/test ---let $regexp=/#sql-ib[0-9a-f]+\.ibd\n// ---list_files_write_file $MYSQLD_DATADIR.files.txt $MYSQLD_DATADIR/test ---replace_regex $regexp ---cat_file $MYSQLD_DATADIR.files.txt ---remove_file $MYSQLD_DATADIR.files.txt +--list_files $MYSQLD_DATADIR/test --echo ---- MYSQLTEST_VARDIR/mysql-test-data-dir/test ---let $regexp=/#sql-ib[0-9a-f]+\.ibd\n// ---list_files_write_file $MYSQLTEST_VARDIR/files.txt $MYSQLTEST_VARDIR/mysql-test-data-dir/test ---replace_regex $regexp ---cat_file $MYSQLTEST_VARDIR/files.txt ---remove_file $MYSQLTEST_VARDIR/files.txt +--list_files $MYSQLTEST_VARDIR/mysql-test-data-dir/test --echo # The ibd tablespaces should not be directly under the DATA DIRECTORY --echo ---- MYSQLTEST_VARDIR/mysql-test-data-dir --list_files $MYSQLTEST_VARDIR/mysql-test-data-dir @@ -122,11 +114,7 @@ ALTER TABLE t1 engine=MyISAM; --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR SHOW CREATE TABLE t1; --echo # Verifying .frm, .par and MyISAM files (.MYD, MYI) ---let $regexp=/#sql-ib[0-9a-f]+\.ibd\n// ---list_files_write_file $MYSQLD_DATADIR.files.txt $MYSQLD_DATADIR/test ---replace_regex $regexp ---cat_file $MYSQLD_DATADIR.files.txt ---remove_file $MYSQLD_DATADIR.files.txt +--list_files $MYSQLD_DATADIR/test --echo ---- MYSQLTEST_VARDIR/mysql-test-data-dir --list_files $MYSQLTEST_VARDIR/mysql-test-data-dir --echo ---- MYSQLTEST_VARDIR/mysql-test-idx-dir @@ -142,21 +130,13 @@ ALTER TABLE t1 engine=InnoDB; SHOW CREATE TABLE t1; --echo # Verifying .frm, .par, .isl and InnoDB .ibd files --echo ---- MYSQLD_DATADIR/test ---let $regexp=/#sql-ib[0-9a-f]+\.ibd\n// ---list_files_write_file $MYSQLD_DATADIR.files.txt $MYSQLD_DATADIR/test ---replace_regex $regexp ---cat_file $MYSQLD_DATADIR.files.txt ---remove_file $MYSQLD_DATADIR.files.txt +--list_files $MYSQLD_DATADIR/test --echo ---- MYSQLTEST_VARDIR/mysql-test-data-dir --list_files $MYSQLTEST_VARDIR/mysql-test-data-dir --echo ---- MYSQLTEST_VARDIR/mysql-test-idx-dir --list_files $MYSQLTEST_VARDIR/mysql-test-idx-dir --echo ---- MYSQLTEST_VARDIR/mysql-test-data-dir/test ---let $regexp=/#sql-ib[0-9a-f]+\.ibd\n// ---list_files_write_file $MYSQLTEST_VARDIR/files.txt $MYSQLTEST_VARDIR/mysql-test-data-dir/test ---replace_regex $regexp ---cat_file $MYSQLTEST_VARDIR/files.txt ---remove_file $MYSQLTEST_VARDIR/files.txt +--list_files $MYSQLTEST_VARDIR/mysql-test-data-dir/test DROP TABLE t1; diff --git a/mysql-test/suite/parts/t/partition_debug_sync_innodb.test b/mysql-test/suite/parts/t/partition_debug_sync_innodb.test index 61eb48faa11..d73333c3b8d 100644 --- a/mysql-test/suite/parts/t/partition_debug_sync_innodb.test +++ b/mysql-test/suite/parts/t/partition_debug_sync_innodb.test @@ -52,11 +52,7 @@ insert into t1 values (1), (11), (21), (33); SELECT * FROM t1; SHOW CREATE TABLE t1; --replace_result #p# #P# #sp# #SP# ---let $regexp=/#sql-ib[0-9a-f]+\.ibd\n// ---list_files_write_file $MYSQLD_DATADIR.files.txt $MYSQLD_DATADIR/test ---replace_regex $regexp ---cat_file $MYSQLD_DATADIR.files.txt ---remove_file $MYSQLD_DATADIR.files.txt +--list_files $MYSQLD_DATADIR/test SET DEBUG_SYNC='before_open_in_get_all_tables SIGNAL parked WAIT_FOR open'; SET DEBUG_SYNC='partition_open_error SIGNAL alter WAIT_FOR finish'; diff --git a/mysql-test/suite/sys_vars/r/sysvars_innodb.result b/mysql-test/suite/sys_vars/r/sysvars_innodb.result index ad359c29ee1..1a88710de94 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_innodb.result +++ b/mysql-test/suite/sys_vars/r/sysvars_innodb.result @@ -81,18 +81,6 @@ NUMERIC_BLOCK_SIZE 0 ENUM_VALUE_LIST NULL READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED -VARIABLE_NAME INNODB_BACKGROUND_DROP_LIST_EMPTY -SESSION_VALUE NULL -DEFAULT_VALUE OFF -VARIABLE_SCOPE GLOBAL -VARIABLE_TYPE BOOLEAN -VARIABLE_COMMENT Wait for the background drop list to become empty -NUMERIC_MIN_VALUE NULL -NUMERIC_MAX_VALUE NULL -NUMERIC_BLOCK_SIZE NULL -ENUM_VALUE_LIST OFF,ON -READ_ONLY NO -COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME INNODB_BUFFER_POOL_CHUNK_SIZE SESSION_VALUE NULL DEFAULT_VALUE 134217728 diff --git a/sql/handler.cc b/sql/handler.cc index dbfdae5e6d0..fc2c46395c3 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -493,7 +493,6 @@ int ha_init_errors(void) SETMSG(HA_ERR_INDEX_COL_TOO_LONG, ER_DEFAULT(ER_INDEX_COLUMN_TOO_LONG)); SETMSG(HA_ERR_INDEX_CORRUPT, ER_DEFAULT(ER_INDEX_CORRUPT)); SETMSG(HA_FTS_INVALID_DOCID, "Invalid InnoDB FTS Doc ID"); - SETMSG(HA_ERR_TABLE_IN_FK_CHECK, ER_DEFAULT(ER_TABLE_IN_FK_CHECK)); SETMSG(HA_ERR_DISK_FULL, ER_DEFAULT(ER_DISK_FULL)); SETMSG(HA_ERR_FTS_TOO_MANY_WORDS_IN_PHRASE, "Too many words in a FTS phrase or proximity search"); SETMSG(HA_ERR_FK_DEPTH_EXCEEDED, "Foreign key cascade delete/update exceeds"); @@ -4259,9 +4258,6 @@ void handler::print_error(int error, myf errflag) case HA_ERR_UNDO_REC_TOO_BIG: textno= ER_UNDO_RECORD_TOO_BIG; break; - case HA_ERR_TABLE_IN_FK_CHECK: - textno= ER_TABLE_IN_FK_CHECK; - break; default: { /* The error was "unknown" to this function. diff --git a/sql/handler.h b/sql/handler.h index 71804a4e98c..a7c455ae7c9 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -1853,11 +1853,13 @@ handlerton *ha_default_tmp_handlerton(THD *thd); */ #define HTON_REQUIRES_CLOSE_AFTER_TRUNCATE (1 << 18) +/* Truncate requires that all other handlers are closed */ +#define HTON_TRUNCATE_REQUIRES_EXCLUSIVE_USE (1 << 19) /* Used by mysql_inplace_alter_table() to decide if we should call hton->notify_tabledef_changed() before commit (MyRocks) or after (InnoDB). */ -#define HTON_REQUIRES_NOTIFY_TABLEDEF_CHANGED_AFTER_COMMIT (1 << 19) +#define HTON_REQUIRES_NOTIFY_TABLEDEF_CHANGED_AFTER_COMMIT (1 << 20) class Ha_trx_info; diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt index ed68576b5b5..205f42f50a0 100644 --- a/sql/share/errmsg-utf8.txt +++ b/sql/share/errmsg-utf8.txt @@ -6636,8 +6636,8 @@ ER_BINLOG_UNSAFE_CREATE_SELECT_AUTOINC ER_BINLOG_UNSAFE_INSERT_TWO_KEYS eng "INSERT... ON DUPLICATE KEY UPDATE on a table with more than one UNIQUE KEY is unsafe" -ER_TABLE_IN_FK_CHECK - eng "Table is being used in foreign key check" +ER_UNUSED_28 + eng "You should never see it" ER_UNUSED_1 eng "You should never see it" diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 6845fe80445..68524cbb1f2 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -2580,10 +2580,15 @@ void Locked_tables_list::mark_table_for_reopen(THD *thd, TABLE *table) { TABLE_SHARE *share= table->s; - for (TABLE_LIST *table_list= m_locked_tables; + for (TABLE_LIST *table_list= m_locked_tables; table_list; table_list= table_list->next_global) { - if (table_list->table->s == share) + /* + table_list->table can be NULL in the case of TRUNCATE TABLE where + the table was locked twice and one instance closed in + close_all_tables_for_name(). + */ + if (table_list->table && table_list->table->s == share) table_list->table->internal_set_needs_reopen(true); } /* This is needed in the case where lock tables where not used */ diff --git a/sql/sql_truncate.cc b/sql/sql_truncate.cc index 0f88a159d63..01e95d5f6b9 100644 --- a/sql/sql_truncate.cc +++ b/sql/sql_truncate.cc @@ -237,6 +237,21 @@ Sql_cmd_truncate_table::handler_truncate(THD *thd, TABLE_LIST *table_ref, DBUG_RETURN(TRUNCATE_FAILED_SKIP_BINLOG); table= table_ref->table; + + if ((table->file->ht->flags & HTON_TRUNCATE_REQUIRES_EXCLUSIVE_USE) && + !is_tmp_table) + { + if (wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN)) + DBUG_RETURN(TRUNCATE_FAILED_SKIP_BINLOG); + /* + Get rid of all TABLE instances belonging to this thread + except one to be used for TRUNCATE + */ + close_all_tables_for_name(thd, table->s, + HA_EXTRA_NOT_USED, + table); + } + error= table->file->ha_truncate(); if (!is_tmp_table && !error) @@ -366,8 +381,8 @@ bool Sql_cmd_truncate_table::lock_table(THD *thd, TABLE_LIST *table_ref, } } - *hton_can_recreate= !sequence - && ha_check_storage_engine_flag(hton, HTON_CAN_RECREATE); + *hton_can_recreate= (!sequence && + ha_check_storage_engine_flag(hton, HTON_CAN_RECREATE)); if (versioned) { @@ -496,10 +511,11 @@ bool Sql_cmd_truncate_table::truncate_table(THD *thd, TABLE_LIST *table_ref) if (error == TRUNCATE_OK && thd->locked_tables_mode && (table_ref->table->file->ht->flags & - HTON_REQUIRES_CLOSE_AFTER_TRUNCATE)) + (HTON_REQUIRES_CLOSE_AFTER_TRUNCATE | + HTON_TRUNCATE_REQUIRES_EXCLUSIVE_USE))) { thd->locked_tables_list.mark_table_for_reopen(thd, table_ref->table); - if (unlikely(thd->locked_tables_list.reopen_tables(thd, true))) + if (unlikely(thd->locked_tables_list.reopen_tables(thd, false))) thd->locked_tables_list.unlink_all_closed_tables(thd, NULL, 0); } diff --git a/storage/innobase/CMakeLists.txt b/storage/innobase/CMakeLists.txt index 222e671a900..e6e1c98f87d 100644 --- a/storage/innobase/CMakeLists.txt +++ b/storage/innobase/CMakeLists.txt @@ -48,6 +48,7 @@ SET(INNOBASE_SOURCES dict/dict0stats.cc dict/dict0stats_bg.cc dict/dict0defrag_bg.cc + dict/drop.cc eval/eval0eval.cc eval/eval0proc.cc fil/fil0fil.cc diff --git a/storage/innobase/btr/btr0btr.cc b/storage/innobase/btr/btr0btr.cc index 9b7ed30c3cd..07f2ee974c0 100644 --- a/storage/innobase/btr/btr0btr.cc +++ b/storage/innobase/btr/btr0btr.cc @@ -1196,21 +1196,29 @@ void btr_free_if_exists(fil_space_t *space, uint32_t page, } } -/** Free an index tree in a temporary tablespace. -@param[in] page_id root page id */ -void btr_free(const page_id_t page_id) +/** Drop a temporary table +@param table temporary table */ +void btr_drop_temporary_table(const dict_table_t &table) { - mtr_t mtr; - mtr.start(); - mtr.set_log_mode(MTR_LOG_NO_REDO); - - buf_block_t* block = buf_page_get(page_id, 0, RW_X_LATCH, &mtr); - - if (block) { - btr_free_but_not_root(block, MTR_LOG_NO_REDO); - btr_free_root(block, &mtr); - } - mtr.commit(); + ut_ad(table.is_temporary()); + ut_ad(table.space == fil_system.temp_space); + mtr_t mtr; + mtr.start(); + for (const dict_index_t *index= table.indexes.start; index; + index= dict_table_get_next_index(index)) + { + if (buf_block_t *block= buf_page_get_low({SRV_TMP_SPACE_ID, index->page}, 0, + RW_X_LATCH, nullptr, BUF_GET, &mtr, + nullptr, false)) + { + btr_free_but_not_root(block, MTR_LOG_NO_REDO); + mtr.set_log_mode(MTR_LOG_NO_REDO); + btr_free_root(block, &mtr); + mtr.commit(); + mtr.start(); + } + } + mtr.commit(); } /** Read the last used AUTO_INCREMENT value from PAGE_ROOT_AUTO_INC. diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc index c02fb72a102..21b51f2410b 100644 --- a/storage/innobase/btr/btr0cur.cc +++ b/storage/innobase/btr/btr0cur.cc @@ -1404,22 +1404,19 @@ btr_cur_search_to_nth_level_func( info->n_searches++; # endif if (autoinc == 0 - && latch_mode <= BTR_MODIFY_LEAF - && info->last_hash_succ -# ifdef MYSQL_INDEX_DISABLE_AHI - && !index->disable_ahi -# endif && !estimate -# ifdef PAGE_CUR_LE_OR_EXTENDS - && mode != PAGE_CUR_LE_OR_EXTENDS -# endif /* PAGE_CUR_LE_OR_EXTENDS */ - && !dict_index_is_spatial(index) + && latch_mode <= BTR_MODIFY_LEAF + && !modify_external /* If !ahi_latch, we do a dirty read of btr_search_enabled below, and btr_search_guess_on_hash() will have to check it again. */ && btr_search_enabled - && !modify_external +# ifdef PAGE_CUR_LE_OR_EXTENDS + && mode != PAGE_CUR_LE_OR_EXTENDS +# endif /* PAGE_CUR_LE_OR_EXTENDS */ + && info->last_hash_succ && !(tuple->info_bits & REC_INFO_MIN_REC_FLAG) + && !index->is_spatial() && !index->table->is_temporary() && btr_search_guess_on_hash(index, info, tuple, mode, latch_mode, cursor, ahi_latch, mtr)) { @@ -2443,9 +2440,6 @@ need_opposite_intention: btr_search_build_page_hash_index() before building a page hash index, while holding search latch. */ if (!btr_search_enabled) { -# ifdef MYSQL_INDEX_DISABLE_AHI - } else if (index->disable_ahi) { -# endif } else if (tuple->info_bits & REC_INFO_MIN_REC_FLAG) { ut_ad(index->is_instant()); /* This may be a search tuple for @@ -2453,6 +2447,8 @@ need_opposite_intention: ut_ad(tuple->is_metadata() || (tuple->is_metadata(tuple->info_bits ^ REC_STATUS_INSTANT))); + } else if (index->is_spatial()) { + } else if (index->table->is_temporary()) { } else if (rec_is_metadata(btr_cur_get_rec(cursor), *index)) { /* Only user records belong in the adaptive hash index. */ @@ -3602,13 +3598,11 @@ fail_err: #ifdef BTR_CUR_HASH_ADAPT if (!leaf) { -# ifdef MYSQL_INDEX_DISABLE_AHI - } else if (index->disable_ahi) { -# endif } else if (entry->info_bits & REC_INFO_MIN_REC_FLAG) { ut_ad(entry->is_metadata()); ut_ad(index->is_instant()); ut_ad(flags == BTR_NO_LOCKING_FLAG); + } else if (index->table->is_temporary()) { } else { srw_lock* ahi_latch = btr_search_sys.get_latch(*index); if (!reorg && cursor->flag == BTR_CUR_HASH) { @@ -3811,14 +3805,12 @@ btr_cur_pessimistic_insert( ut_ad(!big_rec_vec); } else { #ifdef BTR_CUR_HASH_ADAPT -# ifdef MYSQL_INDEX_DISABLE_AHI - if (index->disable_ahi); else -# endif if (entry->info_bits & REC_INFO_MIN_REC_FLAG) { ut_ad(entry->is_metadata()); ut_ad(index->is_instant()); ut_ad(flags & BTR_NO_LOCKING_FLAG); ut_ad(!(flags & BTR_CREATE_FLAG)); + } else if (index->table->is_temporary()) { } else { btr_search_update_hash_on_insert( cursor, btr_search_sys.get_latch(*index)); diff --git a/storage/innobase/btr/btr0sea.cc b/storage/innobase/btr/btr0sea.cc index ccf4992d335..7f110541fee 100644 --- a/storage/innobase/btr/btr0sea.cc +++ b/storage/innobase/btr/btr0sea.cc @@ -293,11 +293,7 @@ is NOT protected by any semaphore, to save CPU time! Do not assume its fields are consistent. @param[in,out] info search info @param[in] cursor cursor which was just positioned */ -static -void -btr_search_info_update_hash( - btr_search_t* info, - btr_cur_t* cursor) +static void btr_search_info_update_hash(btr_search_t *info, btr_cur_t *cursor) { dict_index_t* index = cursor->index; int cmp; @@ -1280,7 +1276,6 @@ retry: assert_block_ahi_valid(block); - if (!index || !btr_search_enabled) { if (is_freed) { part->latch.wr_unlock(); @@ -1290,9 +1285,7 @@ retry: return; } -#ifdef MYSQL_INDEX_DISABLE_AHI - ut_ad(!index->disable_ahi); -#endif + ut_ad(!index->table->is_temporary()); ut_ad(btr_search_enabled); ut_ad(block->page.id().space() == index->table->space_id); @@ -1479,9 +1472,8 @@ btr_search_build_page_hash_index( rec_offs offsets_[REC_OFFS_NORMAL_SIZE]; rec_offs* offsets = offsets_; -#ifdef MYSQL_INDEX_DISABLE_AHI - if (index->disable_ahi) return; -#endif + ut_ad(!index->table->is_temporary()); + if (!btr_search_enabled) { return; } @@ -1661,8 +1653,7 @@ exit_func: /** Updates the search info. @param[in,out] info search info @param[in,out] cursor cursor which was just positioned */ -void -btr_search_info_update_slow(btr_search_t* info, btr_cur_t* cursor) +void btr_search_info_update_slow(btr_search_t *info, btr_cur_t *cursor) { srw_lock* ahi_latch = &btr_search_sys.get_part(*cursor->index) ->latch; @@ -1779,7 +1770,7 @@ drop_exit: /** Updates the page hash index when a single record is deleted from a page. @param[in] cursor cursor which was positioned on the record to delete using btr_cur_search_, the record is not yet deleted.*/ -void btr_search_update_hash_on_delete(btr_cur_t* cursor) +void btr_search_update_hash_on_delete(btr_cur_t *cursor) { buf_block_t* block; const rec_t* rec; @@ -1790,9 +1781,6 @@ void btr_search_update_hash_on_delete(btr_cur_t* cursor) rec_offs_init(offsets_); ut_ad(page_is_leaf(btr_cur_get_page(cursor))); -#ifdef MYSQL_INDEX_DISABLE_AHI - if (cursor->index->disable_ahi) return; -#endif if (!btr_search_enabled) { return; @@ -1810,6 +1798,8 @@ void btr_search_update_hash_on_delete(btr_cur_t* cursor) return; } + ut_ad(!cursor->index->table->is_temporary()); + if (index != cursor->index) { btr_search_drop_page_hash_index(block); return; @@ -1864,9 +1854,7 @@ void btr_search_update_hash_node_on_insert(btr_cur_t *cursor, rec_t* rec; ut_ad(ahi_latch == &btr_search_sys.get_part(*cursor->index)->latch); -#ifdef MYSQL_INDEX_DISABLE_AHI - if (cursor->index->disable_ahi) return; -#endif + if (!btr_search_enabled) { return; } @@ -1884,6 +1872,8 @@ void btr_search_update_hash_node_on_insert(btr_cur_t *cursor, return; } + ut_ad(!cursor->index->table->is_temporary()); + if (index != cursor->index) { ut_ad(index->id == cursor->index->id); btr_search_drop_page_hash_index(block); @@ -1949,9 +1939,7 @@ void btr_search_update_hash_on_insert(btr_cur_t *cursor, ut_ad(ahi_latch == &btr_search_sys.get_part(*cursor->index)->latch); ut_ad(page_is_leaf(btr_cur_get_page(cursor))); -#ifdef MYSQL_INDEX_DISABLE_AHI - if (cursor->index->disable_ahi) return; -#endif + if (!btr_search_enabled) { return; } @@ -1973,9 +1961,8 @@ void btr_search_update_hash_on_insert(btr_cur_t *cursor, rec = btr_cur_get_rec(cursor); -#ifdef MYSQL_INDEX_DISABLE_AHI - ut_a(!index->disable_ahi); -#endif + ut_ad(!cursor->index->table->is_temporary()); + if (index != cursor->index) { ut_ad(index->id == cursor->index->id); btr_search_drop_page_hash_index(block); diff --git a/storage/innobase/dict/dict0crea.cc b/storage/innobase/dict/dict0crea.cc index 4782268aa44..70d9e2bb022 100644 --- a/storage/innobase/dict/dict0crea.cc +++ b/storage/innobase/dict/dict0crea.cc @@ -897,17 +897,6 @@ rec_corrupted: return 0; } -/** @return whether SYS_TABLES.NAME is for a '#sql-ib' table */ -bool dict_table_t::is_garbage_name(const void *data, size_t size) -{ - constexpr size_t suffix= sizeof TEMP_FILE_PREFIX_INNODB; - if (size <= suffix) - return false; - const char *f= static_cast(memchr(data, '/', size - suffix)); - return f && !memcmp(f + 1, TEMP_FILE_PREFIX_INNODB, - (sizeof TEMP_FILE_PREFIX_INNODB) - 1); -} - /*********************************************************************//** Creates a table create graph. @return own: table create node */ @@ -1388,34 +1377,15 @@ dberr_t dict_sys_t::create_or_check_sys_tables() return DB_SUCCESS; trx_t *trx= trx_create(); - trx->dict_operation = true; + trx->dict_operation= true; row_mysql_lock_data_dictionary(trx); - DBUG_EXECUTE_IF("create_and_drop_garbage", - ut_ad(DB_SUCCESS == que_eval_sql( - nullptr, - "PROCEDURE CREATE_GARBAGE_TABLE_PROC () IS\n" - "BEGIN\n" - "CREATE TABLE\n" - "\"test/" TEMP_FILE_PREFIX_INNODB "-garbage\"" - "(ID CHAR);\n" - "CREATE UNIQUE CLUSTERED INDEX PRIMARY ON " - "\"test/" TEMP_FILE_PREFIX_INNODB - "-garbage\"(ID);\n" - "END;\n", false, trx)); - row_drop_table_for_mysql("test/" - TEMP_FILE_PREFIX_INNODB "-garbage", - trx, SQLCOM_DROP_DB, true);); - /* NOTE: when designing InnoDB's foreign key support in 2001, Heikki Tuuri - made a mistake defined table names and the foreign key id to be of type - 'CHAR' (internally, really a VARCHAR). - The type should have been VARBINARY. */ + made a mistake and defined table names and the foreign key id to be of type + CHAR (internally, really VARCHAR). The type should have been VARBINARY. */ + /* System tables are always created inside the system tablespace. */ const auto srv_file_per_table_backup= srv_file_per_table; - - /* We always want SYSTEM tables to be created inside the system - tablespace. */ srv_file_per_table= 0; dberr_t error; const char *tablename; diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc index a1d68ecbc3e..3997989233b 100644 --- a/storage/innobase/dict/dict0dict.cc +++ b/storage/innobase/dict/dict0dict.cc @@ -716,18 +716,18 @@ bool dict_table_t::parse_name(char (&db_name)[NAME_LEN + 1], const size_t db_len= name.dblen(); ut_ad(db_len <= MAX_DATABASE_NAME_LEN); - memcpy(db_buf, name.m_name, db_len); + memcpy(db_buf, mdl_name.m_name, db_len); db_buf[db_len]= 0; - size_t tbl_len= strlen(name.m_name + db_len + 1); - const bool is_temp= name.is_temporary(); + size_t tbl_len= strlen(mdl_name.m_name + db_len + 1); + const bool is_temp= mdl_name.is_temporary(); if (is_temp); else if (const char *is_part= static_cast - (memchr(name.m_name + db_len + 1, '#', tbl_len))) - tbl_len= static_cast(is_part - &name.m_name[db_len + 1]); + (memchr(mdl_name.m_name + db_len + 1, '#', tbl_len))) + tbl_len= static_cast(is_part - &mdl_name.m_name[db_len + 1]); - memcpy(tbl_buf, name.m_name + db_len + 1, tbl_len); + memcpy(tbl_buf, mdl_name.m_name + db_len + 1, tbl_len); tbl_buf[tbl_len]= 0; if (!dict_locked) @@ -1019,13 +1019,13 @@ void dict_sys_t::create() /** Acquire a reference to a cached table. */ -inline void dict_sys_t::acquire(dict_table_t* table) +inline void dict_sys_t::acquire(dict_table_t *table) { ut_ad(dict_sys.find(table)); if (table->can_be_evicted) { - UT_LIST_REMOVE(dict_sys.table_LRU, table); - UT_LIST_ADD_FIRST(dict_sys.table_LRU, table); + UT_LIST_REMOVE(table_LRU, table); + UT_LIST_ADD_FIRST(table_LRU, table); } table->acquire(); @@ -1490,25 +1490,7 @@ dict_table_t::rename_tablespace(const char *new_name, bool replace) const ut_ad(!is_temporary()); if (!space) - { - const char *data_dir= DICT_TF_HAS_DATA_DIR(flags) - ? data_dir_path : nullptr; - ut_ad(data_dir || !DICT_TF_HAS_DATA_DIR(flags)); - - if (char *filepath= fil_make_filepath(data_dir, name, IBD, - data_dir != nullptr)) - { - fil_delete_tablespace(space_id, true); - os_file_type_t ftype; - bool exists; - /* Delete any temp file hanging around. */ - if (os_file_status(filepath, &exists, &ftype) && exists && - !os_file_delete_if_exists(innodb_temp_file_key, filepath, nullptr)) - ib::info() << "Delete of " << filepath << " failed."; - ut_free(filepath); - } return DB_SUCCESS; - } const char *old_path= UT_LIST_GET_FIRST(space->chain)->name; fil_space_t::name_type space_name{new_name, strlen(new_name)}; @@ -1594,17 +1576,33 @@ dict_table_rename_in_cache( HASH_DELETE(dict_table_t, name_hash, &dict_sys.table_hash, ut_fold_string(old_name), table); - if (strlen(new_name) > strlen(table->name.m_name)) { + const bool keep_mdl_name = dict_table_t::is_temporary_name(new_name) + && !table->name.is_temporary(); + + if (keep_mdl_name) { + /* Preserve the original table name for + dict_table_t::parse_name() and dict_acquire_mdl_shared(). */ + table->mdl_name.m_name = mem_heap_strdup(table->heap, + table->name.m_name); + } + + const size_t new_len = strlen(new_name); + + if (new_len > strlen(table->name.m_name)) { /* We allocate MAX_FULL_NAME_LEN + 1 bytes here to avoid memory fragmentation, we assume a repeated calls of ut_realloc() with the same size do not cause fragmentation */ - ut_a(strlen(new_name) <= MAX_FULL_NAME_LEN); + ut_a(new_len <= MAX_FULL_NAME_LEN); table->name.m_name = static_cast( ut_realloc(table->name.m_name, MAX_FULL_NAME_LEN + 1)); } strcpy(table->name.m_name, new_name); + if (!keep_mdl_name) { + table->mdl_name.m_name = table->name.m_name; + } + /* Add table to hash table of tables */ HASH_INSERT(dict_table_t, name_hash, &dict_sys.table_hash, fold, table); @@ -2065,9 +2063,6 @@ dict_index_add_to_cache( new_index->trx_id = index->trx_id; new_index->set_committed(index->is_committed()); new_index->nulls_equal = index->nulls_equal; -#ifdef MYSQL_INDEX_DISABLE_AHI - new_index->disable_ahi = index->disable_ahi; -#endif n_ord = new_index->n_uniq; /* Flag the ordering columns and also set column max_prefix */ diff --git a/storage/innobase/dict/dict0load.cc b/storage/innobase/dict/dict0load.cc index 3fe0104f484..2b9078a1c85 100644 --- a/storage/innobase/dict/dict0load.cc +++ b/storage/innobase/dict/dict0load.cc @@ -853,14 +853,6 @@ static ulint dict_check_sys_tables() rec_get_nth_field_old(rec, DICT_FLD__SYS_TABLES__NAME, &len)); - if (len == UNIV_SQL_NULL - || dict_table_t::is_garbage_name(field, len)) { - /* This table will be dropped by - dict_table_t::drop_garbage(). - We do not care if the file exists. */ - continue; - } - DBUG_PRINT("dict_check_sys_tables", ("name: %*.s", static_cast(len), field)); @@ -2451,7 +2443,7 @@ corrupted: << " failed, the table has missing" " foreign key indexes. Turn off" " 'foreign_key_checks' and try again."; - +evict: dict_sys.remove(table); table = NULL; } else { @@ -2468,8 +2460,9 @@ corrupted: if (!srv_force_recovery || !index || !index->is_primary()) { - dict_sys.remove(table); - table = NULL; + ib::warn() << "Failed to load table " << table->name + << ":" << err; + goto evict; } else if (index->is_corrupted() && table->is_readable()) { /* It is possible we force to load a corrupted diff --git a/storage/innobase/dict/dict0mem.cc b/storage/innobase/dict/dict0mem.cc index 0631bd24bc0..5f273a60be8 100644 --- a/storage/innobase/dict/dict0mem.cc +++ b/storage/innobase/dict/dict0mem.cc @@ -159,6 +159,7 @@ dict_table_t *dict_table_t::create(const span &name, table->flags= static_cast(flags) & ((1U << DICT_TF_BITS) - 1); table->flags2= static_cast(flags2) & ((1U << DICT_TF2_BITS) - 1); table->name.m_name= mem_strdupl(name.data(), name.size()); + table->mdl_name.m_name= table->name.m_name; table->is_system_db= dict_mem_table_is_system(table->name.m_name); table->space= space; table->space_id= space ? space->id : ULINT_UNDEFINED; @@ -221,7 +222,6 @@ dict_mem_table_free( table->referenced_set.~dict_foreign_set(); ut_free(table->name.m_name); - table->name.m_name = NULL; /* Clean up virtual index info structures that are registered with virtual columns */ diff --git a/storage/innobase/dict/dict0stats.cc b/storage/innobase/dict/dict0stats.cc index e9e91f730d5..3bc9ed79318 100644 --- a/storage/innobase/dict/dict0stats.cc +++ b/storage/innobase/dict/dict0stats.cc @@ -529,61 +529,35 @@ free the trx object. If it is not NULL then it will be rolled back only in the case of error, but not freed. @return DB_SUCCESS or error code */ static -dberr_t -dict_stats_exec_sql( - pars_info_t* pinfo, - const char* sql, - trx_t* trx) +dberr_t dict_stats_exec_sql(pars_info_t *pinfo, const char* sql, trx_t *trx) { - dberr_t err; - bool trx_started = false; + ut_d(dict_sys.assert_locked()); - ut_d(dict_sys.assert_locked()); + if (!dict_stats_persistent_storage_check(true)) + { + pars_info_free(pinfo); + return DB_STATS_DO_NOT_EXIST; + } - if (!dict_stats_persistent_storage_check(true)) { - pars_info_free(pinfo); - return(DB_STATS_DO_NOT_EXIST); - } + if (trx) + return que_eval_sql(pinfo, sql, FALSE, trx); - if (trx == NULL) { - trx = trx_create(); - trx_started = true; + trx= trx_create(); + if (srv_read_only_mode) + trx_start_internal_read_only(trx); + else + trx_start_internal(trx); - if (srv_read_only_mode) { - trx_start_internal_read_only(trx); - } else { - trx_start_internal(trx); - } - } + trx->dict_operation_lock_mode= RW_X_LATCH; + dberr_t err= que_eval_sql(pinfo, sql, FALSE, trx); - err = que_eval_sql(pinfo, sql, FALSE, trx); /* pinfo is freed here */ - - DBUG_EXECUTE_IF("stats_index_error", - if (!trx_started) { - err = DB_STATS_DO_NOT_EXIST; - trx->error_state = DB_STATS_DO_NOT_EXIST; - }); - - if (!trx_started && err == DB_SUCCESS) { - return(DB_SUCCESS); - } - - if (err == DB_SUCCESS) { - trx_commit_for_mysql(trx); - } else { - trx->op_info = "rollback of internal trx on stats tables"; - trx->dict_operation_lock_mode = RW_X_LATCH; - trx->rollback(); - trx->dict_operation_lock_mode = 0; - trx->op_info = ""; - ut_a(trx->error_state == DB_SUCCESS); - } - - if (trx_started) { - trx->free(); - } - - return(err); + if (err == DB_SUCCESS) + trx->commit(); + else + trx->rollback(); + trx->dict_operation_lock_mode= 0; + trx->free(); + return err; } /*********************************************************************//** @@ -671,6 +645,7 @@ dict_stats_table_clone_create( t->heap = heap; t->name.m_name = mem_heap_strdup(heap, table->name.m_name); + t->mdl_name.m_name = t->name.m_name; t->corrupted = table->corrupted; @@ -2749,6 +2724,9 @@ dict_stats_save( table_utf8, sizeof(table_utf8)); const time_t now = time(NULL); + trx_t* trx = trx_create(); + trx_start_internal(trx); + trx->dict_operation_lock_mode = RW_X_LATCH; dict_sys_lock(); pinfo = pars_info_create(); @@ -2782,20 +2760,21 @@ dict_stats_save( ":clustered_index_size,\n" ":sum_of_other_index_sizes\n" ");\n" - "END;", NULL); + "END;", trx); if (UNIV_UNLIKELY(ret != DB_SUCCESS)) { ib::error() << "Cannot save table statistics for table " << table->name << ": " << ret; -func_exit: +rollback_and_exit: + trx->rollback(); +free_and_exit: + trx->dict_operation_lock_mode = 0; dict_sys_unlock(); + trx->free(); dict_stats_snapshot_free(table); return ret; } - trx_t* trx = trx_create(); - trx_start_internal(trx); - dict_index_t* index; index_map_t indexes( (ut_strcmp_functor()), @@ -2864,7 +2843,7 @@ func_exit: stat_description, trx); if (ret != DB_SUCCESS) { - goto end; + goto rollback_and_exit; } } @@ -2874,7 +2853,7 @@ func_exit: "Number of leaf pages " "in the index", trx); if (ret != DB_SUCCESS) { - goto end; + goto rollback_and_exit; } ret = dict_stats_save_index_stat(index, now, "size", @@ -2883,15 +2862,12 @@ func_exit: "Number of pages " "in the index", trx); if (ret != DB_SUCCESS) { - goto end; + goto rollback_and_exit; } } - trx_commit_for_mysql(trx); - -end: - trx->free(); - goto func_exit; + trx->commit(); + goto free_and_exit; } /*********************************************************************//** @@ -3657,112 +3633,15 @@ transient: return(DB_SUCCESS); } -/** Remove the information for a particular index's stats from the persistent -storage if it exists and if there is data stored for this index. -This function creates its own trx and commits it. - -We must modify system tables in a separate transaction in order to -adhere to the InnoDB design constraint that dict_sys.latch prevents -lock waits on system tables. If we modified system and user tables in -the same transaction, we should exclusively hold dict_sys.latch until -the transaction is committed, and effectively block other transactions -that will attempt to open any InnoDB tables. Because we have no -guarantee that user transactions will be committed fast, we cannot -afford to keep the system tables locked in a user transaction. +/** Execute DELETE FROM mysql.innodb_table_stats +@param database_name database name +@param table_name table name +@param trx transaction (nullptr=start and commit a new one) @return DB_SUCCESS or error code */ -dberr_t -dict_stats_drop_index( -/*==================*/ - const char* db_and_table,/*!< in: db and table, e.g. 'db/table' */ - const char* iname, /*!< in: index name */ - char* errstr, /*!< out: error message if != DB_SUCCESS - is returned */ - ulint errstr_sz)/*!< in: size of the errstr buffer */ -{ - char db_utf8[MAX_DB_UTF8_LEN]; - char table_utf8[MAX_TABLE_UTF8_LEN]; - pars_info_t* pinfo; - dberr_t ret; - - dict_sys.assert_not_locked(); - - /* skip indexes whose table names do not contain a database name - e.g. if we are dropping an index from SYS_TABLES */ - if (strchr(db_and_table, '/') == NULL) { - - return(DB_SUCCESS); - } - - dict_fs2utf8(db_and_table, db_utf8, sizeof(db_utf8), - table_utf8, sizeof(table_utf8)); - - pinfo = pars_info_create(); - - pars_info_add_str_literal(pinfo, "database_name", db_utf8); - - pars_info_add_str_literal(pinfo, "table_name", table_utf8); - - pars_info_add_str_literal(pinfo, "index_name", iname); - - dict_sys_lock(); - - ret = dict_stats_exec_sql( - pinfo, - "PROCEDURE DROP_INDEX_STATS () IS\n" - "BEGIN\n" - "DELETE FROM \"" INDEX_STATS_NAME "\" WHERE\n" - "database_name = :database_name AND\n" - "table_name = :table_name AND\n" - "index_name = :index_name;\n" - "END;\n", NULL); - - dict_sys_unlock(); - - if (ret == DB_STATS_DO_NOT_EXIST) { - ret = DB_SUCCESS; - } - - if (ret != DB_SUCCESS) { - snprintf(errstr, errstr_sz, - "Unable to delete statistics for index %s" - " from %s%s: %s. They can be deleted later using" - " DELETE FROM %s WHERE" - " database_name = '%s' AND" - " table_name = '%s' AND" - " index_name = '%s';", - iname, - INDEX_STATS_NAME_PRINT, - (ret == DB_LOCK_WAIT_TIMEOUT - ? " because the rows are locked" - : ""), - ut_strerr(ret), - INDEX_STATS_NAME_PRINT, - db_utf8, - table_utf8, - iname); - - ut_print_timestamp(stderr); - fprintf(stderr, " InnoDB: %s\n", errstr); - } - - return(ret); -} - -/*********************************************************************//** -Executes -DELETE FROM mysql.innodb_table_stats -WHERE database_name = '...' AND table_name = '...'; -Creates its own transaction and commits it. -@return DB_SUCCESS or error code */ -UNIV_INLINE -dberr_t -dict_stats_delete_from_table_stats( -/*===============================*/ - const char* database_name, /*!< in: database name, e.g. 'db' */ - const char* table_name) /*!< in: table name, e.g. 'table' */ +dberr_t dict_stats_delete_from_table_stats(const char *database_name, + const char *table_name, trx_t *trx) { pars_info_t* pinfo; - dberr_t ret; ut_d(dict_sys.assert_locked()); @@ -3771,33 +3650,25 @@ dict_stats_delete_from_table_stats( pars_info_add_str_literal(pinfo, "database_name", database_name); pars_info_add_str_literal(pinfo, "table_name", table_name); - ret = dict_stats_exec_sql( + return dict_stats_exec_sql( pinfo, "PROCEDURE DELETE_FROM_TABLE_STATS () IS\n" "BEGIN\n" "DELETE FROM \"" TABLE_STATS_NAME "\" WHERE\n" "database_name = :database_name AND\n" "table_name = :table_name;\n" - "END;\n", NULL); - - return(ret); + "END;\n", trx); } -/*********************************************************************//** -Executes -DELETE FROM mysql.innodb_index_stats -WHERE database_name = '...' AND table_name = '...'; -Creates its own transaction and commits it. +/** Execute DELETE FROM mysql.innodb_index_stats +@param database_name database name +@param table_name table name +@param trx transaction (nullptr=start and commit a new one) @return DB_SUCCESS or error code */ -UNIV_INLINE -dberr_t -dict_stats_delete_from_index_stats( -/*===============================*/ - const char* database_name, /*!< in: database name, e.g. 'db' */ - const char* table_name) /*!< in: table name, e.g. 'table' */ +dberr_t dict_stats_delete_from_index_stats(const char *database_name, + const char *table_name, trx_t *trx) { pars_info_t* pinfo; - dberr_t ret; ut_d(dict_sys.assert_locked()); @@ -3806,375 +3677,144 @@ dict_stats_delete_from_index_stats( pars_info_add_str_literal(pinfo, "database_name", database_name); pars_info_add_str_literal(pinfo, "table_name", table_name); - ret = dict_stats_exec_sql( + return dict_stats_exec_sql( pinfo, "PROCEDURE DELETE_FROM_INDEX_STATS () IS\n" "BEGIN\n" "DELETE FROM \"" INDEX_STATS_NAME "\" WHERE\n" "database_name = :database_name AND\n" "table_name = :table_name;\n" - "END;\n", NULL); - - return(ret); + "END;\n", trx); } -/*********************************************************************//** -Removes the statistics for a table and all of its indexes from the -persistent statistics storage if it exists and if there is data stored for -the table. This function creates its own transaction and commits it. +/** Execute DELETE FROM mysql.innodb_index_stats +@param database_name database name +@param table_name table name +@param index_name name of the index +@param trx transaction (nullptr=start and commit a new one) @return DB_SUCCESS or error code */ -dberr_t -dict_stats_drop_table( -/*==================*/ - const char* db_and_table, /*!< in: db and table, e.g. 'db/table' */ - char* errstr, /*!< out: error message - if != DB_SUCCESS is returned */ - ulint errstr_sz) /*!< in: size of errstr buffer */ -{ - char db_utf8[MAX_DB_UTF8_LEN]; - char table_utf8[MAX_TABLE_UTF8_LEN]; - dberr_t ret; - - ut_d(dict_sys.assert_locked()); - - /* skip tables that do not contain a database name - e.g. if we are dropping SYS_TABLES */ - if (strchr(db_and_table, '/') == NULL) { - - return(DB_SUCCESS); - } - - /* skip innodb_table_stats and innodb_index_stats themselves */ - if (strcmp(db_and_table, TABLE_STATS_NAME) == 0 - || strcmp(db_and_table, INDEX_STATS_NAME) == 0) { - - return(DB_SUCCESS); - } - - dict_fs2utf8(db_and_table, db_utf8, sizeof(db_utf8), - table_utf8, sizeof(table_utf8)); - - ret = dict_stats_delete_from_table_stats(db_utf8, table_utf8); - - if (ret == DB_SUCCESS) { - ret = dict_stats_delete_from_index_stats(db_utf8, table_utf8); - } - - if (ret == DB_STATS_DO_NOT_EXIST) { - ret = DB_SUCCESS; - } - - if (ret != DB_SUCCESS) { - - snprintf(errstr, errstr_sz, - "Unable to delete statistics for table %s.%s: %s." - " They can be deleted later using" - - " DELETE FROM %s WHERE" - " database_name = '%s' AND" - " table_name = '%s';" - - " DELETE FROM %s WHERE" - " database_name = '%s' AND" - " table_name = '%s';", - - db_utf8, table_utf8, - ut_strerr(ret), - - INDEX_STATS_NAME_PRINT, - db_utf8, table_utf8, - - TABLE_STATS_NAME_PRINT, - db_utf8, table_utf8); - } - - return(ret); -} - -/*********************************************************************//** -Executes -UPDATE mysql.innodb_table_stats SET -database_name = '...', table_name = '...' -WHERE database_name = '...' AND table_name = '...'; -Creates its own transaction and commits it. -@return DB_SUCCESS or error code */ -UNIV_INLINE -dberr_t -dict_stats_rename_table_in_table_stats( -/*===================================*/ - const char* old_dbname_utf8,/*!< in: database name, e.g. 'olddb' */ - const char* old_tablename_utf8,/*!< in: table name, e.g. 'oldtable' */ - const char* new_dbname_utf8,/*!< in: database name, e.g. 'newdb' */ - const char* new_tablename_utf8)/*!< in: table name, e.g. 'newtable' */ +dberr_t dict_stats_delete_from_index_stats(const char *database_name, + const char *table_name, + const char *index_name, trx_t *trx) { pars_info_t* pinfo; - dberr_t ret; ut_d(dict_sys.assert_locked()); pinfo = pars_info_create(); - pars_info_add_str_literal(pinfo, "old_dbname_utf8", old_dbname_utf8); - pars_info_add_str_literal(pinfo, "old_tablename_utf8", old_tablename_utf8); - pars_info_add_str_literal(pinfo, "new_dbname_utf8", new_dbname_utf8); - pars_info_add_str_literal(pinfo, "new_tablename_utf8", new_tablename_utf8); + pars_info_add_str_literal(pinfo, "database_name", database_name); + pars_info_add_str_literal(pinfo, "table_name", table_name); + pars_info_add_str_literal(pinfo, "index_name", index_name); - ret = dict_stats_exec_sql( + return dict_stats_exec_sql( pinfo, - "PROCEDURE RENAME_TABLE_IN_TABLE_STATS () IS\n" + "PROCEDURE DELETE_FROM_INDEX_STATS () IS\n" "BEGIN\n" - "UPDATE \"" TABLE_STATS_NAME "\" SET\n" - "database_name = :new_dbname_utf8,\n" - "table_name = :new_tablename_utf8\n" - "WHERE\n" - "database_name = :old_dbname_utf8 AND\n" - "table_name = :old_tablename_utf8;\n" - "END;\n", NULL); - - return(ret); + "DELETE FROM \"" INDEX_STATS_NAME "\" WHERE\n" + "database_name = :database_name AND\n" + "table_name = :table_name AND\n" + "index_name = :index_name;\n" + "END;\n", trx); } -/*********************************************************************//** -Executes -UPDATE mysql.innodb_index_stats SET -database_name = '...', table_name = '...' -WHERE database_name = '...' AND table_name = '...'; -Creates its own transaction and commits it. +/** Rename a table in InnoDB persistent stats storage. +@param old_name old table name +@param new_name new table name +@param trx transaction @return DB_SUCCESS or error code */ -UNIV_INLINE -dberr_t -dict_stats_rename_table_in_index_stats( -/*===================================*/ - const char* old_dbname_utf8,/*!< in: database name, e.g. 'olddb' */ - const char* old_tablename_utf8,/*!< in: table name, e.g. 'oldtable' */ - const char* new_dbname_utf8,/*!< in: database name, e.g. 'newdb' */ - const char* new_tablename_utf8)/*!< in: table name, e.g. 'newtable' */ +dberr_t dict_stats_rename_table(const char *old_name, const char *new_name, + trx_t *trx) { - pars_info_t* pinfo; - dberr_t ret; + /* skip the statistics tables themselves */ + if (!strcmp(old_name, TABLE_STATS_NAME) || + !strcmp(old_name, INDEX_STATS_NAME) || + !strcmp(new_name, TABLE_STATS_NAME) || + !strcmp(new_name, INDEX_STATS_NAME)) + return DB_SUCCESS; - ut_d(dict_sys.assert_locked()); + char old_db[MAX_DB_UTF8_LEN]; + char new_db[MAX_DB_UTF8_LEN]; + char old_table[MAX_TABLE_UTF8_LEN]; + char new_table[MAX_TABLE_UTF8_LEN]; - pinfo = pars_info_create(); + dict_fs2utf8(old_name, old_db, sizeof old_db, old_table, sizeof old_table); + dict_fs2utf8(new_name, new_db, sizeof new_db, new_table, sizeof new_table); - pars_info_add_str_literal(pinfo, "old_dbname_utf8", old_dbname_utf8); - pars_info_add_str_literal(pinfo, "old_tablename_utf8", old_tablename_utf8); - pars_info_add_str_literal(pinfo, "new_dbname_utf8", new_dbname_utf8); - pars_info_add_str_literal(pinfo, "new_tablename_utf8", new_tablename_utf8); + if (dict_table_t::is_temporary_name(old_name) || + dict_table_t::is_temporary_name(new_name)) + { + if (dberr_t e= dict_stats_delete_from_table_stats(old_db, old_table, trx)) + return e; + return dict_stats_delete_from_index_stats(old_db, old_table, trx); + } - ret = dict_stats_exec_sql( - pinfo, - "PROCEDURE RENAME_TABLE_IN_INDEX_STATS () IS\n" - "BEGIN\n" - "UPDATE \"" INDEX_STATS_NAME "\" SET\n" - "database_name = :new_dbname_utf8,\n" - "table_name = :new_tablename_utf8\n" - "WHERE\n" - "database_name = :old_dbname_utf8 AND\n" - "table_name = :old_tablename_utf8;\n" - "END;\n", NULL); + pars_info_t *pinfo= pars_info_create(); + pars_info_add_str_literal(pinfo, "old_db", old_db); + pars_info_add_str_literal(pinfo, "old_table", old_table); + pars_info_add_str_literal(pinfo, "new_db", new_db); + pars_info_add_str_literal(pinfo, "new_table", new_table); - return(ret); + static const char sql[]= + "PROCEDURE RENAME_TABLE_IN_STATS() IS\n" + "BEGIN\n" + "UPDATE \"" TABLE_STATS_NAME "\" SET\n" + "database_name=:new_db, table_name=:new_table\n" + "WHERE database_name=:old_db AND table_name=:old_table;\n" + "UPDATE \"" INDEX_STATS_NAME "\" SET\n" + "database_name=:new_db, table_name=:new_table\n" + "WHERE database_name=:old_db AND table_name=:old_table;\n" + "END;\n"; + + return dict_stats_exec_sql(pinfo, sql, trx); } -/*********************************************************************//** -Renames a table in InnoDB persistent stats storage. -This function creates its own transaction and commits it. +/** Rename an index in InnoDB persistent statistics. +@param db database name +@param table table name +@param old_name old table name +@param new_name new table name +@param trx transaction @return DB_SUCCESS or error code */ -dberr_t -dict_stats_rename_table( -/*====================*/ - const char* old_name, /*!< in: old name, e.g. 'db/table' */ - const char* new_name, /*!< in: new name, e.g. 'db/table' */ - char* errstr, /*!< out: error string if != DB_SUCCESS - is returned */ - size_t errstr_sz) /*!< in: errstr size */ +dberr_t dict_stats_rename_index(const char *db, const char *table, + const char *old_name, const char *new_name, + trx_t *trx) { - char old_db_utf8[MAX_DB_UTF8_LEN]; - char new_db_utf8[MAX_DB_UTF8_LEN]; - char old_table_utf8[MAX_TABLE_UTF8_LEN]; - char new_table_utf8[MAX_TABLE_UTF8_LEN]; - dberr_t ret; + if (!dict_stats_persistent_storage_check(true)) + return DB_STATS_DO_NOT_EXIST; + pars_info_t *pinfo= pars_info_create(); - /* skip innodb_table_stats and innodb_index_stats themselves */ - if (strcmp(old_name, TABLE_STATS_NAME) == 0 - || strcmp(old_name, INDEX_STATS_NAME) == 0 - || strcmp(new_name, TABLE_STATS_NAME) == 0 - || strcmp(new_name, INDEX_STATS_NAME) == 0) { + pars_info_add_str_literal(pinfo, "db", db); + pars_info_add_str_literal(pinfo, "table", table); + pars_info_add_str_literal(pinfo, "old", old_name); + pars_info_add_str_literal(pinfo, "new", new_name); - return(DB_SUCCESS); - } + static const char sql[]= + "PROCEDURE RENAME_INDEX_IN_STATS() IS\n" + "BEGIN\n" + "UPDATE \"" INDEX_STATS_NAME "\" SET index_name=:new\n" + "WHERE database_name=:db AND table_name=:table AND index_name=:old;\n" + "END;\n"; - dict_fs2utf8(old_name, old_db_utf8, sizeof(old_db_utf8), - old_table_utf8, sizeof(old_table_utf8)); - - dict_fs2utf8(new_name, new_db_utf8, sizeof(new_db_utf8), - new_table_utf8, sizeof(new_table_utf8)); - - dict_sys_lock(); - - ulint n_attempts = 0; - do { - n_attempts++; - - ret = dict_stats_rename_table_in_table_stats( - old_db_utf8, old_table_utf8, - new_db_utf8, new_table_utf8); - - if (ret == DB_DUPLICATE_KEY) { - dict_stats_delete_from_table_stats( - new_db_utf8, new_table_utf8); - } - - if (ret == DB_STATS_DO_NOT_EXIST) { - ret = DB_SUCCESS; - } - - if (ret != DB_SUCCESS) { - dict_sys_unlock(); - std::this_thread::sleep_for( - std::chrono::milliseconds(200)); - dict_sys_lock(); - } - } while ((ret == DB_DEADLOCK - || ret == DB_DUPLICATE_KEY - || ret == DB_LOCK_WAIT_TIMEOUT) - && n_attempts < 5); - - if (ret != DB_SUCCESS) { - snprintf(errstr, errstr_sz, - "Unable to rename statistics from" - " %s.%s to %s.%s in %s: %s." - " They can be renamed later using" - - " UPDATE %s SET" - " database_name = '%s'," - " table_name = '%s'" - " WHERE" - " database_name = '%s' AND" - " table_name = '%s';", - - old_db_utf8, old_table_utf8, - new_db_utf8, new_table_utf8, - TABLE_STATS_NAME_PRINT, - ut_strerr(ret), - - TABLE_STATS_NAME_PRINT, - new_db_utf8, new_table_utf8, - old_db_utf8, old_table_utf8); - dict_sys_unlock(); - return(ret); - } - /* else */ - - n_attempts = 0; - do { - n_attempts++; - - ret = dict_stats_rename_table_in_index_stats( - old_db_utf8, old_table_utf8, - new_db_utf8, new_table_utf8); - - if (ret == DB_DUPLICATE_KEY) { - dict_stats_delete_from_index_stats( - new_db_utf8, new_table_utf8); - } - - if (ret == DB_STATS_DO_NOT_EXIST) { - ret = DB_SUCCESS; - } - - if (ret != DB_SUCCESS) { - dict_sys_unlock(); - std::this_thread::sleep_for( - std::chrono::milliseconds(200)); - dict_sys_lock(); - } - } while ((ret == DB_DEADLOCK - || ret == DB_DUPLICATE_KEY - || ret == DB_LOCK_WAIT_TIMEOUT) - && n_attempts < 5); - - dict_sys_unlock(); - - if (ret != DB_SUCCESS) { - snprintf(errstr, errstr_sz, - "Unable to rename statistics from" - " %s.%s to %s.%s in %s: %s." - " They can be renamed later using" - - " UPDATE %s SET" - " database_name = '%s'," - " table_name = '%s'" - " WHERE" - " database_name = '%s' AND" - " table_name = '%s';", - - old_db_utf8, old_table_utf8, - new_db_utf8, new_table_utf8, - INDEX_STATS_NAME_PRINT, - ut_strerr(ret), - - INDEX_STATS_NAME_PRINT, - new_db_utf8, new_table_utf8, - old_db_utf8, old_table_utf8); - } - - return(ret); + return dict_stats_exec_sql(pinfo, sql, trx); } -/*********************************************************************//** -Renames an index in InnoDB persistent stats storage. -This function creates its own transaction and commits it. -@return DB_SUCCESS or error code. DB_STATS_DO_NOT_EXIST will be returned -if the persistent stats do not exist. */ -dberr_t -dict_stats_rename_index( -/*====================*/ - const dict_table_t* table, /*!< in: table whose index - is renamed */ - const char* old_index_name, /*!< in: old index name */ - const char* new_index_name) /*!< in: new index name */ +/** Delete all persistent statistics for a database. +@param db database name +@param trx transaction +@return DB_SUCCESS or error code */ +dberr_t dict_stats_delete(const char *db, trx_t *trx) { - dict_sys_lock(); + static const char sql[] = + "PROCEDURE DROP_DATABASE_STATS () IS\n" + "BEGIN\n" + "DELETE FROM \"" TABLE_STATS_NAME "\" WHERE database_name=:db;\n" + "DELETE FROM \"" INDEX_STATS_NAME "\" WHERE database_name=:db;\n" + "END;\n"; - if (!dict_stats_persistent_storage_check(true)) { - dict_sys_unlock(); - return(DB_STATS_DO_NOT_EXIST); - } - - char dbname_utf8[MAX_DB_UTF8_LEN]; - char tablename_utf8[MAX_TABLE_UTF8_LEN]; - - dict_fs2utf8(table->name.m_name, dbname_utf8, sizeof(dbname_utf8), - tablename_utf8, sizeof(tablename_utf8)); - - pars_info_t* pinfo; - - pinfo = pars_info_create(); - - pars_info_add_str_literal(pinfo, "dbname_utf8", dbname_utf8); - pars_info_add_str_literal(pinfo, "tablename_utf8", tablename_utf8); - pars_info_add_str_literal(pinfo, "new_index_name", new_index_name); - pars_info_add_str_literal(pinfo, "old_index_name", old_index_name); - - dberr_t ret; - - ret = dict_stats_exec_sql( - pinfo, - "PROCEDURE RENAME_INDEX_IN_INDEX_STATS () IS\n" - "BEGIN\n" - "UPDATE \"" INDEX_STATS_NAME "\" SET\n" - "index_name = :new_index_name\n" - "WHERE\n" - "database_name = :dbname_utf8 AND\n" - "table_name = :tablename_utf8 AND\n" - "index_name = :old_index_name;\n" - "END;\n", NULL); - - dict_sys_unlock(); - - return(ret); + pars_info_t *pinfo= pars_info_create(); + pars_info_add_str_literal(pinfo, "db", db); + return dict_stats_exec_sql(pinfo, sql, trx); } /* tests @{ */ diff --git a/storage/innobase/dict/drop.cc b/storage/innobase/dict/drop.cc new file mode 100644 index 00000000000..7f936aaf051 --- /dev/null +++ b/storage/innobase/dict/drop.cc @@ -0,0 +1,256 @@ +/***************************************************************************** + +Copyright (c) 2021, MariaDB Corporation. + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA + +*****************************************************************************/ + +/** +@file dict/drop.cc +Data Dictionary Language operations that delete .ibd files */ + +/* We implement atomic data dictionary operations as follows. + +1. A data dictionary transaction is started. +2. We acquire exclusive lock on all the tables that are to be dropped +during the execution of the transaction. +3. We lock the data dictionary cache. +4. All metadata tables will be updated within the single DDL transaction, +including deleting or renaming InnoDB persistent statistics. +4b. If any lock wait would occur while we are holding the dict_sys latches, +we will instantly report a timeout error and roll back the transaction. +5. The transaction metadata is marked as committed. +6. If any files were deleted, we will durably write FILE_DELETE +to the redo log and start deleting the files. +6b. Also purge after a commit may perform file deletion. This is also the +recovery mechanism if the server was killed between step 5 and 6. +7. We unlock the data dictionary cache. +8. The file handles of the unlinked files will be closed. This will actually +reclaim the space in the file system (delete-on-close semantics). + +Notes: + +(a) Purge will be locked out by MDL. For internal tables related to +FULLTEXT INDEX, purge will not acquire MDL on the user table name, +and therefore, when we are dropping any FTS_ tables, we must suspend +and resume purge to prevent a race condition. + +(b) If a transaction needs to both drop and create a table by some +name, it must rename the table in between. This is used by +ha_innobase::truncate() and fts_drop_common_tables(). + +(c) No data is ever destroyed before the transaction is committed, +so we can trivially roll back the transaction at any time. +Lock waits during a DDL operation are no longer a fatal error +that would cause the InnoDB to hang or to intentionally crash. +(Only ALTER TABLE...DISCARD TABLESPACE may discard data before commit.) + +(d) The only changes to the data dictionary cache that are performed +before transaction commit and must be rolled back explicitly are as follows: +(d1) fts_optimize_add_table() to undo fts_optimize_remove_table() +(d2) stats_bg_flag= BG_STAT_NONE to undo dict_stats_stop_bg() +*/ + +#include "trx0purge.h" +#include "dict0dict.h" +#include "dict0stats.h" +#include "dict0stats_bg.h" + +#include "dict0defrag_bg.h" +#include "btr0defragment.h" + +#include "que0que.h" +#include "pars0pars.h" + +/** Try to drop the foreign key constraints for a persistent table. +@param name name of persistent table +@return error code */ +dberr_t trx_t::drop_table_foreign(const table_name_t &name) +{ + ut_d(dict_sys.assert_locked()); + ut_ad(state == TRX_STATE_ACTIVE); + ut_ad(dict_operation); + ut_ad(dict_operation_lock_mode == RW_X_LATCH); + + if (!dict_sys.sys_foreign || !dict_sys.sys_foreign_cols) + return DB_SUCCESS; + + pars_info_t *info= pars_info_create(); + pars_info_add_str_literal(info, "name", name.m_name); + return que_eval_sql(info, + "PROCEDURE DROP_FOREIGN() IS\n" + "fid CHAR;\n" + + "DECLARE CURSOR fk IS\n" + "SELECT ID FROM SYS_FOREIGN\n" + "WHERE FOR_NAME=:name\n" + "AND TO_BINARY(FOR_NAME)=TO_BINARY(:name)\n" + "FOR UPDATE;\n" + + "BEGIN\n" + "OPEN fk;\n" + "WHILE 1=1 LOOP\n" + " FETCH fk INTO fid;\n" + " IF (SQL % NOTFOUND)THEN RETURN;END IF;\n" + " DELETE FROM SYS_FOREIGN_COLS" + " WHERE ID=fid;\n" + " DELETE FROM SYS_FOREIGN WHERE ID=fid;\n" + "END LOOP;\n" + "CLOSE fk;\n" + "END;\n", FALSE, this); +} + +/** Try to drop the statistics for a persistent table. +@param name name of persistent table +@return error code */ +dberr_t trx_t::drop_table_statistics(const table_name_t &name) +{ + ut_d(dict_sys.assert_locked()); + ut_ad(dict_operation_lock_mode == RW_X_LATCH); + + if (strstr(name.m_name, "/" TEMP_FILE_PREFIX_INNODB) || + !strcmp(name.m_name, TABLE_STATS_NAME) || + !strcmp(name.m_name, INDEX_STATS_NAME)) + return DB_SUCCESS; + + char db[MAX_DB_UTF8_LEN], table[MAX_TABLE_UTF8_LEN]; + dict_fs2utf8(name.m_name, db, sizeof db, table, sizeof table); + + dberr_t err= dict_stats_delete_from_table_stats(db, table, this); + if (err == DB_SUCCESS || err == DB_STATS_DO_NOT_EXIST) + { + err= dict_stats_delete_from_index_stats(db, table, this); + if (err == DB_STATS_DO_NOT_EXIST) + err= DB_SUCCESS; + } + return err; +} + +/** Try to drop a persistent table. +@param table persistent table +@param fk whether to drop FOREIGN KEY metadata +@return error code */ +dberr_t trx_t::drop_table(const dict_table_t &table) +{ + ut_d(dict_sys.assert_locked()); + ut_ad(state == TRX_STATE_ACTIVE); + ut_ad(dict_operation); + ut_ad(dict_operation_lock_mode == RW_X_LATCH); + ut_ad(!table.is_temporary()); + ut_ad(!(table.stats_bg_flag & BG_STAT_IN_PROGRESS)); + /* The table must be exclusively locked by this transaction. */ + ut_ad(table.get_ref_count() <= 1); + ut_ad(!table.n_waiting_or_granted_auto_inc_locks); + ut_ad(table.n_lock_x_or_s == 1); + ut_ad(UT_LIST_GET_LEN(table.locks) >= 1); +#ifdef UNIV_DEBUG + bool found_x; + for (lock_t *lock= UT_LIST_GET_FIRST(table.locks); lock; + lock= UT_LIST_GET_NEXT(un_member.tab_lock.locks, lock)) + { + ut_ad(lock->trx == this); + if (lock->type_mode == (LOCK_X | LOCK_TABLE)) + found_x= true; + else + ut_ad(lock->type_mode == (LOCK_IX | LOCK_TABLE)); + } + ut_ad(found_x); +#endif + + if (dict_sys.sys_virtual) + { + pars_info_t *info= pars_info_create(); + pars_info_add_ull_literal(info, "id", table.id); + if (dberr_t err= que_eval_sql(info, + "PROCEDURE DROP_VIRTUAL() IS\n" + "BEGIN\n" + "DELETE FROM SYS_VIRTUAL" + " WHERE TABLE_ID=:id;\n" + "END;\n", FALSE, this)) + return err; + } + + /* Once DELETE FROM SYS_INDEXES is committed, purge may invoke + dict_drop_index_tree(). */ + + if (!(table.flags2 & (DICT_TF2_FTS_HAS_DOC_ID | DICT_TF2_FTS))); + else if (dberr_t err= fts_drop_tables(this, table)) + { + ib::error() << "Unable to remove FTS tables for " + << table.name << ": " << err; + return err; + } + + mod_tables.emplace(const_cast(&table), undo_no). + first->second.set_dropped(); + + pars_info_t *info= pars_info_create(); + pars_info_add_ull_literal(info, "id", table.id); + return que_eval_sql(info, + "PROCEDURE DROP_TABLE() IS\n" + "iid CHAR;\n" + + "DECLARE CURSOR idx IS\n" + "SELECT ID FROM SYS_INDEXES\n" + "WHERE TABLE_ID=:id FOR UPDATE;\n" + + "BEGIN\n" + "OPEN idx;\n" + "WHILE 1 = 1 LOOP\n" + " FETCH idx INTO iid;\n" + " IF (SQL % NOTFOUND) THEN EXIT; END IF;\n" + " DELETE FROM SYS_FIELDS WHERE INDEX_ID=iid;\n" + " DELETE FROM SYS_INDEXES WHERE CURRENT OF idx;\n" + "END LOOP;\n" + "CLOSE idx;\n" + + "DELETE FROM SYS_COLUMNS WHERE TABLE_ID=:id;\n" + "DELETE FROM SYS_TABLES WHERE ID=:id;\n" + + "END;\n", FALSE, this); +} + +/** Commit the transaction, possibly after drop_table(). +@param deleted handles of data files that were deleted */ +void trx_t::commit(std::vector &deleted) +{ + ut_ad(dict_operation); + commit_persist(); + if (dict_operation) + { + dict_sys.assert_locked(); + for (const auto &p : mod_tables) + { + if (p.second.is_dropped()) + { + dict_table_t *table= p.first; + dict_stats_recalc_pool_del(table); + dict_stats_defrag_pool_del(table, nullptr); + if (btr_defragment_active) + btr_defragment_remove_table(table); + const fil_space_t *space= table->space; + ut_ad(!strstr(table->name.m_name, "/FTS_") || + purge_sys.must_wait_FTS()); + dict_sys.remove(table); + if (const auto id= space ? space->id : 0) + { + pfs_os_file_t d= fil_delete_tablespace(id); + if (d != OS_FILE_CLOSED) + deleted.emplace_back(d); + } + } + } + } + commit_cleanup(); +} diff --git a/storage/innobase/fil/fil0crypt.cc b/storage/innobase/fil/fil0crypt.cc index f7f39337f90..1d2447a64ea 100644 --- a/storage/innobase/fil/fil0crypt.cc +++ b/storage/innobase/fil/fil0crypt.cc @@ -2312,9 +2312,6 @@ void fil_space_crypt_close_tablespace(const fil_space_t *space) while (crypt_data->rotate_state.active_threads || crypt_data->rotate_state.flushing) { mysql_mutex_unlock(&crypt_data->mutex); - /* release dict mutex so that scrub threads can release their - * table references */ - dict_sys.mutex_unlock(); /* wakeup throttle (all) sleepers */ mysql_mutex_lock(&fil_crypt_threads_mutex); @@ -2323,8 +2320,6 @@ void fil_space_crypt_close_tablespace(const fil_space_t *space) mysql_mutex_unlock(&fil_crypt_threads_mutex); std::this_thread::sleep_for(std::chrono::milliseconds(20)); - dict_sys.mutex_lock(); - mysql_mutex_lock(&crypt_data->mutex); time_t now = time(0); @@ -2339,6 +2334,8 @@ void fil_space_crypt_close_tablespace(const fil_space_t *space) << crypt_data->rotate_state.flushing << "."; last = now; } + + mysql_mutex_lock(&crypt_data->mutex); } mysql_mutex_unlock(&crypt_data->mutex); diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index 3072b5497e8..5f6b9e5578d 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -1566,39 +1566,61 @@ fil_name_write( fil_space_t *fil_space_t::check_pending_operations(ulint id) { ut_a(!is_system_tablespace(id)); + bool being_deleted= false; mysql_mutex_lock(&fil_system.mutex); fil_space_t *space= fil_space_get_by_id(id); if (!space); else if (space->pending() & STOPPING) - space= nullptr; + being_deleted= true; else { - space->reacquire(); if (space->crypt_data) { + space->reacquire(); mysql_mutex_unlock(&fil_system.mutex); fil_space_crypt_close_tablespace(space); mysql_mutex_lock(&fil_system.mutex); + space->release(); } - space->set_stopping(true); - space->release(); + being_deleted= space->set_stopping(); } mysql_mutex_unlock(&fil_system.mutex); if (!space) return nullptr; + if (being_deleted) + { + /* A thread executing DDL and another thread executing purge may + be executing fil_delete_tablespace() concurrently for the same + tablespace. Wait for the other thread to complete the operation. */ + for (ulint count= 0;; count++) + { + mysql_mutex_lock(&fil_system.mutex); + space= fil_space_get_by_id(id); + ut_ad(!space || space->is_stopping()); + mysql_mutex_unlock(&fil_system.mutex); + if (!space) + return nullptr; + /* Issue a warning every 10.24 seconds, starting after 2.56 seconds */ + if ((count & 511) == 128) + sql_print_warning("InnoDB: Waiting for tablespace " ULINTPF + " to be deleted", id); + std::this_thread::sleep_for(std::chrono::milliseconds(20)); + } + } + for (ulint count= 0;; count++) { - auto pending= space->referenced(); + const unsigned pending= space->referenced(); if (!pending) return space; - /* Give a warning every 10 second, starting after 1 second */ - if ((count % 500) == 50) - ib::warn() << "Trying to delete tablespace '" - << space->chain.start->name << "' but there are " - << pending << " pending operations on it."; + /* Issue a warning every 10.24 seconds, starting after 2.56 seconds */ + if ((count & 511) == 128) + sql_print_warning("InnoDB: Trying to delete tablespace '%s' " + "but there are %u pending operations", + space->chain.start->name, id); std::this_thread::sleep_for(std::chrono::milliseconds(20)); } } @@ -1645,117 +1667,60 @@ void fil_close_tablespace(ulint id) } /** Delete a tablespace and associated .ibd file. -@param[in] id tablespace identifier -@param[in] if_exists whether to ignore missing tablespace -@param[out] detached deatched file handle (if closing is not wanted) -@return DB_SUCCESS or error */ -dberr_t fil_delete_tablespace(ulint id, bool if_exists, - pfs_os_file_t *detached) +@param id tablespace identifier +@return detached file handle (to be closed by the caller) +@return OS_FILE_CLOSED if no file existed */ +pfs_os_file_t fil_delete_tablespace(ulint id) { - ut_ad(!is_system_tablespace(id)); - ut_ad(!detached || *detached == OS_FILE_CLOSED); + ut_ad(!is_system_tablespace(id)); + pfs_os_file_t handle= OS_FILE_CLOSED; + if (fil_space_t *space= fil_space_t::check_pending_operations(id)) + { + /* Before deleting the file(s), persistently write a log record. */ + mtr_t mtr; + mtr.start(); + mtr.log_file_op(FILE_DELETE, id, space->chain.start->name); + mtr.commit(); + log_write_up_to(mtr.commit_lsn(), true); - dberr_t err; - fil_space_t *space = fil_space_t::check_pending_operations(id); + /* Remove any additional files. */ + if (char *cfg_name= fil_make_filepath(space->chain.start->name, + fil_space_t::name_type{}, CFG, + false)) + { + os_file_delete_if_exists(innodb_data_file_key, cfg_name, nullptr); + ut_free(cfg_name); + } + if (FSP_FLAGS_HAS_DATA_DIR(space->flags)) + RemoteDatafile::delete_link_file(space->name()); - if (!space) { - err = DB_TABLESPACE_NOT_FOUND; - if (!if_exists) { - ib::error() << "Cannot delete tablespace " << id - << " because it is not found" - " in the tablespace memory cache."; - } -func_exit: - ibuf_delete_for_discarded_space(id); - return err; - } + /* Remove the directory entry. The file will actually be deleted + when our caller closes the handle. */ + os_file_delete(innodb_data_file_key, space->chain.start->name); - /* IMPORTANT: Because we have set space::stop_new_ops there - can't be any new reads or flushes. We are here - because node::n_pending was zero above. However, it is still - possible to have pending read and write requests: + mysql_mutex_lock(&fil_system.mutex); + /* Sanity checks after reacquiring fil_system.mutex */ + ut_ad(space == fil_space_get_by_id(id)); + ut_ad(!space->referenced()); + ut_ad(space->is_stopping()); + ut_ad(UT_LIST_GET_LEN(space->chain) == 1); + /* Detach the file handle. */ + handle= fil_system.detach(space, true); + mysql_mutex_unlock(&fil_system.mutex); - A read request can happen because the reader thread has - gone through the ::stop_new_ops check in buf_page_init_for_read() - before the flag was set and has not yet incremented ::n_pending - when we checked it above. + mysql_mutex_lock(&log_sys.mutex); + if (space->max_lsn) + { + ut_d(space->max_lsn = 0); + fil_system.named_spaces.remove(*space); + } + mysql_mutex_unlock(&log_sys.mutex); - A write request can be issued any time because we don't check - fil_space_t::is_stopping() when queueing a block for write. + fil_space_free_low(space); + } - We deal with pending write requests in the following function - where we'd minimally evict all dirty pages belonging to this - space from the flush_list. Note that if a block is IO-fixed - we'll wait for IO to complete. - - To deal with potential read requests, we will check the - is_stopping() in fil_space_t::io(). */ - - err = DB_SUCCESS; - buf_flush_remove_pages(id); - - /* If it is a delete then also delete any generated files, otherwise - when we drop the database the remove directory will fail. */ - { - /* Before deleting the file, write a log record about - it, so that InnoDB crash recovery will expect the file - to be gone. */ - mtr_t mtr; - - mtr.start(); - mtr.log_file_op(FILE_DELETE, id, space->chain.start->name); - mtr.commit(); - /* Even if we got killed shortly after deleting the - tablespace file, the record must have already been - written to the redo log. */ - log_write_up_to(mtr.commit_lsn(), true); - - if (char* cfg_name = fil_make_filepath( - space->chain.start->name, - fil_space_t::name_type{}, CFG, false)) { - os_file_delete_if_exists(innodb_data_file_key, - cfg_name, nullptr); - ut_free(cfg_name); - } - } - - /* Delete the link file pointing to the ibd file we are deleting. */ - if (FSP_FLAGS_HAS_DATA_DIR(space->flags)) { - RemoteDatafile::delete_link_file(space->name()); - } - - mysql_mutex_lock(&fil_system.mutex); - - /* Double check the sanity of pending ops after reacquiring - the fil_system::mutex. */ - ut_a(space == fil_space_get_by_id(id)); - ut_a(!space->referenced()); - ut_a(UT_LIST_GET_LEN(space->chain) == 1); - pfs_os_file_t handle = fil_system.detach(space, detached != nullptr); - if (detached) { - *detached = handle; - } - mysql_mutex_unlock(&fil_system.mutex); - - mysql_mutex_lock(&log_sys.mutex); - - if (space->max_lsn != 0) { - ut_d(space->max_lsn = 0); - fil_system.named_spaces.remove(*space); - } - - mysql_mutex_unlock(&log_sys.mutex); - - if (!os_file_delete(innodb_data_file_key, space->chain.start->name) - && !os_file_delete_if_exists(innodb_data_file_key, - space->chain.start->name, NULL)) { - /* Note: This is because we have removed the - tablespace instance from the cache. */ - err = DB_IO_ERROR; - } - - fil_space_free_low(space); - goto func_exit; + ibuf_delete_for_discarded_space(id); + return handle; } /*******************************************************************//** diff --git a/storage/innobase/fsp/fsp0file.cc b/storage/innobase/fsp/fsp0file.cc index 0c159a8ccb4..aebe6c9ce23 100644 --- a/storage/innobase/fsp/fsp0file.cc +++ b/storage/innobase/fsp/fsp0file.cc @@ -267,20 +267,20 @@ Datafile::read_first_page(bool read_only_mode) IORequestReadPartial, m_handle, m_first_page, 0, page_size, &n_read); - if (err == DB_IO_ERROR && n_read >= UNIV_PAGE_SIZE_MIN) { - - page_size >>= 1; - - } else if (err == DB_SUCCESS) { - + if (err == DB_SUCCESS) { ut_a(n_read == page_size); - break; + } + if (err == DB_IO_ERROR && n_read == 0) { + break; + } + if (err == DB_IO_ERROR && n_read >= UNIV_PAGE_SIZE_MIN) { + page_size >>= 1; } else if (srv_operation == SRV_OPERATION_BACKUP) { break; } else { - ib::error() << "Cannot read first page of '" + ib::info() << "Cannot read first page of '" << m_filepath << "': " << err; break; } diff --git a/storage/innobase/fts/fts0fts.cc b/storage/innobase/fts/fts0fts.cc index 050c8eb7d23..d1b71f3e72e 100644 --- a/storage/innobase/fts/fts0fts.cc +++ b/storage/innobase/fts/fts0fts.cc @@ -23,6 +23,9 @@ Full Text Search interface ***********************************************************************/ #include "trx0roll.h" +#ifdef UNIV_DEBUG +# include "trx0purge.h" +#endif #include "row0mysql.h" #include "row0upd.h" #include "dict0types.h" @@ -871,7 +874,7 @@ fts_drop_index( mysql_mutex_unlock(&cache->init_lock); } - err = fts_drop_index_tables(trx, index); + err = fts_drop_index_tables(trx, *index); ib_vector_remove(indexes, (const void*) index); @@ -1400,46 +1403,43 @@ fts_cache_add_doc( } } -/****************************************************************//** -Drops a table. If the table can't be found we return a SUCCESS code. -@return DB_SUCCESS or error code */ -static MY_ATTRIBUTE((nonnull, warn_unused_result)) -dberr_t -fts_drop_table( -/*===========*/ - trx_t* trx, /*!< in: transaction */ - const char* table_name) /*!< in: table to drop */ +/** Drop a table. +@param trx transaction +@param table_name FTS_ table name +@param rename whether to rename before dropping +@return error code +@retval DB_SUCCESS if the table was dropped +@retval DB_FAIL if the table did not exist */ +static dberr_t fts_drop_table(trx_t *trx, const char *table_name, bool rename) { - dict_table_t* table; - dberr_t error = DB_SUCCESS; + if (dict_table_t *table= dict_table_open_on_name(table_name, TRUE, FALSE, + DICT_ERR_IGNORE_DROP)) + { + table->release(); + if (rename) + { + mem_heap_t *heap= mem_heap_create(FN_REFLEN); + char *tmp= dict_mem_create_temporary_tablename(heap, table->name.m_name, + table->id); + dberr_t err= row_rename_table_for_mysql(table->name.m_name, tmp, trx, + false); + mem_heap_free(heap); + if (err != DB_SUCCESS) + { + ib::error() << "Unable to rename table " << table_name << ": " << err; + return err; + } + } + if (dberr_t err= trx->drop_table(*table)) + { + ib::error() << "Unable to drop table " << table->name << ": " << err; + return err; + } - /* Check that the table exists in our data dictionary. - Similar to regular drop table case, we will open table with - DICT_ERR_IGNORE_INDEX_ROOT and DICT_ERR_IGNORE_CORRUPT option */ - table = dict_table_open_on_name( - table_name, TRUE, FALSE, - static_cast( - DICT_ERR_IGNORE_INDEX_ROOT | DICT_ERR_IGNORE_CORRUPT)); + return DB_SUCCESS; + } - if (table != 0) { - - dict_table_close(table, TRUE, FALSE); - - /* Pass nonatomic=false (don't allow data dict unlock), - because the transaction may hold locks on SYS_* tables from - previous calls to fts_drop_table(). */ - error = row_drop_table_for_mysql(table_name, trx, - SQLCOM_DROP_DB, false, false); - - if (UNIV_UNLIKELY(error != DB_SUCCESS)) { - ib::error() << "Unable to drop FTS index aux table " - << table_name << ": " << error; - } - } else { - error = DB_FAIL; - } - - return(error); + return DB_FAIL; } /****************************************************************//** @@ -1473,7 +1473,7 @@ fts_rename_one_aux_table( fts_table_new_name[table_new_name_len] = 0; return row_rename_table_for_mysql( - fts_table_old_name, fts_table_new_name, trx, false, false); + fts_table_old_name, fts_table_new_name, trx, false); } /****************************************************************//** @@ -1539,25 +1539,115 @@ fts_rename_aux_tables( return(DB_SUCCESS); } +/** Lock an internal FTS_ table, before fts_drop_table() */ +static dberr_t fts_lock_table(trx_t *trx, const char *table_name) +{ + ut_ad(purge_sys.must_wait_FTS()); + + if (dict_table_t *table= dict_table_open_on_name(table_name, false, false, + DICT_ERR_IGNORE_DROP)) + { + dberr_t err= lock_table_for_trx(table, trx, LOCK_X); + /* Wait for purge threads to stop using the table. */ + for (uint n= 15; table->get_ref_count() > 1; ) + { + if (!--n) + { + err= DB_LOCK_WAIT_TIMEOUT; + break; + } + std::this_thread::sleep_for(std::chrono::milliseconds(50)); + } + table->release(); + return err; + } + return DB_SUCCESS; +} + +/** Lock the internal FTS_ tables for an index, before fts_drop_index_tables(). +@param trx transaction +@param index fulltext index */ +dberr_t fts_lock_index_tables(trx_t *trx, const dict_index_t &index) +{ + ut_ad(index.type & DICT_FTS); + fts_table_t fts_table; + char table_name[MAX_FULL_NAME_LEN]; + FTS_INIT_INDEX_TABLE(&fts_table, nullptr, FTS_INDEX_TABLE, (&index)); + for (const fts_index_selector_t *s= fts_index_selector; s->suffix; s++) + { + fts_table.suffix= s->suffix; + fts_get_table_name(&fts_table, table_name, false); + if (dberr_t err= fts_lock_table(trx, table_name)) + return err; + } + return DB_SUCCESS; +} + +/** Lock the internal common FTS_ tables, before fts_drop_common_tables(). +@param trx transaction +@param table table containing FULLTEXT INDEX +@return DB_SUCCESS or error code */ +dberr_t fts_lock_common_tables(trx_t *trx, const dict_table_t &table) +{ + fts_table_t fts_table; + char table_name[MAX_FULL_NAME_LEN]; + + FTS_INIT_FTS_TABLE(&fts_table, nullptr, FTS_COMMON_TABLE, (&table)); + + for (const char **suffix= fts_common_tables; *suffix; suffix++) + { + fts_table.suffix= *suffix; + fts_get_table_name(&fts_table, table_name, false); + if (dberr_t err= fts_lock_table(trx, table_name)) + return err; + } + return DB_SUCCESS; +} + +/** Lock the internal FTS_ tables for table, before fts_drop_tables(). +@param trx transaction +@param table table containing FULLTEXT INDEX +@return DB_SUCCESS or error code */ +dberr_t fts_lock_tables(trx_t *trx, const dict_table_t &table) +{ + if (dberr_t err= fts_lock_common_tables(trx, table)) + return err; + + if (!table.fts) + return DB_SUCCESS; + + auto indexes= table.fts->indexes; + if (!indexes) + return DB_SUCCESS; + + for (ulint i= 0; i < ib_vector_size(indexes); ++i) + if (dberr_t err= + fts_lock_index_tables(trx, *static_cast + (ib_vector_getp(indexes, i)))) + return err; + return DB_SUCCESS; +} + /** Drops the common ancillary tables needed for supporting an FTS index on the given table. row_mysql_lock_data_dictionary must have been called before this. -@param[in] trx transaction to drop fts common table -@param[in] fts_table table with an FTS index +@param trx transaction to drop fts common table +@param fts_table table with an FTS index +@param rename whether to rename before dropping @return DB_SUCCESS or error code */ -static dberr_t fts_drop_common_tables(trx_t *trx, fts_table_t *fts_table) +static dberr_t fts_drop_common_tables(trx_t *trx, fts_table_t *fts_table, + bool rename) { - ulint i; dberr_t error = DB_SUCCESS; - for (i = 0; fts_common_tables[i] != NULL; ++i) { + for (ulint i = 0; fts_common_tables[i] != NULL; ++i) { dberr_t err; char table_name[MAX_FULL_NAME_LEN]; fts_table->suffix = fts_common_tables[i]; fts_get_table_name(fts_table, table_name, true); - err = fts_drop_table(trx, table_name); + err = fts_drop_table(trx, table_name, rename); /* We only return the status of the last error. */ if (err != DB_SUCCESS && err != DB_FAIL) { @@ -1571,17 +1661,13 @@ static dberr_t fts_drop_common_tables(trx_t *trx, fts_table_t *fts_table) /****************************************************************//** Drops FTS auxiliary tables for an FTS index @return DB_SUCCESS or error code */ -dberr_t -fts_drop_index_tables( - trx_t* trx, /*!< in: transaction */ - dict_index_t* index) /*!< in: fts instance */ - +dberr_t fts_drop_index_tables(trx_t *trx, const dict_index_t &index) { ulint i; fts_table_t fts_table; dberr_t error = DB_SUCCESS; - FTS_INIT_INDEX_TABLE(&fts_table, NULL, FTS_INDEX_TABLE, index); + FTS_INIT_INDEX_TABLE(&fts_table, nullptr, FTS_INDEX_TABLE, (&index)); for (i = 0; i < FTS_NUM_AUX_INDEX; ++i) { dberr_t err; @@ -1590,7 +1676,7 @@ fts_drop_index_tables( fts_table.suffix = fts_get_suffix(i); fts_get_table_name(&fts_table, table_name, true); - err = fts_drop_table(trx, table_name); + err = fts_drop_table(trx, table_name, false); /* We only return the status of the last error. */ if (err != DB_SUCCESS && err != DB_FAIL) { @@ -1611,52 +1697,36 @@ dberr_t fts_drop_all_index_tables( /*======================*/ trx_t* trx, /*!< in: transaction */ - fts_t* fts) /*!< in: fts instance */ + const fts_t* fts) /*!< in: fts instance */ { - dberr_t error = DB_SUCCESS; + dberr_t error= DB_SUCCESS; + auto indexes= fts->indexes; + if (!indexes) + return DB_SUCCESS; - for (ulint i = 0; - fts->indexes != 0 && i < ib_vector_size(fts->indexes); - ++i) { - - dberr_t err; - dict_index_t* index; - - index = static_cast( - ib_vector_getp(fts->indexes, i)); - - err = fts_drop_index_tables(trx, index); - - if (err != DB_SUCCESS) { - error = err; - } - } - - return(error); + for (ulint i= 0; i < ib_vector_size(indexes); ++i) + if (dberr_t err= fts_drop_index_tables(trx, + *static_cast + (ib_vector_getp(indexes, i)))) + error= err; + return error; } -/*********************************************************************//** -Drops the ancillary tables needed for supporting an FTS index on a -given table. row_mysql_lock_data_dictionary must have been called before -this. +/** Drop the internal FTS_ tables for table. +@param trx transaction +@param table table containing FULLTEXT INDEX @return DB_SUCCESS or error code */ -dberr_t -fts_drop_tables( -/*============*/ - trx_t* trx, /*!< in: transaction */ - dict_table_t* table) /*!< in: table has the FTS index */ +dberr_t fts_drop_tables(trx_t *trx, const dict_table_t &table) { dberr_t error; fts_table_t fts_table; - FTS_INIT_FTS_TABLE(&fts_table, NULL, FTS_COMMON_TABLE, table); + FTS_INIT_FTS_TABLE(&fts_table, NULL, FTS_COMMON_TABLE, (&table)); - /* TODO: This is not atomic and can cause problems during recovery. */ + error = fts_drop_common_tables(trx, &fts_table, false); - error = fts_drop_common_tables(trx, &fts_table); - - if (error == DB_SUCCESS && table->fts) { - error = fts_drop_all_index_tables(trx, table->fts); + if (error == DB_SUCCESS && table.fts) { + error = fts_drop_all_index_tables(trx, table.fts); } return(error); @@ -1797,7 +1867,7 @@ fts_create_common_tables( FTS_INIT_FTS_TABLE(&fts_table, NULL, FTS_COMMON_TABLE, table); - error = fts_drop_common_tables(trx, &fts_table); + error = fts_drop_common_tables(trx, &fts_table, true); if (error != DB_SUCCESS) { @@ -4172,8 +4242,7 @@ begin_sync: index_cache = static_cast( ib_vector_get(cache->indexes, i)); - if (index_cache->index->to_be_dropped - || index_cache->index->table->to_be_dropped) { + if (index_cache->index->to_be_dropped) { continue; } @@ -4201,7 +4270,6 @@ begin_sync: ib_vector_get(cache->indexes, i)); if (index_cache->index->to_be_dropped - || index_cache->index->table->to_be_dropped || fts_sync_index_check(index_cache)) { continue; } diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 78abc11d1dc..7199fcfb547 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -94,7 +94,6 @@ this program; if not, write to the Free Software Foundation, Inc., #include "mtr0mtr.h" #include "os0file.h" #include "page0zip.h" -#include "pars0pars.h" #include "rem0types.h" #include "row0import.h" #include "row0ins.h" @@ -186,7 +185,7 @@ static char* innobase_reset_all_monitor_counter; stopword table to be used */ static char* innobase_server_stopword_table; -static my_bool innobase_rollback_on_timeout; +my_bool innobase_rollback_on_timeout; static my_bool innobase_create_status_file; my_bool innobase_stats_on_metadata; static my_bool innodb_optimize_fulltext_only; @@ -1312,7 +1311,8 @@ static ibool innodb_drop_database_fk(void *node, void *report) return true; } -/** Remove all tables in the named database inside InnoDB. +/** After DROP DATABASE executed ha_innobase::delete_table() on all +tables that it was aware of, drop any leftover tables inside InnoDB. @param path database path */ static void innodb_drop_database(handlerton*, char *path) { @@ -1375,15 +1375,12 @@ retry: continue; const auto n_handles= table->get_ref_count(); const bool locks= !n_handles && lock_table_has_locks(table); - const auto n_fk_checks= table->n_foreign_key_checks_running; - if (n_fk_checks || n_handles || locks) + if (n_handles || locks) { err= DB_ERROR; ib::error errmsg; errmsg << "DROP DATABASE: cannot DROP TABLE " << table->name; - if (n_fk_checks) - errmsg << " due to " << n_fk_checks << " FOREIGN KEY checks"; - else if (n_handles) + if (n_handles) errmsg << " due to " << n_handles << " open handles"; else errmsg << " due to locks"; @@ -1393,6 +1390,20 @@ retry: } } + trx_start_for_ddl(trx); + uint errors= 0; + char db[NAME_LEN + 1]; + strconvert(&my_charset_filename, namebuf, len, system_charset_info, db, + sizeof db, &errors); + if (errors); + else if (dict_stats_delete(db, trx)) + { + /* Ignore this error. Leaving garbage statistics behind is a + lesser evil. Carry on to try to remove any garbage tables. */ + trx->rollback(); + trx_start_for_ddl(trx); + } + static const char drop_database[] = "PROCEDURE DROP_DATABASE_PROC () IS\n" "fk CHAR;\n" @@ -1453,7 +1464,6 @@ retry: "END;\n"; innodb_drop_database_fk_report report{{namebuf, len + 1}, false}; - trx_start_for_ddl(trx); if (err == DB_SUCCESS) { @@ -1539,8 +1549,7 @@ retry: ut_ad("corrupted SYS_TABLES.SPACE" == 0); else if (uint32_t space_id= mach_read_from_4(s)) { - pfs_os_file_t detached= OS_FILE_CLOSED; - fil_delete_tablespace(space_id, true, &detached); + pfs_os_file_t detached= fil_delete_tablespace(space_id); if (detached != OS_FILE_CLOSED) to_close.emplace_back(detached); } @@ -1900,6 +1909,9 @@ static int innobase_wsrep_set_checkpoint(handlerton* hton, const XID* xid); static int innobase_wsrep_get_checkpoint(handlerton* hton, XID* xid); #endif /* WITH_WSREP */ +#define normalize_table_name(a,b) \ + normalize_table_name_c_low(a,b,IF_WIN(true,false)) + ulonglong ha_innobase::table_version() const { /* This is either "garbage" or something that was assigned @@ -2030,7 +2042,7 @@ convert_error_code_to_mysql( if (thd) { thd_mark_transaction_to_rollback( - thd, (bool) row_rollback_on_timeout); + thd, innobase_rollback_on_timeout); } return(HA_ERR_LOCK_WAIT_TIMEOUT); @@ -2066,9 +2078,6 @@ convert_error_code_to_mysql( "InnoDB"); return(HA_ERR_INTERNAL_ERROR); - case DB_TABLE_IN_FK_CHECK: - return(HA_ERR_TABLE_IN_FK_CHECK); - case DB_TABLE_NOT_FOUND: return(HA_ERR_NO_SUCH_TABLE); @@ -3809,8 +3818,6 @@ static int innodb_init_params() srv_buf_pool_size = ulint(innobase_buffer_pool_size); - row_rollback_on_timeout = (ibool) innobase_rollback_on_timeout; - if (innobase_open_files < 10) { innobase_open_files = 300; if (srv_file_per_table && tc_size > 300 && tc_size < open_files_limit) { @@ -3943,6 +3950,7 @@ static int innodb_init(void* p) HTON_NATIVE_SYS_VERSIONING | HTON_WSREP_REPLICATION | HTON_REQUIRES_CLOSE_AFTER_TRUNCATE | + HTON_TRUNCATE_REQUIRES_EXCLUSIVE_USE | HTON_REQUIRES_NOTIFY_TABLEDEF_CHANGED_AFTER_COMMIT; #ifdef WITH_WSREP @@ -4129,9 +4137,8 @@ innobase_commit_low( #ifdef WITH_WSREP const char* tmp = 0; const bool is_wsrep = trx->is_wsrep(); - THD* thd = trx->mysql_thd; if (is_wsrep) { - tmp = thd_proc_info(thd, "innobase_commit_low()"); + tmp = thd_proc_info(trx->mysql_thd, "innobase_commit_low()"); } #endif /* WITH_WSREP */ if (trx_is_started(trx)) { @@ -4145,7 +4152,7 @@ innobase_commit_low( #ifdef WITH_WSREP if (is_wsrep) { - thd_proc_info(thd, tmp); + thd_proc_info(trx->mysql_thd, tmp); } #endif /* WITH_WSREP */ } @@ -5009,10 +5016,6 @@ ha_innobase::table_cache_type() return(HA_CACHE_TBL_ASKTRANSACT); } -/****************************************************************//** -Determines if the primary key is clustered index. -@return true */ - /** Normalizes a table name string. A normalized name consists of the database name catenated to '/' and table name. For example: test/mytable. @@ -5027,7 +5030,7 @@ normalize_table_name_c_low( char* norm_name, /* out: normalized name as a null-terminated string */ const char* name, /* in: table name string */ - ibool set_lower_case) /* in: TRUE if we want to set + bool set_lower_case) /* in: TRUE if we want to set name to lower case */ { char* name_ptr; @@ -5095,29 +5098,11 @@ create_table_info_t::create_table_info_t( m_default_row_format(innodb_default_row_format), m_create_info(create_info), m_table_name(table_name), m_table(NULL), - m_drop_before_rollback(false), m_remote_path(remote_path), m_innodb_file_per_table(file_per_table) { } -/** Normalizes a table name string. -A normalized name consists of the database name catenated to '/' -and table name. For example: test/mytable. -On Windows, normalization puts both the database name and the -table name always to lower case if "set_lower_case" is set to TRUE. -@param[out] norm_name Normalized name, null-terminated. -@param[in] name Name to normalize. -@param[in] set_lower_case True if we also should fold to lower case. */ -void -create_table_info_t::normalize_table_name_low( - char* norm_name, - const char* name, - ibool set_lower_case) -{ - normalize_table_name_c_low(norm_name, name, set_lower_case); -} - #if !defined(DBUG_OFF) /********************************************************************* Test normalize_table_name_low(). */ @@ -5172,7 +5157,7 @@ test_normalize_table_name_low() " testing \"%s\", expected \"%s\"... ", test_data[i][0], test_data[i][1]); - create_table_info_t::normalize_table_name_low( + normalize_table_name_c_low( norm_name, test_data[i][0], FALSE); if (strcmp(norm_name, test_data[i][1]) == 0) { @@ -6040,10 +6025,8 @@ ha_innobase::open_dict_table( whether there exists table name in system table whose name is not being normalized to lower case */ - create_table_info_t:: - normalize_table_name_low( - par_case_name, - table_name, FALSE); + normalize_table_name_c_low( + par_case_name, table_name, false); #endif ib_table = dict_table_open_on_name( par_case_name, FALSE, TRUE, @@ -10395,7 +10378,6 @@ create_table_info_t::create_table_def() DBUG_PRINT("enter", ("table_name: %s", m_table_name)); DBUG_ASSERT(m_trx->mysql_thd == m_thd); - DBUG_ASSERT(!m_drop_before_rollback); /* MySQL does the name length check. But we do additional check on the name length here */ @@ -10672,7 +10654,6 @@ err_col: } else { if (err == DB_SUCCESS) { err = row_create_table_for_mysql(table, m_trx); - m_drop_before_rollback = (err == DB_SUCCESS); } DBUG_EXECUTE_IF("ib_crash_during_create_for_encryption", @@ -12493,9 +12474,6 @@ int create_table_info_t::create_table(bool create_fk) DBUG_RETURN(error); } - DBUG_ASSERT(m_drop_before_rollback - == !(m_flags2 & DICT_TF2_TEMPORARY)); - /* Create the keys */ if (m_form->s->keys == 0 || primary_key_no == -1) { @@ -13044,18 +13022,15 @@ ha_innobase::create( /* Drop the being-created table before rollback, so that rollback can possibly rename back a table that could have been renamed before the failed creation. */ - if (info.drop_before_rollback()) { - trx->error_state = DB_SUCCESS; - row_drop_table_for_mysql(info.table_name(), - trx, SQLCOM_TRUNCATE, true, - false); - } trx_rollback_for_mysql(trx); row_mysql_unlock_data_dictionary(trx); } else { - innobase_commit_low(trx); + /* When this is invoked as part of ha_innobase::truncate(), + the old copy of the table will be deleted here. */ + std::vector deleted; + trx->commit(deleted); row_mysql_unlock_data_dictionary(trx); - ut_ad(!srv_read_only_mode); + for (pfs_os_file_t d : deleted) os_file_close(d); error = info.create_table_update_dict(); } @@ -13142,7 +13117,7 @@ ha_innobase::discard_or_import_tablespace( } err = row_discard_tablespace_for_mysql( - m_prebuilt->table->name.m_name, m_prebuilt->trx); + m_prebuilt->table, m_prebuilt->trx); } else if (m_prebuilt->table->is_readable()) { /* Commit the transaction in order to @@ -13222,141 +13197,210 @@ ha_innobase::discard_or_import_tablespace( } -/** -Drops a table from an InnoDB database. Before calling this function, -MySQL calls innobase_commit to commit the transaction of the current user. -Then the current user cannot have locks set on the table. Drop table -operation inside InnoDB will remove all locks any user has on the table -inside InnoDB. -@param[in] name table name -@param[in] sqlcom SQLCOM_DROP_DB, SQLCOM_TRUNCATE, ... +/** DROP TABLE (possibly as part of DROP DATABASE, CREATE/ALTER TABLE) +@param name table name @return error number */ -inline int ha_innobase::delete_table(const char* name, enum_sql_command sqlcom) +int ha_innobase::delete_table(const char *name) { - dberr_t err; - THD* thd = ha_thd(); - char norm_name[FN_REFLEN]; + DBUG_ENTER("ha_innobase::delete_table"); + if (high_level_read_only) + DBUG_RETURN(HA_ERR_TABLE_READONLY); - DBUG_ENTER("ha_innobase::delete_table"); + THD *thd= ha_thd(); - DBUG_EXECUTE_IF( - "test_normalize_table_name_low", - test_normalize_table_name_low(); - ); - DBUG_EXECUTE_IF( - "test_ut_format_name", - test_ut_format_name(); - ); + DBUG_EXECUTE_IF("test_normalize_table_name_low", + test_normalize_table_name_low();); + DBUG_EXECUTE_IF("test_ut_format_name", test_ut_format_name();); - /* Strangely, MySQL passes the table name without the '.frm' - extension, in contrast to ::create */ - normalize_table_name(norm_name, name); + trx_t *parent_trx= check_trx_exists(thd); + dict_table_t *table; - if (high_level_read_only) { - DBUG_RETURN(HA_ERR_TABLE_READONLY); - } + for (;;) + { + char norm_name[FN_REFLEN]; + normalize_table_name(norm_name, name); + span n{norm_name, strlen(norm_name)}; - trx_t* parent_trx = check_trx_exists(thd); - - /* Remove the to-be-dropped table from the list of modified tables - by parent_trx. Otherwise we may end up with an orphaned pointer to - the table object from parent_trx::mod_tables. This could happen in: - SET AUTOCOMMIT=0; - CREATE TABLE t (PRIMARY KEY (a)) ENGINE=INNODB SELECT 1 AS a UNION - ALL SELECT 1 AS a; */ - for (auto iter = parent_trx->mod_tables.begin(); - iter != parent_trx->mod_tables.end(); - ++iter) { - - dict_table_t* table_to_drop = iter->first; - - if (strcmp(norm_name, table_to_drop->name.m_name) == 0) { - parent_trx->mod_tables.erase(iter); - break; - } - } - - trx_t* trx = innobase_trx_allocate(thd); - - ulint name_len = strlen(name); - - ut_a(name_len < 1000); - - trx->will_lock = true; - - /* Drop the table in InnoDB */ - - err = row_drop_table_for_mysql(norm_name, trx, sqlcom); - - if (err == DB_TABLE_NOT_FOUND && lower_case_table_names == 1) { - char* is_part = is_partition(norm_name); - - if (is_part) { - char par_case_name[FN_REFLEN]; - -#ifndef _WIN32 - /* Check for the table using lower - case name, including the partition - separator "P" */ - strcpy(par_case_name, norm_name); - innobase_casedn_str(par_case_name); -#else - /* On Windows platfrom, check - whether there exists table name in - system table whose name is - not being normalized to lower case */ - normalize_table_name_c_low( - par_case_name, name, FALSE); + dict_sys.lock(SRW_LOCK_CALL); + table= dict_sys.load_table(n, DICT_ERR_IGNORE_DROP); +#ifdef WITH_PARTITION_STORAGE_ENGINE + if (!table && lower_case_table_names == 1 && is_partition(norm_name)) + { + IF_WIN(normalize_table_name_c_low(norm_name, name, false), + innobase_casedn_str(norm_name)); + table= dict_sys.load_table(n, DICT_ERR_IGNORE_DROP); + } #endif - err = row_drop_table_for_mysql( - par_case_name, trx, sqlcom); - } - } + if (!table) + { + dict_sys.unlock(); + DBUG_RETURN(HA_ERR_NO_SUCH_TABLE); + } - ut_ad(!srv_read_only_mode); + if (dict_stats_stop_bg(table)) + break; + dict_sys.unlock(); + } - innobase_commit_low(trx); + if (table->is_temporary()) + { + dict_sys.remove(table, false, true); + dict_sys.unlock(); + parent_trx->mod_tables.erase(table); /* CREATE...SELECT error handling */ + btr_drop_temporary_table(*table); + dict_mem_table_free(table); + DBUG_RETURN(0); + } - trx->free(); + table->acquire(); + dict_sys.unlock(); - DBUG_RETURN(convert_error_code_to_mysql(err, 0, NULL)); -} + trx_t *trx= parent_trx; + if (!trx->lock.table_locks.empty() && + thd_sql_command(trx->mysql_thd) == SQLCOM_CREATE_TABLE) + { +#if 0 // MDEV-21602 FIXME: this fails for innodb.innodb and some others + for (const lock_t *l : trx->lock.table_locks) + if (l && l->type_mode == (LOCK_IX | LOCK_TABLE) && + l->un_member.tab_lock.table == table) + goto create_select; + sql_print_warning("InnoDB: CREATE...SELECT did not hold expected locks"); +create_select: +#endif + /* CREATE TABLE...PRIMARY KEY...SELECT ought to be dropping the + table because a duplicate key was detected. We shall hijack the + existing transaction to drop the table and commit the transaction. + If this is a partitioned table, one partition will use this hijacked + transaction; others will use a separate transaction, one per partition. */ + ut_ad(!trx->dict_operation_lock_mode); + ut_ad(trx->will_lock); + ut_ad(trx->state == TRX_STATE_ACTIVE); + trx->dict_operation= true; + trx->internal= true; + } + else + { + trx= innobase_trx_allocate(thd); + trx_start_for_ddl(trx); + } -/** Drop an InnoDB table. -@param[in] name table name -@return error number */ -int ha_innobase::delete_table(const char* name) -{ - enum_sql_command sqlcom = enum_sql_command(thd_sql_command(ha_thd())); - /* SQLCOM_TRUNCATE should be passed via ha_innobase::truncate() only. + dberr_t err= lock_table_for_trx(table, trx, LOCK_X); + const bool fts= err == DB_SUCCESS && + (table->flags2 & (DICT_TF2_FTS_HAS_DOC_ID | DICT_TF2_FTS)); - On client disconnect, when dropping temporary tables, the - previous sqlcom would not be overwritten. In such a case, we - will have thd_kill_level() != NOT_KILLED, !m_prebuilt can - hold, and sqlcom could be anything, including TRUNCATE. + if (fts) + { + fts_optimize_remove_table(table); + purge_sys.stop_FTS(); + err= fts_lock_tables(trx, *table); + } - The sqlcom only matters for persistent tables; no persistent - metadata or FOREIGN KEY metadata is kept for temporary - tables. Therefore, we relax the assertion. If there is a bug - that slips through this assertion due to !m_prebuilt, the - worst impact should be that on DROP TABLE of a persistent - table, FOREIGN KEY constraints will be ignored and their - metadata will not be removed. */ - DBUG_ASSERT(sqlcom != SQLCOM_TRUNCATE - || (thd_kill_level(ha_thd()) != THD_IS_NOT_KILLED - && (!m_prebuilt - || m_prebuilt->table->is_temporary()))); - return delete_table(name, sqlcom); + dict_sys.lock(SRW_LOCK_CALL); + trx->dict_operation_lock_mode= RW_X_LATCH; + if (!table->release() && err == DB_SUCCESS) + { + /* Wait for purge threads to stop using the table. */ + for (uint n= 15;;) + { + row_mysql_unlock_data_dictionary(trx); + std::this_thread::sleep_for(std::chrono::milliseconds(50)); + row_mysql_lock_data_dictionary(trx); + + if (!--n) + { + err= DB_LOCK_WAIT_TIMEOUT; + break; + } + if (!table->get_ref_count()) + break; + } + } + + if (err != DB_SUCCESS) + { +err_exit: + trx->rollback(); + trx->dict_operation_lock_mode= 0; + switch (err) { + case DB_CANNOT_DROP_CONSTRAINT: + case DB_LOCK_WAIT_TIMEOUT: + break; + default: + ib::error() << "DROP TABLE " << table->name << ": " << err; + } + table->stats_bg_flag= BG_STAT_NONE; + if (fts) + { + fts_optimize_add_table(table); + purge_sys.resume_FTS(); + } + dict_sys.unlock(); + if (trx != parent_trx) + trx->free(); + DBUG_RETURN(convert_error_code_to_mysql(err, 0, NULL)); + } + + if (!table->no_rollback() && trx->check_foreigns) + { + const bool drop_db= thd_sql_command(thd) == SQLCOM_DROP_DB; + for (auto foreign : table->referenced_set) + { + /* We should allow dropping a referenced table if creating + that referenced table has failed for some reason. For example + if referenced table is created but it column types that are + referenced do not match. */ + if (foreign->foreign_table == table || + (drop_db && + dict_tables_have_same_db(table->name.m_name, + foreign->foreign_table_name_lookup))) + continue; + mysql_mutex_lock(&dict_foreign_err_mutex); + rewind(dict_foreign_err_file); + ut_print_timestamp(dict_foreign_err_file); + fputs(" Cannot drop table ", dict_foreign_err_file); + ut_print_name(dict_foreign_err_file, trx, table->name.m_name); + fputs("\nbecause it is referenced by ", dict_foreign_err_file); + ut_print_name(dict_foreign_err_file, trx, foreign->foreign_table_name); + putc('\n', dict_foreign_err_file); + mysql_mutex_unlock(&dict_foreign_err_mutex); + err= DB_CANNOT_DROP_CONSTRAINT; + goto err_exit; + } + } + + if (!table->no_rollback()) + { + err= trx->drop_table_foreign(table->name); + if (err == DB_SUCCESS) + err= trx->drop_table_statistics(table->name); + if (err != DB_SUCCESS) + goto err_exit; + } + + err= trx->drop_table(*table); + if (err != DB_SUCCESS) + goto err_exit; + + std::vector deleted; + trx->commit(deleted); + row_mysql_unlock_data_dictionary(trx); + if (trx != parent_trx) + trx->free(); + for (pfs_os_file_t d : deleted) + os_file_close(d); + if (fts) + purge_sys.resume_FTS(); + DBUG_RETURN(0); } /** Rename an InnoDB table. @param[in,out] trx InnoDB data dictionary transaction @param[in] from old table name @param[in] to new table name -@param[in] commit whether to commit trx (and to enforce FOREIGN KEY) +@param[in] use_fk whether to enforce FOREIGN KEY @return DB_SUCCESS or error code */ inline dberr_t innobase_rename_table(trx_t *trx, const char *from, - const char *to, bool commit) + const char *to, bool use_fk) { dberr_t error; char norm_to[FN_REFLEN]; @@ -13375,14 +13419,7 @@ inline dberr_t innobase_rename_table(trx_t *trx, const char *from, trx_start_if_not_started(trx, true); ut_ad(trx->will_lock); - if (commit) { - /* Serialize data dictionary operations with dictionary mutex: - no deadlocks can occur then in these operations. */ - row_mysql_lock_data_dictionary(trx); - } - - error = row_rename_table_for_mysql(norm_from, norm_to, trx, commit, - commit); + error = row_rename_table_for_mysql(norm_from, norm_to, trx, use_fk); if (error != DB_SUCCESS) { if (error == DB_TABLE_NOT_FOUND @@ -13402,13 +13439,12 @@ inline dberr_t innobase_rename_table(trx_t *trx, const char *from, whether there exists table name in system table whose name is not being normalized to lower case */ - create_table_info_t::normalize_table_name_low( - par_case_name, from, FALSE); + normalize_table_name_c_low( + par_case_name, from, false); #endif /* _WIN32 */ trx_start_if_not_started(trx, true); error = row_rename_table_for_mysql( - par_case_name, norm_to, trx, - true, false); + par_case_name, norm_to, trx, false); } } @@ -13432,10 +13468,6 @@ inline dberr_t innobase_rename_table(trx_t *trx, const char *from, } } - if (commit) { - row_mysql_unlock_data_dictionary(trx); - } - DBUG_RETURN(error); } @@ -13453,92 +13485,158 @@ int ha_innobase::truncate() } HA_CREATE_INFO info; - mem_heap_t* heap = mem_heap_create(1000); dict_table_t* ib_table = m_prebuilt->table; - const auto update_time = ib_table->update_time; - const auto stored_lock = m_prebuilt->stored_select_lock_type; info.init(); update_create_info_from_table(&info, table); + switch (dict_tf_get_rec_format(ib_table->flags)) { + case REC_FORMAT_REDUNDANT: + info.row_type = ROW_TYPE_REDUNDANT; + break; + case REC_FORMAT_COMPACT: + info.row_type = ROW_TYPE_COMPACT; + break; + case REC_FORMAT_COMPRESSED: + info.row_type = ROW_TYPE_COMPRESSED; + break; + case REC_FORMAT_DYNAMIC: + info.row_type = ROW_TYPE_DYNAMIC; + break; + } + + const auto stored_lock = m_prebuilt->stored_select_lock_type; + trx_t* trx = innobase_trx_allocate(m_user_thd); + trx_start_for_ddl(trx); if (ib_table->is_temporary()) { info.options|= HA_LEX_CREATE_TMP_TABLE; - } else { - dict_get_and_save_data_dir_path(ib_table, false); + btr_drop_temporary_table(*ib_table); + m_prebuilt->table = nullptr; + row_prebuilt_free(m_prebuilt, false); + m_prebuilt = nullptr; + my_free(m_upd_buf); + m_upd_buf = nullptr; + m_upd_buf_size = 0; + + row_mysql_lock_data_dictionary(trx); + ib_table->release(); + dict_sys.remove(ib_table, false, true); + + int err = create(ib_table->name.m_name, table, &info, true, + trx); + if (!err) { + err = open(ib_table->name.m_name, 0, 0); + m_prebuilt->stored_select_lock_type = stored_lock; + } + + trx->free(); + +#ifdef BTR_CUR_HASH_ADAPT + if (UT_LIST_GET_LEN(ib_table->freed_indexes)) { + ib_table->vc_templ = nullptr; + ib_table->id = 0; + DBUG_RETURN(err); + } +#endif /* BTR_CUR_HASH_ADAPT */ + + dict_mem_table_free(ib_table); + DBUG_RETURN(err); } - char* data_file_name = ib_table->data_dir_path; - - if (data_file_name) { - info.data_file_name = data_file_name - = mem_heap_strdup(heap, data_file_name); - } + mem_heap_t* heap = mem_heap_create(1000); + dict_get_and_save_data_dir_path(ib_table, false); + info.data_file_name = ib_table->data_dir_path; const char* temp_name = dict_mem_create_temporary_tablename( heap, ib_table->name.m_name, ib_table->id); const char* name = mem_heap_strdup(heap, ib_table->name.m_name); - trx_t* trx = innobase_trx_allocate(m_user_thd); - trx->will_lock = true; - trx->dict_operation = true; + dberr_t error = lock_table_for_trx(ib_table, trx, LOCK_X); + const bool fts = error == DB_SUCCESS + && ib_table->flags2 & (DICT_TF2_FTS_HAS_DOC_ID | DICT_TF2_FTS); + + if (fts) { + fts_optimize_remove_table(ib_table); + purge_sys.stop_FTS(); + error = fts_lock_tables(trx, *ib_table); + } + row_mysql_lock_data_dictionary(trx); dict_stats_wait_bg_to_stop_using_table(ib_table, trx); - - int err = convert_error_code_to_mysql( - innobase_rename_table(trx, ib_table->name.m_name, temp_name, - false), - ib_table->flags, m_user_thd); - if (err) { - trx_rollback_for_mysql(trx); - row_mysql_unlock_data_dictionary(trx); - } else { - switch (dict_tf_get_rec_format(ib_table->flags)) { - case REC_FORMAT_REDUNDANT: - info.row_type = ROW_TYPE_REDUNDANT; - break; - case REC_FORMAT_COMPACT: - info.row_type = ROW_TYPE_COMPACT; - break; - case REC_FORMAT_COMPRESSED: - info.row_type = ROW_TYPE_COMPRESSED; - break; - case REC_FORMAT_DYNAMIC: - info.row_type = ROW_TYPE_DYNAMIC; + /* Wait for purge threads to stop using the table. */ + for (uint n = 15; ib_table->get_ref_count() > 1; ) { + if (!--n) { + error = DB_LOCK_WAIT_TIMEOUT; break; } + row_mysql_unlock_data_dictionary(trx); + std::this_thread::sleep_for(std::chrono::milliseconds(50)); + row_mysql_lock_data_dictionary(trx); + } + + if (error == DB_SUCCESS) { + error = innobase_rename_table(trx, ib_table->name.m_name, + temp_name, false); + + if (error == DB_SUCCESS) { + error = trx->drop_table(*ib_table); + } + } + + int err = convert_error_code_to_mysql(error, ib_table->flags, + m_user_thd); + if (err) { + trx_rollback_for_mysql(trx); + if (fts) { + fts_optimize_add_table(ib_table); + purge_sys.resume_FTS(); + } + row_mysql_unlock_data_dictionary(trx); + } else { + const auto update_time = ib_table->update_time; + const auto stored_lock = m_prebuilt->stored_select_lock_type; + ib_table->release(); + m_prebuilt->table = nullptr; + err = create(name, table, &info, - ib_table->is_temporary() - || dict_table_is_file_per_table(ib_table), trx); + dict_table_is_file_per_table(ib_table), trx); + if (fts) { + purge_sys.resume_FTS(); + } + + if (err) { +reload: + m_prebuilt->table = dict_table_open_on_name( + name, false, false, DICT_ERR_IGNORE_NONE); + } else { + row_prebuilt_t* prebuilt = m_prebuilt; + uchar* upd_buf = m_upd_buf; + ulint upd_buf_size = m_upd_buf_size; + /* Mimic ha_innobase::close(). */ + m_prebuilt = nullptr; + m_upd_buf = nullptr; + m_upd_buf_size = 0; + + err = open(name, 0, 0); + + if (!err) { + m_prebuilt->stored_select_lock_type + = stored_lock; + m_prebuilt->table->update_time = update_time; + row_prebuilt_free(prebuilt, false); + my_free(upd_buf); + } else { + /* Revert to the old table. */ + m_prebuilt = prebuilt; + m_upd_buf = upd_buf; + m_upd_buf_size = upd_buf_size; + goto reload; + } + } } trx->free(); - if (!err) { - /* Reopen the newly created table, and drop the - original table that was renamed to temp_name. */ - - row_prebuilt_t* prebuilt = m_prebuilt; - uchar* upd_buf = m_upd_buf; - ulint upd_buf_size = m_upd_buf_size; - /* Mimic ha_innobase::close(). */ - m_prebuilt = NULL; - m_upd_buf = NULL; - m_upd_buf_size = 0; - err = open(name, 0, 0); - if (!err) { - m_prebuilt->stored_select_lock_type = stored_lock; - m_prebuilt->table->update_time = update_time; - row_prebuilt_free(prebuilt, FALSE); - delete_table(temp_name, SQLCOM_TRUNCATE); - my_free(upd_buf); - } else { - /* Revert to the old table before truncation. */ - m_prebuilt = prebuilt; - m_upd_buf = upd_buf; - m_upd_buf_size = upd_buf_size; - } - } - mem_heap_free(heap); DBUG_RETURN(err); } @@ -13567,54 +13665,46 @@ ha_innobase::rename_table( /* We are doing a DDL operation. */ trx->will_lock = true; trx->dict_operation = true; + row_mysql_lock_data_dictionary(trx); dberr_t error = innobase_rename_table(trx, from, to, true); DEBUG_SYNC(thd, "after_innobase_rename_table"); - innobase_commit_low(trx); - - trx->free(); - if (error == DB_SUCCESS) { char norm_from[MAX_FULL_NAME_LEN]; char norm_to[MAX_FULL_NAME_LEN]; - char errstr[512]; - dberr_t ret; normalize_table_name(norm_from, from); normalize_table_name(norm_to, to); - ret = dict_stats_rename_table(norm_from, norm_to, - errstr, sizeof(errstr)); - - if (ret != DB_SUCCESS) { - ib::error() << errstr; - - push_warning(thd, Sql_condition::WARN_LEVEL_WARN, - ER_LOCK_WAIT_TIMEOUT, errstr); + error = dict_stats_rename_table(norm_from, norm_to, trx); + if (error == DB_DUPLICATE_KEY) { + /* The duplicate may also occur in + mysql.innodb_index_stats. */ + my_error(ER_DUP_KEY, MYF(0), + "mysql.innodb_table_stats"); + error = DB_ERROR; } } - /* Add a special case to handle the Duplicated Key error - and return DB_ERROR instead. - This is to avoid a possible SIGSEGV error from mysql error - handling code. Currently, mysql handles the Duplicated Key - error by re-entering the storage layer and getting dup key - info by calling get_dup_key(). This operation requires a valid - table handle ('row_prebuilt_t' structure) which could no - longer be available in the error handling stage. The suggested - solution is to report a 'table exists' error message (since - the dup key error here is due to an existing table whose name - is the one we are trying to rename to) and return the generic - error code. */ - if (error == DB_DUPLICATE_KEY) { - my_error(ER_TABLE_EXISTS_ERROR, MYF(0), to); + if (error == DB_SUCCESS) { + innobase_commit_low(trx); + } else { + trx->rollback(); + } + row_mysql_unlock_data_dictionary(trx); + trx->free(); + + if (error == DB_DUPLICATE_KEY) { + /* We are not able to deal with handler::get_dup_key() + during DDL operations, because the duplicate key would + exist in metadata tables, not in the user table. */ + my_error(ER_TABLE_EXISTS_ERROR, MYF(0), to); error = DB_ERROR; } else if (error == DB_LOCK_WAIT_TIMEOUT) { my_error(ER_LOCK_WAIT_TIMEOUT, MYF(0), to); - error = DB_LOCK_WAIT; } @@ -17784,20 +17874,11 @@ innobase_fts_find_ranking(FT_INFO* fts_hdl, uchar*, uint) } #ifdef UNIV_DEBUG -static my_bool innodb_background_drop_list_empty = TRUE; static my_bool innodb_log_checkpoint_now = TRUE; static my_bool innodb_buf_flush_list_now = TRUE; static uint innodb_merge_threshold_set_all_debug = DICT_INDEX_MERGE_THRESHOLD_DEFAULT; -/** Wait for the background drop list to become empty. */ -static -void -wait_background_drop_list_empty(THD*, st_mysql_sys_var*, void*, const void*) -{ - row_wait_for_background_drop_list_empty(); -} - /****************************************************************//** Force innodb to checkpoint. */ static @@ -18341,12 +18422,6 @@ static MYSQL_SYSVAR_ULONG(io_capacity_max, srv_max_io_capacity, SRV_MAX_IO_CAPACITY_LIMIT, 0); #ifdef UNIV_DEBUG -static MYSQL_SYSVAR_BOOL(background_drop_list_empty, - innodb_background_drop_list_empty, - PLUGIN_VAR_OPCMDARG, - "Wait for the background drop list to become empty", - NULL, wait_background_drop_list_empty, FALSE); - static MYSQL_SYSVAR_BOOL(log_checkpoint_now, innodb_log_checkpoint_now, PLUGIN_VAR_OPCMDARG, "Force checkpoint now", @@ -19382,7 +19457,6 @@ static struct st_mysql_sys_var* innobase_system_variables[]= { MYSQL_SYSVAR(purge_threads), MYSQL_SYSVAR(purge_batch_size), #ifdef UNIV_DEBUG - MYSQL_SYSVAR(background_drop_list_empty), MYSQL_SYSVAR(log_checkpoint_now), MYSQL_SYSVAR(buf_flush_list_now), MYSQL_SYSVAR(merge_threshold_set_all_debug), diff --git a/storage/innobase/handler/ha_innodb.h b/storage/innobase/handler/ha_innodb.h index 431e93f7021..4185f7a68cd 100644 --- a/storage/innobase/handler/ha_innodb.h +++ b/storage/innobase/handler/ha_innodb.h @@ -204,8 +204,6 @@ public: TABLE* form, HA_CREATE_INFO* create_info) override; - inline int delete_table(const char* name, enum_sql_command sqlcom); - int truncate() override; int delete_table(const char *name) override; @@ -708,26 +706,9 @@ public: const char* table_name() const { return(m_table_name); } - /** @return whether the table needs to be dropped on rollback */ - bool drop_before_rollback() const { return m_drop_before_rollback; } - THD* thd() const { return(m_thd); } - /** Normalizes a table name string. - A normalized name consists of the database name catenated to '/' and - table name. An example: test/mytable. On Windows normalization puts - both the database name and the table name always to lower case if - "set_lower_case" is set to true. - @param[in,out] norm_name Buffer to return the normalized name in. - @param[in] name Table name string. - @param[in] set_lower_case True if we want to set name to lower - case. */ - static void normalize_table_name_low( - char* norm_name, - const char* name, - ibool set_lower_case); - private: /** Parses the table name into normal name and either temp path or remote path if needed.*/ @@ -757,8 +738,6 @@ private: char* m_table_name; /** Table */ dict_table_t* m_table; - /** Whether the table needs to be dropped before rollback */ - bool m_drop_before_rollback; /** Remote path (DATA DIRECTORY) or zero length-string */ char* m_remote_path; @@ -861,15 +840,6 @@ innodb_base_col_setup_for_stored( /** whether this is a stored generated column */ #define innobase_is_s_fld(field) ((field)->vcol_info && (field)->stored_in_db()) -/** Always normalize table name to lower case on Windows */ -#ifdef _WIN32 -#define normalize_table_name(norm_name, name) \ - create_table_info_t::normalize_table_name_low(norm_name, name, TRUE) -#else -#define normalize_table_name(norm_name, name) \ - create_table_info_t::normalize_table_name_low(norm_name, name, FALSE) -#endif /* _WIN32 */ - /** Converts a search mode flag understood by MySQL to a flag understood by InnoDB. @param[in] find_flag MySQL search mode flag. diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 471ff1574d6..fce6c06b6c6 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -1164,10 +1164,14 @@ struct ha_innobase_inplace_ctx : public inplace_alter_handler_ctx } } -private: - // Disable copying - ha_innobase_inplace_ctx(const ha_innobase_inplace_ctx&); - ha_innobase_inplace_ctx& operator=(const ha_innobase_inplace_ctx&); + /** @return whether a FULLTEXT INDEX is being added */ + bool adding_fulltext_index() const + { + for (ulint a= 0; a < num_to_add_index; a++) + if (add_index[a]->type & DICT_FTS) + return true; + return false; + } }; /********************************************************************//** @@ -4515,38 +4519,6 @@ found_col: DBUG_RETURN(col_map); } -/** Drop newly create FTS index related auxiliary table during -FIC create index process, before fts_add_index is called -@param table table that was being rebuilt online -@param trx transaction -@return DB_SUCCESS if successful, otherwise last error code -*/ -static -dberr_t -innobase_drop_fts_index_table( -/*==========================*/ - dict_table_t* table, - trx_t* trx) -{ - dberr_t ret_err = DB_SUCCESS; - - for (dict_index_t* index = dict_table_get_first_index(table); - index != NULL; - index = dict_table_get_next_index(index)) { - if (index->type & DICT_FTS) { - dberr_t err; - - err = fts_drop_index_tables(trx, index); - - if (err != DB_SUCCESS) { - ret_err = err; - } - } - } - - return(ret_err); -} - /** Get the new non-virtual column names if any columns were renamed @param ha_alter_info Data used during in-place alter @param altered_table MySQL table that is being altered @@ -6122,6 +6094,24 @@ create_index_dict( DBUG_RETURN(index); } +/** After releasing the data dictionary latch, close deleted files +@param deleted handles of deleted files */ +static void close_unlinked_files(const std::vector &deleted) +{ + dict_sys.assert_not_locked(); + for (pfs_os_file_t d : deleted) + os_file_close(d); +} + +/** Commit a DDL transaction and unlink any deleted files. */ +static void commit_unlock_and_unlink(trx_t *trx) +{ + std::vector deleted; + trx->commit(deleted); + row_mysql_unlock_data_dictionary(trx); + close_unlinked_files(deleted); +} + /** Update internal structures with concurrent writes blocked, while preparing ALTER TABLE. @@ -6277,6 +6267,8 @@ prepare_inplace_alter_table_dict( mem_heap_alloc(ctx->heap, ctx->num_to_add_index * sizeof *ctx->add_key_numbers)); + const bool fts_exist = ctx->new_table->flags2 + & (DICT_TF2_FTS_HAS_DOC_ID | DICT_TF2_FTS); /* Acquire a lock on the table before creating any indexes. */ bool table_lock_failed = false; @@ -6284,15 +6276,21 @@ prepare_inplace_alter_table_dict( error = DB_SUCCESS; } else { ctx->prebuilt->trx->op_info = "acquiring table lock"; - error = lock_table_for_trx(ctx->new_table, - ctx->prebuilt->trx, LOCK_S); + error = lock_table_for_trx(ctx->new_table, ctx->trx, LOCK_S); + } - if (error != DB_SUCCESS) { - table_lock_failed = true; - goto error_handling; + if (fts_exist) { + purge_sys.stop_FTS(); + if (error == DB_SUCCESS) { + error = fts_lock_tables(ctx->trx, *ctx->new_table); } } + if (error != DB_SUCCESS) { + table_lock_failed = true; + goto error_handling; + } + /* Latch the InnoDB data dictionary exclusively so that no deadlocks or lock waits can happen in it during an index create operation. */ @@ -7086,22 +7084,28 @@ error_handling_drop_uncached: DBUG_ASSERT(error == DB_SUCCESS); - if (UT_LIST_GET_LEN(ctx->trx->lock.trx_locks)) { + { /* Commit the data dictionary transaction in order to release the table locks on the system tables. This means that if MariaDB is killed while rebuilding the table inside row_merge_build_indexes(), ctx->new_table will not be dropped by trx_rollback_active(). */ - trx_commit_for_mysql(ctx->trx); - trx_start_for_ddl(ctx->trx); - + ut_d(dict_table_check_for_dup_indexes(user_table, + CHECK_PARTIAL_OK)); if (ctx->need_rebuild()) { ctx->new_table->acquire(); } - } - ut_d(dict_table_check_for_dup_indexes(user_table, CHECK_PARTIAL_OK)); - row_mysql_unlock_data_dictionary(ctx->trx); + /* fts_create_common_tables() may drop old common tables, + whose files would be deleted here. */ + commit_unlock_and_unlink(ctx->trx); + if (fts_exist) { + purge_sys.resume_FTS(); + } + + trx_start_for_ddl(ctx->trx); + ctx->prebuilt->trx_id = ctx->trx->id; + } if (ctx->old_table->fts) { fts_sync_during_ddl(ctx->old_table); @@ -7190,6 +7194,9 @@ err_exit: ctx->trx->free(); } trx_commit_for_mysql(ctx->prebuilt->trx); + if (fts_exist) { + purge_sys.resume_FTS(); + } for (uint i = 0; i < ctx->num_to_add_fk; i++) { if (ctx->add_fk[i]) { @@ -8654,26 +8661,7 @@ innobase_rollback_sec_index( } } -/* Get the number of uncommitted fts index during rollback -operation. -@param[in] table table which undergoes rollback for alter -@return number of uncommitted fts indexes. */ -static -ulint innobase_get_uncommitted_fts_indexes(const dict_table_t* table) -{ - dict_sys.assert_locked(); - dict_index_t* index = dict_table_get_first_index(table); - ulint n_uncommitted_fts = 0; - - for (; index ; index = dict_table_get_next_index(index)) - { - if (index->type & DICT_FTS && !index->is_committed()) - n_uncommitted_fts++; - } - - return n_uncommitted_fts; -} - +MY_ATTRIBUTE((nonnull, warn_unused_result)) /** Roll back the changes made during prepare_inplace_alter_table() and inplace_alter_table() inside the storage engine. Note that the allowed level of concurrency during this operation will be the same as @@ -8687,162 +8675,150 @@ during prepare, but might not be during commit). @retval true Failure @retval false Success */ -inline MY_ATTRIBUTE((nonnull, warn_unused_result)) -bool -rollback_inplace_alter_table( -/*=========================*/ - Alter_inplace_info* ha_alter_info, - const TABLE* table, - row_prebuilt_t* prebuilt) +inline bool rollback_inplace_alter_table(Alter_inplace_info *ha_alter_info, + const TABLE *table, + row_prebuilt_t *prebuilt) { - bool fail = false; + bool fail= false; + ha_innobase_inplace_ctx *ctx= static_cast + (ha_alter_info->handler_ctx); - ha_innobase_inplace_ctx* ctx - = static_cast - (ha_alter_info->handler_ctx); + DBUG_ENTER("rollback_inplace_alter_table"); - DBUG_ENTER("rollback_inplace_alter_table"); + if (!ctx) + /* If we have not started a transaction yet, + (almost) nothing has been or needs to be done. */ + dict_sys.lock(SRW_LOCK_CALL); + else if (ctx->new_table) + { + ut_ad(ctx->trx->state == TRX_STATE_ACTIVE); + const bool fts_exist= (ctx->new_table->flags2 & + (DICT_TF2_FTS_HAS_DOC_ID | DICT_TF2_FTS)) || + ctx->adding_fulltext_index(); + if (fts_exist) + { + fts_optimize_remove_table(ctx->new_table); + purge_sys.stop_FTS(); + } + if (ctx->need_rebuild()) + { + dberr_t err= lock_table_for_trx(ctx->new_table, ctx->trx, LOCK_X); + if (fts_exist) + { + if (err == DB_SUCCESS) + err= fts_lock_common_tables(ctx->trx, *ctx->new_table); + for (const dict_index_t* index= ctx->new_table->indexes.start; + err == DB_SUCCESS && index; index= index->indexes.next) + if (index->type & DICT_FTS) + err= fts_lock_index_tables(ctx->trx, *index); + } + row_mysql_lock_data_dictionary(ctx->trx); + /* Detach ctx->new_table from dict_index_t::online_log. */ + innobase_online_rebuild_log_free(ctx->old_table); - if (!ctx) { - /* If we have not started a transaction yet, - (almost) nothing has been or needs to be done. */ - goto func_exit; - } + ut_d(const bool last_handle=) ctx->new_table->release(); + ut_ad(last_handle); + if (err == DB_SUCCESS) + err= ctx->trx->drop_table(*ctx->new_table); - row_mysql_lock_data_dictionary(ctx->trx); - ctx->trx->dict_operation = true; + if (err == DB_SUCCESS) + for (const dict_index_t* index= ctx->new_table->indexes.start; index; + index= index->indexes.next) + if (index->type & DICT_FTS) + if (dberr_t err2= fts_drop_index_tables(ctx->trx, *index)) + err= err2; - if (!ctx->new_table) { - } else if (ctx->need_rebuild()) { - /* DML threads can access ctx->new_table via the - online rebuild log. Free it first. */ - innobase_online_rebuild_log_free(prebuilt->table); - dberr_t err= DB_SUCCESS; - ulint flags = ctx->new_table->flags; + if (err != DB_SUCCESS) + { + my_error_innodb(err, table->s->table_name.str, ctx->new_table->flags); + fail= true; + } + } + else + { + DBUG_ASSERT(!(ha_alter_info->handler_flags & ALTER_ADD_PK_INDEX)); + DBUG_ASSERT(ctx->old_table == prebuilt->table); + if (fts_exist) + { + for (ulint a= 0; a < ctx->num_to_add_index; a++) + { + const dict_index_t *index = ctx->add_index[a]; + // FIXME: skip fts_drop_index_tables() if we failed to acquire locks + if (index->type & DICT_FTS) + fts_lock_index_tables(ctx->trx, *index); + } + // FIXME: skip fts_drop_tables() if we failed to acquire locks + fts_lock_common_tables(ctx->trx, *ctx->new_table); + } + row_mysql_lock_data_dictionary(ctx->trx); + ctx->rollback_instant(); + innobase_rollback_sec_index(ctx->old_table, table, + ha_alter_info->alter_info->requested_lock == + Alter_info::ALTER_TABLE_LOCK_EXCLUSIVE, + ctx->trx, prebuilt->trx); + ctx->clean_new_vcol_index(); + ut_d(dict_table_check_for_dup_indexes(ctx->old_table, CHECK_ABORTED_OK)); + } - /* Since the FTS index specific auxiliary tables has - not yet registered with "table->fts" by fts_add_index(), - we will need explicitly delete them here */ - if (dict_table_has_fts_index(ctx->new_table)) { + commit_unlock_and_unlink(ctx->trx); + if (fts_exist) + purge_sys.resume_FTS(); + if (ctx->old_table->fts) + { + dict_sys.mutex_lock(); + ut_ad(fts_check_cached_index(ctx->old_table)); + fts_optimize_add_table(ctx->old_table); + dict_sys.mutex_unlock(); + } + goto free_and_exit; + } + else + { +free_and_exit: + DBUG_ASSERT(ctx->prebuilt == prebuilt); + ctx->trx->free(); + ctx->trx= nullptr; - err = innobase_drop_fts_index_table( - ctx->new_table, ctx->trx); + dict_sys.lock(SRW_LOCK_CALL); - if (err != DB_SUCCESS) { - my_error_innodb( - err, table->s->table_name.str, - flags); - fail = true; - } - } + for (ulint i= 0; i < ctx->num_to_add_fk; i++) + dict_foreign_free(ctx->add_fk[i]); + /* Clear the to_be_dropped flags in the data dictionary cache. + The flags may already have been cleared, in case an error was + detected in commit_inplace_alter_table(). */ + for (ulint i= 0; i < ctx->num_to_drop_index; i++) + { + dict_index_t *index= ctx->drop_index[i]; + DBUG_ASSERT(index->is_committed()); + index->to_be_dropped= 0; + } + } - ut_d(const bool last_handle=) ctx->new_table->release(); - ut_ad(last_handle); - err = row_drop_table_for_mysql(ctx->new_table->name.m_name, - ctx->trx, SQLCOM_DROP_TABLE, - false, false); - if (err != DB_SUCCESS) { - my_error_innodb(err, table->s->table_name.str, - flags); - fail = true; - } - } else { - DBUG_ASSERT(!(ha_alter_info->handler_flags - & ALTER_ADD_PK_INDEX)); - DBUG_ASSERT(ctx->new_table == prebuilt->table); + DBUG_ASSERT(!prebuilt->table->indexes.start->online_log); + DBUG_ASSERT(prebuilt->table->indexes.start->online_status == + ONLINE_INDEX_COMPLETE); - /* Remove the fts table from fts_optimize_wq if - there is only one fts index exist. */ - if (prebuilt->table->fts - && innobase_get_uncommitted_fts_indexes( - prebuilt->table) == 1 - && (ib_vector_is_empty(prebuilt->table->fts->indexes) - || ib_vector_size(prebuilt->table->fts->indexes) - == 1)) { - row_mysql_unlock_data_dictionary(ctx->trx); - fts_optimize_remove_table(prebuilt->table); - row_mysql_lock_data_dictionary(ctx->trx); - } + /* Reset dict_col_t::ord_part for unindexed columns */ + for (ulint i= 0; i < dict_table_get_n_cols(prebuilt->table); i++) + { + dict_col_t &col= prebuilt->table->cols[i]; + if (col.ord_part && !check_col_exists_in_indexes(prebuilt->table, i, false, + true)) + col.ord_part= 0; + } - innobase_rollback_sec_index( - prebuilt->table, table, - (ha_alter_info->alter_info->requested_lock - == Alter_info::ALTER_TABLE_LOCK_EXCLUSIVE), - ctx->trx, prebuilt->trx); - - ctx->clean_new_vcol_index(); - } - - trx_commit_for_mysql(ctx->trx); - row_mysql_unlock_data_dictionary(ctx->trx); - ctx->trx->free(); - ctx->trx = NULL; - -func_exit: -#ifndef DBUG_OFF - dict_index_t* clust_index = dict_table_get_first_index( - prebuilt->table); - DBUG_ASSERT(!clust_index->online_log); - DBUG_ASSERT(dict_index_get_online_status(clust_index) - == ONLINE_INDEX_COMPLETE); -#endif /* !DBUG_OFF */ - - if (ctx) { - DBUG_ASSERT(ctx->prebuilt == prebuilt); - - if (ctx->num_to_add_fk) { - for (ulint i = 0; i < ctx->num_to_add_fk; i++) { - dict_foreign_free(ctx->add_fk[i]); - } - } - - if (ctx->num_to_drop_index) { - row_mysql_lock_data_dictionary(prebuilt->trx); - - /* Clear the to_be_dropped flags - in the data dictionary cache. - The flags may already have been cleared, - in case an error was detected in - commit_inplace_alter_table(). */ - for (ulint i = 0; i < ctx->num_to_drop_index; i++) { - dict_index_t* index = ctx->drop_index[i]; - DBUG_ASSERT(index->is_committed()); - index->to_be_dropped = 0; - } - - row_mysql_unlock_data_dictionary(prebuilt->trx); - } - } - - /* Reset dict_col_t::ord_part for those columns fail to be indexed, - we do this by checking every existing column, if any current - index would index them */ - for (ulint i = 0; i < dict_table_get_n_cols(prebuilt->table); i++) { - dict_col_t& col = prebuilt->table->cols[i]; - if (!col.ord_part) { - continue; - } - if (!check_col_exists_in_indexes(prebuilt->table, i, false, - true)) { - col.ord_part = 0; - } - } - - for (ulint i = 0; i < dict_table_get_n_v_cols(prebuilt->table); i++) { - dict_col_t& col = prebuilt->table->v_cols[i].m_col; - if (!col.ord_part) { - continue; - } - if (!check_col_exists_in_indexes(prebuilt->table, i, true, - true)) { - col.ord_part = 0; - } - } - - trx_commit_for_mysql(prebuilt->trx); - prebuilt->trx_id = 0; - MONITOR_ATOMIC_DEC(MONITOR_PENDING_ALTER_TABLE); - DBUG_RETURN(fail); + for (ulint i = 0; i < dict_table_get_n_v_cols(prebuilt->table); i++) + { + dict_col_t &col = prebuilt->table->v_cols[i].m_col; + if (col.ord_part && !check_col_exists_in_indexes(prebuilt->table, i, true, + true)) + col.ord_part= 0; + } + dict_sys.unlock(); + trx_commit_for_mysql(prebuilt->trx); + prebuilt->trx_id = 0; + MONITOR_ATOMIC_DEC(MONITOR_PENDING_ALTER_TABLE); + DBUG_RETURN(fail); } /** Drop a FOREIGN KEY constraint from the data dictionary tables. @@ -9679,8 +9655,6 @@ innobase_update_foreign_cache( column names. No need to pass col_names or to drop constraints from the data dictionary cache. */ DBUG_ASSERT(!ctx->col_names); - DBUG_ASSERT(user_table->foreign_set.empty()); - DBUG_ASSERT(user_table->referenced_set.empty()); user_table = ctx->new_table; } else { /* Drop the foreign key constraints if the @@ -9924,6 +9898,8 @@ commit_try_rebuild( DBUG_ASSERT(ctx->num_to_drop_fk <= ha_alter_info->alter_info->drop_list.elements); + innobase_online_rebuild_log_free(user_table); + for (dict_index_t* index = dict_table_get_first_index(rebuilt_table); index; index = dict_table_get_next_index(index)) { @@ -9957,8 +9933,6 @@ commit_try_rebuild( DBUG_RETURN(true); } - DBUG_EXECUTE_IF("ib_ddl_crash_before_rename", DBUG_SUICIDE();); - /* The new table must inherit the flag from the "parent" table. */ if (!user_table->space) { @@ -9966,31 +9940,27 @@ commit_try_rebuild( rebuilt_table->flags2 |= DICT_TF2_DISCARDED; } - dberr_t error = (ctx->old_table->flags2 & DICT_TF2_FTS) - ? fts_drop_tables(trx, ctx->old_table) - : DB_SUCCESS; + /* We can now rename the old table as a temporary table, + rename the new temporary table as the old table and drop the + old table. */ + char* old_name= mem_heap_strdup(ctx->heap, user_table->name.m_name); + dberr_t error = row_rename_table_for_mysql(user_table->name.m_name, + ctx->tmp_name, trx, false); if (error == DB_SUCCESS) { - /* We can now rename the old table as a temporary table, - rename the new temporary table as the old table and drop the - old table. */ - char* old_name= mem_heap_strdup(ctx->heap, - user_table->name.m_name); - - error = row_rename_table_for_mysql(user_table->name.m_name, - ctx->tmp_name, trx, - false, false); + error = row_rename_table_for_mysql( + rebuilt_table->name.m_name, old_name, trx, false); if (error == DB_SUCCESS) { - error = row_rename_table_for_mysql( - rebuilt_table->name.m_name, old_name, trx, - false, false); + error = trx->drop_table_statistics( + ctx->old_table->name); + if (error == DB_SUCCESS) { + error = trx->drop_table(*ctx->old_table); + } } } /* We must be still holding a table handle. */ DBUG_ASSERT(user_table->get_ref_count() == 1); - - DBUG_EXECUTE_IF("ib_ddl_crash_after_rename", DBUG_SUICIDE();); DBUG_EXECUTE_IF("ib_rebuild_cannot_rename", error = DB_ERROR;); switch (error) { @@ -10139,22 +10109,6 @@ innobase_page_compression_try( DBUG_RETURN(false); } -static -void -dict_stats_try_drop_table(THD *thd, const table_name_t &name, - const LEX_CSTRING &table_name) -{ - char errstr[1024]; - if (dict_stats_drop_table(name.m_name, errstr, sizeof(errstr)) != DB_SUCCESS) - { - push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, ER_ALTER_INFO, - "Deleting persistent statistics" - " for table '%s' in InnoDB failed: %s", - table_name.str, - errstr); - } -} - /** Evict the table from cache and reopen it. Drop outdated statistics. @param thd mariadb THD entity @param table innodb table @@ -10165,26 +10119,19 @@ static dict_table_t *innobase_reload_table(THD *thd, dict_table_t *table, const LEX_CSTRING &table_name, ha_innobase_inplace_ctx &ctx) { - char *tb_name= strdup(table->name.m_name); - dict_table_close(table, true, false); - if (ctx.is_instant()) { - for (auto i = ctx.old_n_v_cols; i--; ) + for (auto i= ctx.old_n_v_cols; i--; ) { ctx.old_v_cols[i].~dict_v_col_t(); - const_cast(ctx.old_n_v_cols) = 0; + const_cast(ctx.old_n_v_cols)= 0; } } + const table_id_t id= table->id; + table->release(); dict_sys.remove(table); - table= dict_table_open_on_name(tb_name, TRUE, TRUE, - DICT_ERR_IGNORE_FK_NOKEY); - - /* Drop outdated table stats. */ - dict_stats_try_drop_table(thd, table->name, table_name); - free(tb_name); - return table; + return dict_table_open_on_id(id, true, DICT_TABLE_OP_NORMAL); } /** Commit the changes made during prepare_inplace_alter_table() @@ -10259,7 +10206,7 @@ commit_try_norebuild( DBUG_RETURN(true); } - dberr_t error; + dberr_t error = DB_SUCCESS; dict_index_t* index; const char *op = "rename index to add"; ulint num_fts_index = 0; @@ -10284,6 +10231,12 @@ commit_try_norebuild( } } + char db[MAX_DB_UTF8_LEN], table[MAX_TABLE_UTF8_LEN]; + if (ctx->num_to_drop_index) { + dict_fs2utf8(ctx->old_table->name.m_name, + db, sizeof db, table, sizeof table); + } + for (ulint i = 0; i < ctx->num_to_drop_index; i++) { index = ctx->drop_index[i]; DBUG_ASSERT(index->is_committed()); @@ -10313,16 +10266,66 @@ commit_try_norebuild( if (error != DB_SUCCESS) { goto handle_error; } + + error = dict_stats_delete_from_index_stats(db, table, + index->name, trx); + switch (error) { + case DB_SUCCESS: + case DB_STATS_DO_NOT_EXIST: + continue; + default: + goto handle_error; + } + } + + if (const size_t size = ha_alter_info->rename_keys.size()) { + char tmp_name[5]; + char db[MAX_DB_UTF8_LEN], table[MAX_TABLE_UTF8_LEN]; + + dict_fs2utf8(ctx->new_table->name.m_name, db, sizeof db, + table, sizeof table); + + for (size_t i = 0; error == DB_SUCCESS && i < size; i++) { + snprintf(tmp_name, sizeof tmp_name, "\xff%zu", i); + error = dict_stats_rename_index(db, table, + ha_alter_info-> + rename_keys[i]. + old_key->name.str, + tmp_name, trx); + } + for (size_t i = 0; error == DB_SUCCESS && i < size; i++) { + snprintf(tmp_name, sizeof tmp_name, "\xff%zu", i); + error = dict_stats_rename_index(db, table, tmp_name, + ha_alter_info + ->rename_keys[i]. + new_key->name.str, + trx); + } + + switch (error) { + case DB_SUCCESS: + case DB_STATS_DO_NOT_EXIST: + break; + case DB_DUPLICATE_KEY: + my_error(ER_DUP_KEY, MYF(0), + "mysql.innodb_index_stats"); + DBUG_RETURN(true); + default: + goto handle_error; + } } if ((ctx->old_table->flags2 & DICT_TF2_FTS) && !num_fts_index) { - error = fts_drop_tables(trx, ctx->old_table); + error = fts_drop_tables(trx, *ctx->old_table); if (error != DB_SUCCESS) { handle_error: switch (error) { case DB_TOO_MANY_CONCURRENT_TRXS: my_error(ER_TOO_MANY_CONCURRENT_TRXS, MYF(0)); break; + case DB_LOCK_WAIT_TIMEOUT: + my_error(ER_LOCK_WAIT_TIMEOUT, MYF(0)); + break; default: sql_print_error("InnoDB: %s: %s\n", op, ut_strerr(error)); @@ -10598,8 +10601,6 @@ alter_stats_norebuild( ha_innobase_inplace_ctx* ctx, THD* thd) { - ulint i; - DBUG_ENTER("alter_stats_norebuild"); DBUG_ASSERT(!ctx->need_rebuild()); @@ -10607,98 +10608,7 @@ alter_stats_norebuild( DBUG_VOID_RETURN; } - /* Delete corresponding rows from the stats table. We do this - in a separate transaction from trx, because lock waits are not - allowed in a data dictionary transaction. (Lock waits are possible - on the statistics table, because it is directly accessible by users, - not covered by the dict_sys.latch.) - - Because the data dictionary changes were already committed, orphaned - rows may be left in the statistics table if the system crashes. - - FIXME: each change to the statistics tables is being committed in a - separate transaction, meaning that the operation is not atomic - - FIXME: This will not drop the (unused) statistics for - FTS_DOC_ID_INDEX if it was a hidden index, dropped together - with the last renamining FULLTEXT index. */ - for (i = 0; i < ha_alter_info->index_drop_count; i++) { - const KEY* key = ha_alter_info->index_drop_buffer[i]; - - if (key->flags & HA_FULLTEXT) { - /* There are no index cardinality - statistics for FULLTEXT indexes. */ - continue; - } - - char errstr[1024]; - - if (dict_stats_drop_index( - ctx->new_table->name.m_name, key->name.str, - errstr, sizeof errstr) != DB_SUCCESS) { - push_warning(thd, - Sql_condition::WARN_LEVEL_WARN, - ER_LOCK_WAIT_TIMEOUT, errstr); - } - } - - for (size_t i = 0; i < ha_alter_info->rename_keys.size(); i++) { - const Alter_inplace_info::Rename_key_pair& pair - = ha_alter_info->rename_keys[i]; - - std::stringstream ss; - ss << TEMP_FILE_PREFIX_INNODB << std::this_thread::get_id() - << i; - auto tmp_name = ss.str(); - - dberr_t err = dict_stats_rename_index(ctx->new_table, - pair.old_key->name.str, - tmp_name.c_str()); - - if (err != DB_SUCCESS) { - push_warning_printf( - thd, - Sql_condition::WARN_LEVEL_WARN, - ER_ERROR_ON_RENAME, - "Error renaming an index of table '%s'" - " from '%s' to '%s' in InnoDB persistent" - " statistics storage: %s", - ctx->new_table->name.m_name, - pair.old_key->name.str, - tmp_name.c_str(), - ut_strerr(err)); - } - } - - for (size_t i = 0; i < ha_alter_info->rename_keys.size(); i++) { - const Alter_inplace_info::Rename_key_pair& pair - = ha_alter_info->rename_keys[i]; - - std::stringstream ss; - ss << TEMP_FILE_PREFIX_INNODB << std::this_thread::get_id() - << i; - auto tmp_name = ss.str(); - - dberr_t err = dict_stats_rename_index(ctx->new_table, - tmp_name.c_str(), - pair.new_key->name.str); - - if (err != DB_SUCCESS) { - push_warning_printf( - thd, - Sql_condition::WARN_LEVEL_WARN, - ER_ERROR_ON_RENAME, - "Error renaming an index of table '%s'" - " from '%s' to '%s' in InnoDB persistent" - " statistics storage: %s", - ctx->new_table->name.m_name, - tmp_name.c_str(), - pair.new_key->name.str, - ut_strerr(err)); - } - } - - for (i = 0; i < ctx->num_to_add_index; i++) { + for (ulint i = 0; i < ctx->num_to_add_index; i++) { dict_index_t* index = ctx->add_index[i]; DBUG_ASSERT(index->table == ctx->new_table); @@ -10748,17 +10658,6 @@ alter_stats_rebuild( DBUG_VOID_RETURN; } -#ifndef DBUG_OFF -# define DBUG_INJECT_CRASH(prefix, count) \ -do { \ - char buf[32]; \ - snprintf(buf, sizeof buf, prefix "_%u", count); \ - DBUG_EXECUTE_IF(buf, DBUG_SUICIDE();); \ -} while (0) -#else -# define DBUG_INJECT_CRASH(prefix, count) -#endif - /** Apply the log for the table rebuild operation. @param[in] ctx Inplace Alter table context @param[in] altered_table MySQL table that is being altered @@ -10872,8 +10771,6 @@ ha_innobase::commit_inplace_alter_table( (ha_alter_info->handler_ctx); #ifndef DBUG_OFF - uint crash_inject_count = 1; - uint crash_fail_inject_count = 1; uint failure_inject_count = 1; #endif /* DBUG_OFF */ @@ -10892,12 +10789,10 @@ ha_innobase::commit_inplace_alter_table( if (!commit) { /* A rollback is being requested. So far we may at - most have created some indexes. If any indexes were to - be dropped, they would actually be dropped in this - method if commit=true. */ - const bool ret = rollback_inplace_alter_table( - ha_alter_info, table, m_prebuilt); - DBUG_RETURN(ret); + most have created stubs for ADD INDEX or a copy of the + table for rebuild. */ + DBUG_RETURN(rollback_inplace_alter_table( + ha_alter_info, table, m_prebuilt)); } if (!(ha_alter_info->handler_flags & ~INNOBASE_INPLACE_IGNORE)) { @@ -10924,15 +10819,15 @@ ha_innobase::commit_inplace_alter_table( ut_ad(m_prebuilt->table == ctx0->old_table); ha_alter_info->group_commit_ctx = NULL; - trx_start_if_not_started_xa(m_prebuilt->trx, true); const bool new_clustered = ctx0->need_rebuild(); - + trx_t* const trx = ctx0->trx; + trx->op_info = "acquiring table lock"; + bool fts_exist = false; for (inplace_alter_handler_ctx** pctx = ctx_array; *pctx; pctx++) { - ha_innobase_inplace_ctx* ctx - = static_cast(*pctx); + auto ctx = static_cast(*pctx); DBUG_ASSERT(ctx->prebuilt->trx == m_prebuilt->trx); + ut_ad(m_prebuilt != ctx->prebuilt || ctx == ctx0); DBUG_ASSERT(new_clustered == ctx->need_rebuild()); - /* If decryption failed for old table or new table fail here. */ if ((!ctx->old_table->is_readable() @@ -10945,44 +10840,22 @@ ha_innobase::commit_inplace_alter_table( my_error(ER_GET_ERRMSG, MYF(0), HA_ERR_DECRYPTION_FAILED, str.c_ptr(), engine); DBUG_RETURN(true); } - - if (new_clustered) { - continue; - } - - /* Exclusively lock the table, to ensure that no other - transaction is holding locks on the table while we - change the table definition. Any recovered incomplete - transactions would be holding InnoDB locks only, not MDL. */ - ctx->prebuilt->trx->op_info = "acquiring table lock"; - - if (dberr_t error = lock_table_for_trx(ctx->new_table, - ctx->prebuilt->trx, - LOCK_X)) { - my_error_innodb( - error, table_share->table_name.str, 0); - DBUG_RETURN(true); + if ((ctx->old_table->flags2 | ctx->new_table->flags2) + & (DICT_TF2_FTS_HAS_DOC_ID | DICT_TF2_FTS)) { + fts_exist = true; } } - DEBUG_SYNC(m_user_thd, "innodb_alter_commit_after_lock_table"); + if (fts_exist) { + purge_sys.stop_FTS(); + } - trx_t* trx = ctx0->trx; - bool fail = false; + for (inplace_alter_handler_ctx** pctx = ctx_array; *pctx; pctx++) { + auto ctx = static_cast(*pctx); - /* Stop background FTS operations. */ - for (inplace_alter_handler_ctx** pctx = ctx_array; - *pctx; pctx++) { - ha_innobase_inplace_ctx* ctx - = static_cast(*pctx); - - DBUG_ASSERT(new_clustered == ctx->need_rebuild()); - - if (new_clustered) { - if (ctx->old_table->fts) { - ut_ad(!ctx->old_table->fts->add_wq); - fts_optimize_remove_table(ctx->old_table); - } + if (new_clustered && ctx->old_table->fts) { + ut_ad(!ctx->old_table->fts->add_wq); + fts_optimize_remove_table(ctx->old_table); } if (ctx->new_table->fts) { @@ -10991,26 +10864,55 @@ ha_innobase::commit_inplace_alter_table( fts_sync_during_ddl(ctx->new_table); } - /* Apply the online log of the table before acquiring - data dictionary latches. Here alter thread already acquired - MDL_EXCLUSIVE on the table. So there can't be anymore DDLs, DMLs - for the altered table. By applying the log here, InnoDB - makes sure that concurrent DDLs, purge thread or any other - background thread doesn't wait for the dict_operation_lock - for longer time. */ - if (new_clustered && commit - && alter_rebuild_apply_log( - ctx, ha_alter_info, altered_table)) { + /* Exclusively lock the table, to ensure that no other + transaction is holding locks on the table while we + change the table definition. Any recovered incomplete + transactions would be holding InnoDB locks only, not MDL. */ + + if (dberr_t error = lock_table_for_trx(ctx->new_table, trx, + LOCK_X)) { +lock_fail: + my_error_innodb( + error, table_share->table_name.str, 0); DBUG_RETURN(true); + } else if ((ctx->new_table->flags2 + & (DICT_TF2_FTS_HAS_DOC_ID | DICT_TF2_FTS)) + && (error = fts_lock_tables(trx, *ctx->new_table)) + != DB_SUCCESS) { + goto lock_fail; + } else if (!new_clustered) { + } else if ((error = lock_table_for_trx(ctx->old_table, trx, + LOCK_X)) + != DB_SUCCESS) { + goto lock_fail; + } else if ((ctx->old_table->flags2 + & (DICT_TF2_FTS_HAS_DOC_ID | DICT_TF2_FTS)) + && (error = fts_lock_tables(trx, *ctx->old_table)) + != DB_SUCCESS) { + goto lock_fail; + } + } + + DEBUG_SYNC(m_user_thd, "innodb_alter_commit_after_lock_table"); + + if (new_clustered) { + /* We are holding MDL_EXCLUSIVE as well as exclusive + InnoDB table locks. Let us apply any table rebuild log + before locking dict_sys. */ + for (inplace_alter_handler_ctx** pctx= ctx_array; *pctx; + pctx++) { + auto ctx= static_cast(*pctx); + DBUG_ASSERT(ctx->need_rebuild()); + if (alter_rebuild_apply_log(ctx, ha_alter_info, + altered_table)) { + DBUG_RETURN(true); + } } } /* Latch the InnoDB data dictionary exclusively so that no deadlocks or lock waits can happen in it during the data dictionary operation. */ row_mysql_lock_data_dictionary(trx); - if (trx->state != TRX_STATE_ACTIVE) { - trx_start_for_ddl(trx); - } /* Prevent the background statistics collection from accessing the tables. */ @@ -11043,38 +10945,45 @@ ha_innobase::commit_inplace_alter_table( /* Apply the changes to the data dictionary tables, for all partitions. */ - - for (inplace_alter_handler_ctx** pctx = ctx_array; - *pctx && !fail; pctx++) { - ha_innobase_inplace_ctx* ctx - = static_cast(*pctx); + for (inplace_alter_handler_ctx** pctx = ctx_array; *pctx; pctx++) { + auto ctx = static_cast(*pctx); DBUG_ASSERT(new_clustered == ctx->need_rebuild()); if (ctx->need_rebuild() && !ctx->old_table->space) { my_error(ER_TABLESPACE_DISCARDED, MYF(0), table->s->table_name.str); - fail = true; - } else { - fail = commit_set_autoinc(ha_alter_info, ctx, - altered_table, table); +fail: + trx->rollback(); + ut_ad(!trx->fts_trx); + row_mysql_unlock_data_dictionary(trx); + if (fts_exist) { + purge_sys.resume_FTS(); + } + trx_start_for_ddl(trx); + DBUG_RETURN(true); } - if (fail) { - } else if (ctx->need_rebuild()) { + if (commit_set_autoinc(ha_alter_info, ctx, + altered_table, table)) { + goto fail; + } + + if (ctx->need_rebuild()) { ctx->tmp_name = dict_mem_create_temporary_tablename( ctx->heap, ctx->new_table->name.m_name, ctx->new_table->id); - fail = commit_try_rebuild( - ha_alter_info, ctx, altered_table, table, - trx, table_share->table_name.str); - } else { - fail = commit_try_norebuild( - ha_alter_info, ctx, altered_table, table, trx, - table_share->table_name.str); + if (commit_try_rebuild(ha_alter_info, ctx, + altered_table, table, + trx, + table_share->table_name.str)) { + goto fail; + } + } else if (commit_try_norebuild(ha_alter_info, ctx, + altered_table, table, trx, + table_share->table_name.str)) { + goto fail; } - DBUG_INJECT_CRASH("ib_commit_inplace_crash", - crash_inject_count++); #ifndef DBUG_OFF { /* Generate a dynamic dbug text. */ @@ -11087,7 +10996,7 @@ ha_innobase::commit_inplace_alter_table( DBUG_EXECUTE_IF(buf, my_error(ER_INTERNAL_ERROR, MYF(0), "Injected error!"); - fail = true; + goto fail; ); } #endif @@ -11096,52 +11005,56 @@ ha_innobase::commit_inplace_alter_table( /* Commit or roll back the changes to the data dictionary. */ DEBUG_SYNC(m_user_thd, "innodb_alter_inplace_before_commit"); - if (fail) { - trx_rollback_for_mysql(trx); - for (inplace_alter_handler_ctx** pctx = ctx_array; - *pctx; pctx++) { - ha_innobase_inplace_ctx* ctx - = static_cast(*pctx); - ctx->rollback_instant(); + if (new_clustered) { + ut_ad(trx->has_logged()); + for (inplace_alter_handler_ctx** pctx = ctx_array; *pctx; + pctx++) { + auto ctx= static_cast(*pctx); + ut_ad(!strcmp(ctx->old_table->name.m_name, + ctx->tmp_name)); + ut_ad(ctx->new_table->get_ref_count() == 1); + const bool own = m_prebuilt == ctx->prebuilt; + trx_t* const user_trx = m_prebuilt->trx; + row_prebuilt_free(ctx->prebuilt, true); + /* Rebuild the prebuilt object. */ + ctx->prebuilt = row_create_prebuilt( + ctx->new_table, altered_table->s->reclength); + if (own) { + m_prebuilt = ctx->prebuilt; + } + trx_start_if_not_started(user_trx, true); + m_prebuilt->trx = user_trx; } - } else { - /* Test what happens on crash if the redo logs - are flushed to disk here. The log records - about the rename should not be committed, and - the data dictionary transaction should be - rolled back, restoring the old table. */ - DBUG_EXECUTE_IF("innodb_alter_commit_crash_before_commit", - log_buffer_flush_to_disk(); - DBUG_SUICIDE();); - ut_ad(!trx->fts_trx); - - ut_ad(trx_state_eq(trx, TRX_STATE_ACTIVE)); - ut_ad(!new_clustered || trx->has_logged()); - /* The SQL layer recovery of ALTER TABLE will invoke - innodb_check_version() to know whether our trx->id, which we - reported via ha_innobase::table_version() after - ha_innobase::prepare_inplace_alter_table(), was committed. - - If this trx was committed (the log write below completed), - we will be able to recover our trx->id to - dict_table_t::def_trx_id from the data dictionary tables. - - For this logic to work, purge_sys.stop_SYS() and - purge_sys.resume_SYS() will ensure that the DB_TRX_ID that we - wrote to the SYS_ tables will be preserved until the SQL layer - has durably marked the ALTER TABLE operation as completed. - - During recovery, the purge of InnoDB transaction history will - not start until innodb_ddl_recovery_done(). */ - ha_alter_info->inplace_alter_table_committed = - purge_sys.resume_SYS; - purge_sys.stop_SYS(); - trx->commit(); - log_write_up_to(trx->commit_lsn, true); - DBUG_EXECUTE_IF("innodb_alter_commit_crash_after_commit", - DBUG_SUICIDE();); } + ut_ad(!trx->fts_trx); + + std::vector deleted; + DBUG_EXECUTE_IF("innodb_alter_commit_crash_before_commit", + log_buffer_flush_to_disk(); DBUG_SUICIDE();); + /* The SQL layer recovery of ALTER TABLE will invoke + innodb_check_version() to know whether our trx->id, which we + reported via ha_innobase::table_version() after + ha_innobase::prepare_inplace_alter_table(), was committed. + + If this trx was committed (the log write below completed), + we will be able to recover our trx->id to + dict_table_t::def_trx_id from the data dictionary tables. + + For this logic to work, purge_sys.stop_SYS() and + purge_sys.resume_SYS() will ensure that the DB_TRX_ID that we + wrote to the SYS_ tables will be preserved until the SQL layer + has durably marked the ALTER TABLE operation as completed. + + During recovery, the purge of InnoDB transaction history will + not start until innodb_ddl_recovery_done(). */ + ha_alter_info->inplace_alter_table_committed = purge_sys.resume_SYS; + purge_sys.stop_SYS(); + trx->commit(deleted); + log_write_up_to(trx->commit_lsn, true); + DBUG_EXECUTE_IF("innodb_alter_commit_crash_after_commit", + DBUG_SUICIDE();); + /* At this point, the changes to the persistent storage have been committed or rolled back. What remains to be done is to update the in-memory structures, close some handles, release @@ -11154,55 +11067,10 @@ ha_innobase::commit_inplace_alter_table( DBUG_ASSERT(ctx->need_rebuild() == new_clustered); - if (new_clustered) { - innobase_online_rebuild_log_free(ctx->old_table); - } - - if (fail) { - if (new_clustered) { - trx_start_for_ddl(trx); - - ut_d(const bool last_handle=) - ctx->new_table->release(); - ut_ad(last_handle); - row_drop_table_for_mysql( - ctx->new_table->name.m_name, - trx, SQLCOM_DROP_TABLE, false, false); - - trx_commit_for_mysql(trx); - ctx->new_table = NULL; - } else { - /* We failed, but did not rebuild the table. - Roll back any ADD INDEX, or get rid of garbage - ADD INDEX that was left over from a previous - ALTER TABLE statement. */ - trx_start_for_ddl(trx); - innobase_rollback_sec_index( - ctx->new_table, table, TRUE, trx); - trx_commit_for_mysql(trx); - } - DBUG_INJECT_CRASH("ib_commit_inplace_crash_fail", - crash_fail_inject_count++); - - continue; - } - innobase_copy_frm_flags_from_table_share( ctx->new_table, altered_table->s); if (new_clustered) { - /* We will reload and refresh the - in-memory foreign key constraint - metadata. This is a rename operation - in preparing for dropping the old - table. Set the table to_be_dropped bit - here, so to make sure DML foreign key - constraint check does not use the - stale dict_foreign_t. This is done - because WL#6049 (FK MDL) has not been - implemented yet. */ - ctx->old_table->to_be_dropped = true; - DBUG_PRINT("to_be_dropped", ("table: %s", ctx->old_table->name.m_name)); @@ -11234,42 +11102,10 @@ foreign_fail: dict_mem_table_free_foreign_vcol_set(ctx->new_table); dict_mem_table_fill_foreign_vcol_set(ctx->new_table); - - DBUG_INJECT_CRASH("ib_commit_inplace_crash", - crash_inject_count++); } - if (fail) { - for (inplace_alter_handler_ctx** pctx = ctx_array; - *pctx; pctx++) { - ha_innobase_inplace_ctx* ctx - = static_cast - (*pctx); - DBUG_ASSERT(ctx->need_rebuild() == new_clustered); - - ut_d(dict_table_check_for_dup_indexes( - ctx->old_table, - CHECK_ABORTED_OK)); - ut_a(fts_check_cached_index(ctx->old_table)); - DBUG_INJECT_CRASH("ib_commit_inplace_crash_fail", - crash_fail_inject_count++); - - /* Restart the FTS background operations. */ - if (ctx->old_table->fts) { - fts_optimize_add_table(ctx->old_table); - } - } - - row_mysql_unlock_data_dictionary(trx); - if (trx != ctx0->trx) { - trx->free(); - } - DBUG_RETURN(true); - } - - if (trx == ctx0->trx) { - ctx0->trx = NULL; - } + ut_ad(trx == ctx0->trx); + ctx0->trx = nullptr; /* Free the ctx->trx of other partitions, if any. We will only use the ctx0->trx here. Others may have been allocated in @@ -11299,7 +11135,6 @@ foreign_fail: && ha_alter_info->handler_flags & ALTER_STORED_COLUMN_ORDER)) { DBUG_ASSERT(ctx0->old_table->get_ref_count() == 1); ut_ad(ctx0->prebuilt == m_prebuilt); - trx_commit_for_mysql(m_prebuilt->trx); for (inplace_alter_handler_ctx** pctx = ctx_array; *pctx; pctx++) { @@ -11313,15 +11148,14 @@ foreign_fail: row_mysql_unlock_data_dictionary(trx); trx->free(); + close_unlinked_files(deleted); + if (fts_exist) { + purge_sys.resume_FTS(); + } MONITOR_ATOMIC_DEC(MONITOR_PENDING_ALTER_TABLE); DBUG_RETURN(false); } - /* Release the table locks. */ - trx_commit_for_mysql(m_prebuilt->trx); - - DBUG_EXECUTE_IF("ib_ddl_crash_after_user_trx_commit", DBUG_SUICIDE();); - for (inplace_alter_handler_ctx** pctx = ctx_array; *pctx; pctx++) { ha_innobase_inplace_ctx* ctx @@ -11363,63 +11197,14 @@ foreign_fail: ut_a(fts_check_cached_index(ctx->new_table)); } #endif - if (new_clustered) { - /* Since the table has been rebuilt, we remove - all persistent statistics corresponding to the - old copy of the table (which was renamed to - ctx->tmp_name). */ - - DBUG_ASSERT(0 == strcmp(ctx->old_table->name.m_name, - ctx->tmp_name)); - - dict_stats_try_drop_table(m_user_thd, - ctx->new_table->name, - table->s->table_name); - - DBUG_EXECUTE_IF("ib_ddl_crash_before_commit", - DBUG_SUICIDE();); - - ut_ad(m_prebuilt != ctx->prebuilt - || ctx == ctx0); - bool update_own_prebuilt = - (m_prebuilt == ctx->prebuilt); - trx_t* const user_trx = m_prebuilt->trx; - - row_prebuilt_free(ctx->prebuilt, TRUE); - - /* Drop the copy of the old table, which was - renamed to ctx->tmp_name at the atomic DDL - transaction commit. If the system crashes - before this is completed, some orphan tables - with ctx->tmp_name may be recovered. */ - trx_start_for_ddl(trx); - if (dberr_t error = row_drop_table_for_mysql( - ctx->old_table->name.m_name, - trx, SQLCOM_DROP_TABLE, false, false)) { - ib::error() << "Inplace alter table " << ctx->old_table->name - << " dropping copy of the old table failed error " - << error - << ". tmp_name " << (ctx->tmp_name ? ctx->tmp_name : "N/A") - << " new_table " << ctx->new_table->name; - } - - trx_commit_for_mysql(trx); - - /* Rebuild the prebuilt object. */ - ctx->prebuilt = row_create_prebuilt( - ctx->new_table, altered_table->s->reclength); - if (update_own_prebuilt) { - m_prebuilt = ctx->prebuilt; - } - trx_start_if_not_started(user_trx, true); - m_prebuilt->trx = user_trx; - } - DBUG_INJECT_CRASH("ib_commit_inplace_crash", - crash_inject_count++); } row_mysql_unlock_data_dictionary(trx); trx->free(); + close_unlinked_files(deleted); + if (fts_exist) { + purge_sys.resume_FTS(); + } /* TODO: The following code could be executed while allowing concurrent access to the table @@ -11436,8 +11221,6 @@ foreign_fail: alter_stats_rebuild( ctx->new_table, table->s->table_name.str, m_user_thd); - DBUG_INJECT_CRASH("ib_commit_inplace_crash", - crash_inject_count++); } } else { for (inplace_alter_handler_ctx** pctx = ctx_array; @@ -11448,8 +11231,6 @@ foreign_fail: DBUG_ASSERT(!ctx->need_rebuild()); alter_stats_norebuild(ha_alter_info, ctx, m_user_thd); - DBUG_INJECT_CRASH("ib_commit_inplace_crash", - crash_inject_count++); } } diff --git a/storage/innobase/include/btr0btr.h b/storage/innobase/include/btr0btr.h index 28cb80ba65c..1c5533ecd59 100644 --- a/storage/innobase/include/btr0btr.h +++ b/storage/innobase/include/btr0btr.h @@ -337,9 +337,9 @@ btr_create( void btr_free_if_exists(fil_space_t *space, uint32_t page, index_id_t index_id, mtr_t *mtr); -/** Free an index tree in a temporary tablespace. -@param[in] page_id root page id */ -void btr_free(const page_id_t page_id); +/** Drop a temporary table +@param table temporary table */ +void btr_drop_temporary_table(const dict_table_t &table); /** Read the last used AUTO_INCREMENT value from PAGE_ROOT_AUTO_INC. @param[in,out] index clustered index diff --git a/storage/innobase/include/btr0sea.h b/storage/innobase/include/btr0sea.h index 2f27395155f..da7bbac1f83 100644 --- a/storage/innobase/include/btr0sea.h +++ b/storage/innobase/include/btr0sea.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2020, MariaDB Corporation. +Copyright (c) 2017, 2021, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -128,7 +128,7 @@ void btr_search_update_hash_on_insert(btr_cur_t *cursor, /** Updates the page hash index when a single record is deleted from a page. @param[in] cursor cursor which was positioned on the record to delete using btr_cur_search_, the record is not yet deleted.*/ -void btr_search_update_hash_on_delete(btr_cur_t* cursor); +void btr_search_update_hash_on_delete(btr_cur_t *cursor); /** Validates the search system. @return true if ok */ diff --git a/storage/innobase/include/btr0sea.ic b/storage/innobase/include/btr0sea.ic index 0f972528ce2..5a8d648029a 100644 --- a/storage/innobase/include/btr0sea.ic +++ b/storage/innobase/include/btr0sea.ic @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2018, 2020, MariaDB Corporation. +Copyright (c) 2018, 2021, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -47,8 +47,7 @@ static inline btr_search_t* btr_search_info_create(mem_heap_t* heap) /** Updates the search info. @param[in,out] info search info @param[in,out] cursor cursor which was just positioned */ -void -btr_search_info_update_slow(btr_search_t* info, btr_cur_t* cursor); +void btr_search_info_update_slow(btr_search_t *info, btr_cur_t *cursor); /*********************************************************************//** Updates the search info. */ @@ -59,7 +58,10 @@ btr_search_info_update( dict_index_t* index, /*!< in: index of the cursor */ btr_cur_t* cursor) /*!< in: cursor which was just positioned */ { - if (dict_index_is_spatial(index) || !btr_search_enabled) { + ut_ad(!index->is_spatial()); + ut_ad(!index->table->is_temporary()); + + if (!btr_search_enabled) { return; } diff --git a/storage/innobase/include/db0err.h b/storage/innobase/include/db0err.h index 98d02e3a767..bd5eb0688cb 100644 --- a/storage/innobase/include/db0err.h +++ b/storage/innobase/include/db0err.h @@ -118,8 +118,6 @@ enum dberr_t { DB_READ_ONLY, /*!< Update operation attempted in a read-only transaction */ DB_FTS_INVALID_DOCID, /* FTS Doc ID cannot be zero */ - DB_TABLE_IN_FK_CHECK, /* table is being used in foreign - key check */ DB_ONLINE_LOG_TOO_BIG, /*!< Modification log grew too big during online index creation */ diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h index 867826f92d6..5424fce9ba3 100644 --- a/storage/innobase/include/dict0mem.h +++ b/storage/innobase/include/dict0mem.h @@ -1000,15 +1000,6 @@ struct dict_index_t { representation we add more columns */ unsigned nulls_equal:1; /*!< if true, SQL NULL == SQL NULL */ -#ifdef BTR_CUR_HASH_ADAPT -#ifdef MYSQL_INDEX_DISABLE_AHI - unsigned disable_ahi:1; - /*!< whether to disable the - adaptive hash index. - Maybe this could be disabled for - temporary tables? */ -#endif -#endif /* BTR_CUR_HASH_ADAPT */ unsigned n_uniq:10;/*!< number of fields from the beginning which are enough to determine an index entry uniquely */ @@ -1958,23 +1949,6 @@ struct dict_table_t { return versioned() && cols[vers_start].mtype == DATA_INT; } - void inc_fk_checks() - { -#ifdef UNIV_DEBUG - int32_t fk_checks= -#endif - n_foreign_key_checks_running++; - ut_ad(fk_checks >= 0); - } - void dec_fk_checks() - { -#ifdef UNIV_DEBUG - int32_t fk_checks= -#endif - n_foreign_key_checks_running--; - ut_ad(fk_checks > 0); - } - /** For overflow fields returns potential max length stored inline */ inline size_t get_overflow_field_local_len() const; @@ -2049,7 +2023,7 @@ public: table_id_t id; /** dict_sys.id_hash chain node */ dict_table_t* id_hash; - /** Table name. */ + /** Table name in name_hash */ table_name_t name; /** dict_sys.name_hash chain node */ dict_table_t* name_hash; @@ -2100,12 +2074,6 @@ public: /** TRUE if the table object has been added to the dictionary cache. */ unsigned cached:1; - /** TRUE if the table is to be dropped, but not yet actually dropped - (could in the background drop list). It is turned on at the beginning - of row_drop_table_for_mysql() and turned off just before we start to - update system tables for the drop. It is protected by dict_sys.latch. */ - unsigned to_be_dropped:1; - /** Number of non-virtual columns defined so far. */ unsigned n_def:10; @@ -2202,11 +2170,6 @@ public: loading child table into memory along with its parent table. */ byte fk_max_recusive_level; - /** Count of how many foreign key check operations are currently being - performed on the table. We cannot drop the table while there are - foreign key checks running on it. */ - Atomic_counter n_foreign_key_checks_running; - /** DDL transaction that last touched the table definition, or 0 if no history is available. This includes possible changes in ha_innobase::prepare_inplace_alter_table() and @@ -2219,6 +2182,11 @@ public: an empty leaf page), and an ahi_latch (if btr_search_enabled). */ Atomic_relaxed bulk_trx_id; + /** Original table name, for MDL acquisition in purge. Normally, + this points to the same as name. When is_temporary_name(name.m_name) holds, + this should be a copy of the original table name, allocated from heap. */ + table_name_t mdl_name; + /*!< set of foreign key constraints in the table; these refer to columns in other tables */ dict_foreign_set foreign_set; @@ -2439,9 +2407,6 @@ public: static dict_table_t *create(const span &name, fil_space_t *space, ulint n_cols, ulint n_v_cols, ulint flags, ulint flags2); - - /** @return whether SYS_TABLES.NAME is for a '#sql-ib' table */ - static bool is_garbage_name(const void *data, size_t size); }; inline void dict_index_t::set_modified(mtr_t& mtr) const diff --git a/storage/innobase/include/dict0mem.ic b/storage/innobase/include/dict0mem.ic index 0a554a54dbd..d60ee5d9bf4 100644 --- a/storage/innobase/include/dict0mem.ic +++ b/storage/innobase/include/dict0mem.ic @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, MariaDB Corporation. +Copyright (c) 2017, 2021, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -64,10 +64,5 @@ dict_mem_fill_index_struct( /* The '1 +' above prevents allocation of an empty mem block */ index->nulls_equal = false; -#ifdef BTR_CUR_HASH_ADAPT -#ifdef MYSQL_INDEX_DISABLE_AHI - index->disable_ahi = false; -#endif -#endif /* BTR_CUR_HASH_ADAPT */ ut_d(index->magic_n = DICT_INDEX_MAGIC_N); } diff --git a/storage/innobase/include/dict0stats.h b/storage/innobase/include/dict0stats.h index cf0e2adab76..7112238c9b6 100644 --- a/storage/innobase/include/dict0stats.h +++ b/storage/innobase/include/dict0stats.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2009, 2018, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2020, MariaDB Corporation. +Copyright (c) 2017, 2021, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -30,9 +30,6 @@ Created Jan 06, 2010 Vasil Dimov #include "dict0types.h" #include "trx0types.h" -#define TABLE_STATS_NAME "mysql/innodb_table_stats" -#define INDEX_STATS_NAME "mysql/innodb_index_stats" - enum dict_stats_upd_option_t { DICT_STATS_RECALC_PERSISTENT,/* (re) calculate the statistics using a precise and slow @@ -140,40 +137,31 @@ dict_stats_update( the stats or to fetch them from the persistent storage */ -/** Remove the information for a particular index's stats from the persistent -storage if it exists and if there is data stored for this index. -This function creates its own trx and commits it. - -We must modify system tables in a separate transaction in order to -adhere to the InnoDB design constraint that dict_sys.latch prevents -lock waits on system tables. If we modified system and user tables in -the same transaction, we should exclusively hold dict_sys.latch until -the transaction is committed, and effectively block other transactions -that will attempt to open any InnoDB tables. Because we have no -guarantee that user transactions will be committed fast, we cannot -afford to keep the system tables locked in a user transaction. +/** Execute DELETE FROM mysql.innodb_table_stats +@param database_name database name +@param table_name table name +@param trx transaction (nullptr=start and commit a new one) @return DB_SUCCESS or error code */ -dberr_t -dict_stats_drop_index( -/*==================*/ - const char* tname, /*!< in: table name */ - const char* iname, /*!< in: index name */ - char* errstr, /*!< out: error message if != DB_SUCCESS - is returned */ - ulint errstr_sz);/*!< in: size of the errstr buffer */ - -/*********************************************************************//** -Removes the statistics for a table and all of its indexes from the -persistent storage if it exists and if there is data stored for the table. -This function creates its own transaction and commits it. +dberr_t dict_stats_delete_from_table_stats(const char *database_name, + const char *table_name, + trx_t *trx= nullptr); +/** Execute DELETE FROM mysql.innodb_index_stats +@param database_name database name +@param table_name table name +@param trx transaction (nullptr=start and commit a new one) @return DB_SUCCESS or error code */ -dberr_t -dict_stats_drop_table( -/*==================*/ - const char* table_name, /*!< in: table name */ - char* errstr, /*!< out: error message - if != DB_SUCCESS is returned */ - ulint errstr_sz); /*!< in: size of errstr buffer */ +dberr_t dict_stats_delete_from_index_stats(const char *database_name, + const char *table_name, + trx_t *trx= nullptr); +/** Execute DELETE FROM mysql.innodb_index_stats +@param database_name database name +@param table_name table name +@param index_name name of the index +@param trx transaction (nullptr=start and commit a new one) +@return DB_SUCCESS or error code */ +dberr_t dict_stats_delete_from_index_stats(const char *database_name, + const char *table_name, + const char *index_name, trx_t *trx); /*********************************************************************//** Fetches or calculates new estimates for index statistics. */ @@ -183,31 +171,29 @@ dict_stats_update_for_index( dict_index_t* index) /*!< in/out: index */ MY_ATTRIBUTE((nonnull)); -/*********************************************************************//** -Renames a table in InnoDB persistent stats storage. -This function creates its own transaction and commits it. +/** Rename a table in InnoDB persistent stats storage. +@param old_name old table name +@param new_name new table name +@param trx transaction @return DB_SUCCESS or error code */ -dberr_t -dict_stats_rename_table( -/*====================*/ - const char* old_name, /*!< in: old table name */ - const char* new_name, /*!< in: new table name */ - char* errstr, /*!< out: error string if != DB_SUCCESS - is returned */ - size_t errstr_sz); /*!< in: errstr size */ -/*********************************************************************//** -Renames an index in InnoDB persistent stats storage. -This function creates its own transaction and commits it. -@return DB_SUCCESS or error code. DB_STATS_DO_NOT_EXIST will be returned -if the persistent stats do not exist. */ -dberr_t -dict_stats_rename_index( -/*====================*/ - const dict_table_t* table, /*!< in: table whose index - is renamed */ - const char* old_index_name, /*!< in: old index name */ - const char* new_index_name) /*!< in: new index name */ - __attribute__((warn_unused_result)); +dberr_t dict_stats_rename_table(const char *old_name, const char *new_name, + trx_t *trx); +/** Rename an index in InnoDB persistent statistics. +@param db database name +@param table table name +@param old_name old table name +@param new_name new table name +@param trx transaction +@return DB_SUCCESS or error code */ +dberr_t dict_stats_rename_index(const char *db, const char *table, + const char *old_name, const char *new_name, + trx_t *trx); + +/** Delete all persistent statistics for a database. +@param db database name +@param trx transaction +@return DB_SUCCESS or error code */ +dberr_t dict_stats_delete(const char *db, trx_t *trx); /** Save an individual index's statistic into the persistent statistics storage. diff --git a/storage/innobase/include/dict0types.h b/storage/innobase/include/dict0types.h index cfd0ff98912..9a53ecdab8f 100644 --- a/storage/innobase/include/dict0types.h +++ b/storage/innobase/include/dict0types.h @@ -168,4 +168,7 @@ enum spatial_status_t { SPATIAL_ONLY = 3 }; +#define TABLE_STATS_NAME "mysql/innodb_table_stats" +#define INDEX_STATS_NAME "mysql/innodb_index_stats" + #endif diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h index cf770ccce37..dfee49a500c 100644 --- a/storage/innobase/include/fil0fil.h +++ b/storage/innobase/include/fil0fil.h @@ -518,8 +518,12 @@ public: /** Close each file. Only invoked on fil_system.temp_space. */ void close(); - /** Note that operations on the tablespace must stop or can resume */ - inline void set_stopping(bool stopping); + /** Note that operations on the tablespace must stop. + @return whether the operations were already stopped */ + inline bool set_stopping(); + + /** Note that operations on the tablespace can resume after truncation */ + inline void clear_stopping(); /** Look up the tablespace and wait for pending operations to cease @param id tablespace identifier @@ -1508,12 +1512,19 @@ inline void fil_space_t::reacquire() #endif /* SAFE_MUTEX */ } -/** Note that operations on the tablespace must stop or can resume */ -inline void fil_space_t::set_stopping(bool stopping) +/** Note that operations on the tablespace must stop. +@return whether the operations were already stopped */ +inline bool fil_space_t::set_stopping() { mysql_mutex_assert_owner(&fil_system.mutex); - ut_d(auto n=) n_pending.fetch_xor(STOPPING, std::memory_order_relaxed); - ut_ad(!(n & STOPPING) == stopping); + return n_pending.fetch_or(STOPPING, std::memory_order_relaxed) & STOPPING; +} + +inline void fil_space_t::clear_stopping() +{ + mysql_mutex_assert_owner(&fil_system.mutex); + ut_d(auto n=) n_pending.fetch_and(~STOPPING, std::memory_order_relaxed); + ut_ad(n & STOPPING); } /** Flush pending writes from the file system cache to the file. */ @@ -1595,13 +1606,12 @@ fil_write_flushed_lsn( lsn_t lsn) MY_ATTRIBUTE((warn_unused_result)); +MY_ATTRIBUTE((warn_unused_result)) /** Delete a tablespace and associated .ibd file. -@param[in] id tablespace identifier -@param[in] if_exists whether to ignore missing tablespace -@param[out] detached deatched file handle (if closing is not wanted) -@return DB_SUCCESS or error */ -dberr_t fil_delete_tablespace(ulint id, bool if_exists= false, - pfs_os_file_t *detached= nullptr); +@param id tablespace identifier +@return detached file handle (to be closed by the caller) +@return OS_FILE_CLOSED if no file existed */ +pfs_os_file_t fil_delete_tablespace(ulint id); /** Close a single-table tablespace on failed IMPORT TABLESPACE. The tablespace must be cached in the memory cache. diff --git a/storage/innobase/include/fts0fts.h b/storage/innobase/include/fts0fts.h index e360e3227b1..bb61eae43f2 100644 --- a/storage/innobase/include/fts0fts.h +++ b/storage/innobase/include/fts0fts.h @@ -500,17 +500,29 @@ fts_add_doc_id_column( dict_table_t* table, /*!< in/out: Table with FTS index */ mem_heap_t* heap); /*!< in: temporary memory heap, or NULL */ -/*********************************************************************//** -Drops the ancillary tables needed for supporting an FTS index on the -given table. row_mysql_lock_data_dictionary must have been called before -this. +/** Lock the internal FTS_ tables for an index, before fts_drop_index_tables(). +@param trx transaction +@param index fulltext index */ +dberr_t fts_lock_index_tables(trx_t *trx, const dict_index_t &index); + +/** Lock the internal common FTS_ tables, before fts_drop_common_tables(). +@param trx transaction +@param table table containing FULLTEXT INDEX @return DB_SUCCESS or error code */ -dberr_t -fts_drop_tables( -/*============*/ - trx_t* trx, /*!< in: transaction */ - dict_table_t* table); /*!< in: table has the FTS - index */ +dberr_t fts_lock_common_tables(trx_t *trx, const dict_table_t &table); + +/** Lock the internal FTS_ tables for table, before fts_drop_tables(). +@param trx transaction +@param table table containing FULLTEXT INDEX +@return DB_SUCCESS or error code */ +dberr_t fts_lock_tables(trx_t *trx, const dict_table_t &table); + +/** Drop the internal FTS_ tables for table. +@param trx transaction +@param table table containing FULLTEXT INDEX +@return DB_SUCCESS or error code */ +dberr_t fts_drop_tables(trx_t *trx, const dict_table_t &table); + /******************************************************************//** The given transaction is about to be committed; do whatever is necessary from the FTS system's POV. @@ -643,11 +655,7 @@ fts_optimize_init(void); /****************************************************************//** Drops index ancillary tables for a FTS index @return DB_SUCCESS or error code */ -dberr_t -fts_drop_index_tables( -/*==================*/ - trx_t* trx, /*!< in: transaction */ - dict_index_t* index) /*!< in: Index to drop */ +dberr_t fts_drop_index_tables(trx_t *trx, const dict_index_t &index) MY_ATTRIBUTE((warn_unused_result)); /** Add the table to add to the OPTIMIZER's list. diff --git a/storage/innobase/include/ha_prototypes.h b/storage/innobase/include/ha_prototypes.h index 4acee09715a..b65a874177c 100644 --- a/storage/innobase/include/ha_prototypes.h +++ b/storage/innobase/include/ha_prototypes.h @@ -453,7 +453,7 @@ normalize_table_name_c_low( char* norm_name, /*!< out: normalized name as a null-terminated string */ const char* name, /*!< in: table name string */ - ibool set_lower_case); /*!< in: TRUE if we want to set + bool set_lower_case); /*!< in: true if we want to set name to lower case */ /** Create a MYSQL_THD for a background thread and mark it as such. diff --git a/storage/innobase/include/row0mysql.h b/storage/innobase/include/row0mysql.h index 0b4590b67bc..6c783ec3495 100644 --- a/storage/innobase/include/row0mysql.h +++ b/storage/innobase/include/row0mysql.h @@ -37,11 +37,6 @@ Created 9/17/2000 Heikki Tuuri #include "fts0fts.h" #include "gis0type.h" -#include "sql_list.h" -#include "sql_cmd.h" - -extern ibool row_rollback_on_timeout; - struct row_prebuilt_t; class ha_innobase; @@ -378,17 +373,6 @@ row_create_index_for_mysql( uint32_t key_id) /*!< in: encryption key_id */ MY_ATTRIBUTE((warn_unused_result)); -/** The master task calls this regularly to drop tables which -we must drop in background after queries to them have ended. -@return how many tables dropped + remaining tables in list */ -ulint row_drop_tables_for_mysql_in_background(); - -/** @return number of tables in the background drop list */ -ulint row_get_background_drop_list_len_low(); - -/** Drop garbage tables during recovery. */ -void row_mysql_drop_garbage_tables(); - /*********************************************************************//** Sets an exclusive lock on a table. @return error code or DB_SUCCESS */ @@ -401,36 +385,12 @@ row_mysql_lock_table( const char* op_info) /*!< in: string for trx->op_info */ MY_ATTRIBUTE((nonnull, warn_unused_result)); -/** Drop a table. -If the data dictionary was not already locked by the transaction, -the transaction will be committed. Otherwise, the data dictionary -will remain locked. -@param[in] name Table name -@param[in,out] trx Transaction handle -@param[in] sqlcom type of SQL operation -@param[in] create_failed true=create table failed - because e.g. foreign key column -@param[in] nonatomic Whether it is permitted to release - and reacquire dict_sys.latch -@return error code */ -dberr_t -row_drop_table_for_mysql( - const char* name, - trx_t* trx, - enum_sql_command sqlcom, - bool create_failed = false, - bool nonatomic = true); - /*********************************************************************//** Discards the tablespace of a table which stored in an .ibd file. Discarding means that this function deletes the .ibd file and assigns a new table id for the table. Also the file_unreadable flag is set. @return error code or DB_SUCCESS */ -dberr_t -row_discard_tablespace_for_mysql( -/*=============================*/ - const char* name, /*!< in: table name */ - trx_t* trx) /*!< in: transaction handle */ +dberr_t row_discard_tablespace_for_mysql(dict_table_t *table, trx_t *trx) MY_ATTRIBUTE((nonnull, warn_unused_result)); /*****************************************************************//** Imports a tablespace. The space id in the .ibd file must match the space id @@ -452,7 +412,6 @@ row_rename_table_for_mysql( const char* old_name, /*!< in: old table name */ const char* new_name, /*!< in: new table name */ trx_t* trx, /*!< in/out: transaction */ - bool commit, /*!< in: whether to commit trx */ bool use_fk) /*!< in: whether to parse and enforce FOREIGN KEY constraints */ MY_ATTRIBUTE((nonnull, warn_unused_result)); @@ -472,17 +431,6 @@ row_scan_index_for_mysql( ulint* n_rows) /*!< out: number of entries seen in the consistent read */ MY_ATTRIBUTE((warn_unused_result)); -/*********************************************************************//** -Initialize this module */ -void -row_mysql_init(void); -/*================*/ - -/*********************************************************************//** -Close this module */ -void -row_mysql_close(void); -/*=================*/ /* A struct describing a place for an individual column in the MySQL row format which is presented to the table handler in ha_innobase. @@ -946,10 +894,4 @@ innobase_rename_vc_templ( #define ROW_READ_TRY_SEMI_CONSISTENT 1 #define ROW_READ_DID_SEMI_CONSISTENT 2 -#ifdef UNIV_DEBUG -/** Wait for the background drop list to become empty. */ -void -row_wait_for_background_drop_list_empty(); -#endif /* UNIV_DEBUG */ - #endif /* row0mysql.h */ diff --git a/storage/innobase/include/srv0mon.h b/storage/innobase/include/srv0mon.h index a7aa6e99307..56b56a18bdb 100644 --- a/storage/innobase/include/srv0mon.h +++ b/storage/innobase/include/srv0mon.h @@ -377,7 +377,6 @@ enum monitor_id_t { MONITOR_OVLD_SERVER_ACTIVITY, MONITOR_MASTER_ACTIVE_LOOPS, MONITOR_MASTER_IDLE_LOOPS, - MONITOR_SRV_BACKGROUND_DROP_TABLE_MICROSECOND, MONITOR_SRV_LOG_FLUSH_MICROSECOND, MONITOR_SRV_DICT_LRU_MICROSECOND, MONITOR_SRV_DICT_LRU_EVICT_COUNT_ACTIVE, @@ -400,7 +399,6 @@ enum monitor_id_t { /* Data DDL related counters */ MONITOR_MODULE_DDL_STATS, MONITOR_BACKGROUND_DROP_INDEX, - MONITOR_BACKGROUND_DROP_TABLE, MONITOR_ONLINE_CREATE_INDEX, MONITOR_PENDING_ALTER_TABLE, MONITOR_ALTER_TABLE_SORT_FILES, diff --git a/storage/innobase/include/trx0purge.h b/storage/innobase/include/trx0purge.h index db11f882968..559e38b73b6 100644 --- a/storage/innobase/include/trx0purge.h +++ b/storage/innobase/include/trx0purge.h @@ -138,6 +138,8 @@ private: Atomic_counter m_paused; /** number of stop_SYS() calls without resume_SYS() */ Atomic_counter m_SYS_paused; + /** number of stop_FTS() calls without resume_FTS() */ + Atomic_counter m_FTS_paused; public: que_t* query; /*!< The query graph which will do the parallelized purge operation */ @@ -243,13 +245,14 @@ public: /** @return whether the purge tasks are active */ bool running() const; - /** Stop purge during FLUSH TABLES FOR EXPORT */ + /** Stop purge during FLUSH TABLES FOR EXPORT. */ void stop(); /** Resume purge at UNLOCK TABLES after FLUSH TABLES FOR EXPORT */ void resume(); private: void wait_SYS(); + void wait_FTS(); public: /** Suspend purge in data dictionary tables */ void stop_SYS(); @@ -260,6 +263,15 @@ public: /** check stop_SYS() */ void check_stop_SYS() { if (must_wait_SYS()) wait_SYS(); } + /** Pause purge during a DDL operation that could drop FTS_ tables. */ + void stop_FTS() { m_FTS_paused++; } + /** Resume purge after stop_FTS(). */ + void resume_FTS() { ut_d(const auto p=) m_FTS_paused--; ut_ad(p); } + /** @return whether stop_SYS() is in effect */ + bool must_wait_FTS() const { return m_FTS_paused; } + /** check stop_SYS() */ + void check_stop_FTS() { if (must_wait_FTS()) wait_FTS(); } + /** A wrapper around ReadView::changes_visible(). */ bool changes_visible(trx_id_t id, const table_name_t &name) const { diff --git a/storage/innobase/include/trx0trx.h b/storage/innobase/include/trx0trx.h index a570f3cb5e0..7c98db62c67 100644 --- a/storage/innobase/include/trx0trx.h +++ b/storage/innobase/include/trx0trx.h @@ -38,7 +38,6 @@ Created 3/26/1996 Heikki Tuuri #include "ilist.h" #include -#include // Forward declaration struct mtr_t; @@ -412,7 +411,8 @@ class trx_mod_table_time_t /** First modification of the table, possibly ORed with BULK */ undo_no_t first; - /** First modification of a system versioned column (or NONE) */ + /** First modification of a system versioned column + (NONE= no versioning, BULK= the table was dropped) */ undo_no_t first_versioned= NONE; public: /** Constructor @@ -427,17 +427,26 @@ public: { auto f= first & LIMIT; return f <= first_versioned && f <= rows; } #endif /* UNIV_DEBUG */ /** @return if versioned columns were modified */ - bool is_versioned() const { return first_versioned != NONE; } + bool is_versioned() const { return (~first_versioned & LIMIT) != 0; } + /** @return if the table was dropped */ + bool is_dropped() const { return first_versioned == BULK; } /** After writing an undo log record, set is_versioned() if needed @param rows number of modified rows so far */ void set_versioned(undo_no_t rows) { - ut_ad(!is_versioned()); + ut_ad(first_versioned == NONE); first_versioned= rows; ut_ad(valid(rows)); } + /** After writing an undo log record, note that the table will be dropped */ + void set_dropped() + { + ut_ad(first_versioned == NONE); + first_versioned= BULK; + } + /** Notify the start of a bulk insert operation */ void start_bulk_insert() { first|= BULK; } @@ -923,6 +932,10 @@ private: inline void commit_tables(); /** Mark a transaction committed in the main memory data structures. */ inline void commit_in_memory(const mtr_t *mtr); + /** Write log for committing the transaction. */ + void commit_persist(); + /** Clean up the transaction after commit_in_memory() */ + void commit_cleanup(); /** Commit the transaction in a mini-transaction. @param mtr mini-transaction (if there are any persistent modifications) */ void commit_low(mtr_t *mtr= nullptr); @@ -931,6 +944,24 @@ public: void commit(); + /** Try to drop a persistent table. + @param table persistent table + @param fk whether to drop FOREIGN KEY metadata + @return error code */ + dberr_t drop_table(const dict_table_t &table); + /** Try to drop the foreign key constraints for a persistent table. + @param name name of persistent table + @return error code */ + dberr_t drop_table_foreign(const table_name_t &name); + /** Try to drop the statistics for a persistent table. + @param name name of persistent table + @return error code */ + dberr_t drop_table_statistics(const table_name_t &name); + /** Commit the transaction, possibly after drop_table(). + @param deleted handles of data files that were deleted */ + void commit(std::vector &deleted); + + /** Discard all savepoints */ void savepoints_discard() { savepoints_discard(UT_LIST_GET_FIRST(trx_savepoints)); } diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc index 209a9eb6fc5..199df390582 100644 --- a/storage/innobase/lock/lock0lock.cc +++ b/storage/innobase/lock/lock0lock.cc @@ -1265,19 +1265,16 @@ lock_rec_enqueue_waiting( trx_t* trx = thr_get_trx(thr); ut_ad(trx->mutex_is_owner()); - if (UNIV_UNLIKELY(trx->dict_operation)) { - ib::error() << "A record lock wait happens in a dictionary" - " operation. index " - << index->name - << " of table " - << index->table->name - << ". " << BUG_REPORT_MSG; - ut_ad(0); + if (UNIV_UNLIKELY(trx->dict_operation_lock_mode == RW_X_LATCH)) { + ut_ad(!strcmp(index->table->name.m_name, TABLE_STATS_NAME) + || !strcmp(index->table->name.m_name, INDEX_STATS_NAME)); +instant_timeout: + trx->error_state = DB_LOCK_WAIT_TIMEOUT; + return DB_LOCK_WAIT_TIMEOUT; } if (trx->mysql_thd && thd_lock_wait_timeout(trx->mysql_thd) == 0) { - trx->error_state = DB_LOCK_WAIT_TIMEOUT; - return DB_LOCK_WAIT_TIMEOUT; + goto instant_timeout; } /* Enqueue the lock request that will wait to be granted, note that @@ -3314,11 +3311,11 @@ lock_table_enqueue_waiting( trx_t* trx = thr_get_trx(thr); ut_ad(trx->mutex_is_owner()); - if (UNIV_UNLIKELY(trx->dict_operation)) { - ib::error() << "A table lock wait happens in a dictionary" - " operation. Table " << table->name - << ". " << BUG_REPORT_MSG; - ut_ad(0); + if (UNIV_UNLIKELY(trx->dict_operation_lock_mode == RW_X_LATCH)) { + ut_ad(!strcmp(table->name.m_name, TABLE_STATS_NAME) + || !strcmp(table->name.m_name, INDEX_STATS_NAME)); + trx->error_state = DB_LOCK_WAIT_TIMEOUT; + return DB_LOCK_WAIT_TIMEOUT; } #ifdef WITH_WSREP diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc index e197b1cf81f..6b8b11605af 100644 --- a/storage/innobase/os/os0file.cc +++ b/storage/innobase/os/os0file.cc @@ -1482,8 +1482,7 @@ os_file_rename_func( /* New path must not exist. */ ut_ad(os_file_status(newpath, &exists, &type)); - /* MDEV-25506 FIXME: Remove the strstr() */ - ut_ad(!exists || strstr(oldpath, "/" TEMP_FILE_PREFIX_INNODB)); + ut_ad(!exists); /* Old path must exist. */ ut_ad(os_file_status(oldpath, &exists, &type)); @@ -2535,8 +2534,7 @@ os_file_rename_func( /* New path must not exist. */ ut_ad(os_file_status(newpath, &exists, &type)); - /* MDEV-25506 FIXME: Remove the strstr() */ - ut_ad(!exists || strstr(oldpath, "/" TEMP_FILE_PREFIX_INNODB)); + ut_ad(!exists); /* Old path must exist. */ ut_ad(os_file_status(oldpath, &exists, &type)); diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc index 6cb1ad64c88..08bc40a5da2 100644 --- a/storage/innobase/row/row0ins.cc +++ b/storage/innobase/row/row0ins.cc @@ -1830,16 +1830,12 @@ do_possible_lock_wait: thr->lock_state = QUE_THR_LOCK_ROW; - check_table->inc_fk_checks(); - err = lock_wait(thr); thr->lock_state = QUE_THR_LOCK_NOLOCK; - check_table->dec_fk_checks(); - if (err != DB_SUCCESS) { - } else if (check_table->to_be_dropped) { + } else if (check_table->name.is_temporary()) { err = DB_LOCK_WAIT_TIMEOUT; } else { err = DB_LOCK_WAIT; @@ -1912,14 +1908,10 @@ row_ins_check_foreign_constraints( { dict_foreign_t* foreign; dberr_t err = DB_SUCCESS; - trx_t* trx; - ibool got_s_lock = FALSE; mem_heap_t* heap = NULL; DBUG_ASSERT(index->is_primary() == pk); - trx = thr_get_trx(thr); - DEBUG_SYNC_C_IF_THD(thr_get_trx(thr)->mysql_thd, "foreign_constraint_check_for_ins"); @@ -1965,32 +1957,9 @@ row_ins_check_foreign_constraints( FALSE, FALSE, DICT_ERR_IGNORE_NONE); } - if (0 == trx->dict_operation_lock_mode) { - got_s_lock = TRUE; - - row_mysql_freeze_data_dictionary(trx); - } - - if (referenced_table) { - foreign->foreign_table->inc_fk_checks(); - } - - /* NOTE that if the thread ends up waiting for a lock - we will release dict_sys.latch temporarily! - But the counter on the table protects the referenced - table from being dropped while the check is running. */ - err = row_ins_check_foreign_constraint( TRUE, foreign, table, ref_tuple, thr); - if (referenced_table) { - foreign->foreign_table->dec_fk_checks(); - } - - if (got_s_lock) { - row_mysql_unfreeze_data_dictionary(trx); - } - if (ref_table != NULL) { dict_table_close(ref_table, FALSE, FALSE); } diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc index 485af26dd32..715a49cd3ae 100644 --- a/storage/innobase/row/row0merge.cc +++ b/storage/innobase/row/row0merge.cc @@ -3787,7 +3787,7 @@ static void row_merge_drop_fulltext_indexes(trx_t *trx, dict_table_t *table) return; fts_optimize_remove_table(table); - fts_drop_tables(trx, table); + fts_drop_tables(trx, *table); fts_free(table); DICT_TF2_FLAG_UNSET(table, DICT_TF2_FTS); } diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc index 3b365bd86a2..4adc279fb32 100644 --- a/storage/innobase/row/row0mysql.cc +++ b/storage/innobase/row/row0mysql.cc @@ -38,8 +38,6 @@ Created 9/17/2000 Heikki Tuuri #include "dict0load.h" #include "dict0stats.h" #include "dict0stats_bg.h" -#include "dict0defrag_bg.h" -#include "btr0defragment.h" #include "fil0fil.h" #include "fil0crypt.h" #include "fsp0file.h" @@ -62,6 +60,7 @@ Created 9/17/2000 Heikki Tuuri #include "trx0undo.h" #include "srv0mon.h" #include "srv0start.h" +#include "log.h" #include #include @@ -70,33 +69,9 @@ Created 9/17/2000 Heikki Tuuri #ifdef WITH_WSREP #include "mysql/service_wsrep.h" #include "wsrep.h" -#include "log.h" #include "wsrep_mysqld.h" #endif -/** Provide optional 4.x backwards compatibility for 5.0 and above */ -ibool row_rollback_on_timeout = FALSE; - -/** Chain node of the list of tables to drop in the background. */ -struct row_mysql_drop_t{ - table_id_t table_id; /*!< table id */ - UT_LIST_NODE_T(row_mysql_drop_t)row_mysql_drop_list; - /*!< list chain node */ -}; - -/** @brief List of tables we should drop in background. - -ALTER TABLE in MySQL requires that the table handler can drop the -table in background when there are no queries to it any -more. Protected by row_drop_list_mutex. */ -static UT_LIST_BASE_NODE_T(row_mysql_drop_t) row_mysql_drop_list; - -/** Mutex protecting the background table drop list. */ -static mysql_mutex_t row_drop_list_mutex; - -/** Flag: has row_mysql_drop_list been initialized? */ -static bool row_mysql_drop_list_inited; - /*******************************************************************//** Determine if the given name is a name reserved for MySQL system tables. @return TRUE if name is a MySQL system table name */ @@ -116,21 +91,6 @@ row_mysql_is_system_table( || 0 == strcmp(name + 6, "db")); } -#ifdef UNIV_DEBUG -/** Wait for the background drop list to become empty. */ -void -row_wait_for_background_drop_list_empty() -{ - bool empty = false; - while (!empty) { - mysql_mutex_lock(&row_drop_list_mutex); - empty = (UT_LIST_GET_LEN(row_mysql_drop_list) == 0); - mysql_mutex_unlock(&row_drop_list_mutex); - std::this_thread::sleep_for(std::chrono::milliseconds(100)); - } -} -#endif /* UNIV_DEBUG */ - /*******************************************************************//** Delays an INSERT, DELETE or UPDATE operation if the purge is lagging. */ static @@ -701,7 +661,8 @@ handle_new_error: switch (err) { case DB_LOCK_WAIT_TIMEOUT: - if (row_rollback_on_timeout) { + extern my_bool innobase_rollback_on_timeout; + if (innobase_rollback_on_timeout) { goto rollback; } /* fall through */ @@ -2476,258 +2437,6 @@ row_create_index_for_mysql( return(err); } -/*********************************************************************//** -Drops a table for MySQL as a background operation. MySQL relies on Unix -in ALTER TABLE to the fact that the table handler does not remove the -table before all handles to it has been removed. Furhermore, the MySQL's -call to drop table must be non-blocking. Therefore we do the drop table -as a background operation, which is taken care of by the master thread -in srv0srv.cc. -@return error code or DB_SUCCESS */ -static -dberr_t -row_drop_table_for_mysql_in_background( -/*===================================*/ - const char* name) /*!< in: table name */ -{ - dberr_t error; - trx_t* trx; - - trx = trx_create(); - - /* If the original transaction was dropping a table referenced by - foreign keys, we must set the following to be able to drop the - table: */ - - trx->check_foreigns = false; - - /* Try to drop the table in InnoDB */ - - error = row_drop_table_for_mysql(name, trx, SQLCOM_TRUNCATE); - - trx_commit_for_mysql(trx); - - trx->free(); - - return(error); -} - -/*********************************************************************//** -The master thread in srv0srv.cc calls this regularly to drop tables which -we must drop in background after queries to them have ended. Such lazy -dropping of tables is needed in ALTER TABLE on Unix. -@return how many tables dropped + remaining tables in list */ -ulint -row_drop_tables_for_mysql_in_background(void) -/*=========================================*/ -{ - row_mysql_drop_t* drop; - dict_table_t* table; - ulint n_tables; - ulint n_tables_dropped = 0; -loop: - mysql_mutex_lock(&row_drop_list_mutex); - - ut_a(row_mysql_drop_list_inited); -next: - drop = UT_LIST_GET_FIRST(row_mysql_drop_list); - - n_tables = UT_LIST_GET_LEN(row_mysql_drop_list); - - mysql_mutex_unlock(&row_drop_list_mutex); - - if (drop == NULL) { - /* All tables dropped */ - - return(n_tables + n_tables_dropped); - } - - /* On fast shutdown, just empty the list without dropping tables. */ - table = srv_shutdown_state == SRV_SHUTDOWN_NONE || !srv_fast_shutdown - ? dict_table_open_on_id(drop->table_id, FALSE, - DICT_TABLE_OP_OPEN_ONLY_IF_CACHED) - : NULL; - - if (!table) { - n_tables_dropped++; - mysql_mutex_lock(&row_drop_list_mutex); - UT_LIST_REMOVE(row_mysql_drop_list, drop); - MONITOR_DEC(MONITOR_BACKGROUND_DROP_TABLE); - ut_free(drop); - goto next; - } - - ut_a(!table->can_be_evicted); - - bool skip = false; - - if (!table->to_be_dropped) { -skip: - dict_table_close(table, FALSE, FALSE); - - mysql_mutex_lock(&row_drop_list_mutex); - UT_LIST_REMOVE(row_mysql_drop_list, drop); - if (!skip) { - UT_LIST_ADD_LAST(row_mysql_drop_list, drop); - } else { - ut_free(drop); - } - goto next; - } - - if (!srv_fast_shutdown && !trx_sys.any_active_transactions()) { - table->lock_mutex_lock(); - skip = UT_LIST_GET_LEN(table->locks) != 0; - table->lock_mutex_unlock(); - if (skip) { - /* We cannot drop tables that are locked by XA - PREPARE transactions. */ - goto skip; - } - } - - char* name = mem_strdup(table->name.m_name); - - dict_table_close(table, FALSE, FALSE); - - dberr_t err = row_drop_table_for_mysql_in_background(name); - - ut_free(name); - - if (err != DB_SUCCESS) { - /* If the DROP fails for some table, we return, and let the - main thread retry later */ - return(n_tables + n_tables_dropped); - } - - goto loop; -} - -/*********************************************************************//** -Get the background drop list length. NOTE: the caller must own the -drop list mutex! -@return how many tables in list */ -ulint -row_get_background_drop_list_len_low(void) -/*======================================*/ -{ - ulint len; - - mysql_mutex_lock(&row_drop_list_mutex); - - ut_a(row_mysql_drop_list_inited); - - len = UT_LIST_GET_LEN(row_mysql_drop_list); - - mysql_mutex_unlock(&row_drop_list_mutex); - - return(len); -} - -/** Drop garbage tables during recovery. */ -void row_mysql_drop_garbage_tables() -{ - btr_pcur_t pcur; - mtr_t mtr; - trx_t* trx = trx_create(); - trx->op_info = "dropping garbage tables"; - row_mysql_lock_data_dictionary(trx); - - mtr.start(); - btr_pcur_open_at_index_side( - true, dict_table_get_first_index(dict_sys.sys_tables), - BTR_SEARCH_LEAF, &pcur, true, 0, &mtr); - - for (;;) { - const rec_t* rec; - const byte* field; - ulint len; - - btr_pcur_move_to_next_user_rec(&pcur, &mtr); - - if (!btr_pcur_is_on_user_rec(&pcur)) { - break; - } - - rec = btr_pcur_get_rec(&pcur); - if (rec_get_deleted_flag(rec, 0)) { - continue; - } - - field = rec_get_nth_field_old(rec, 0/*NAME*/, &len); - if (len == UNIV_SQL_NULL) { - /* Corrupted SYS_TABLES.NAME */ - continue; - } - - if (!dict_table_t::is_garbage_name(field, len)) { - continue; - } - - btr_pcur_store_position(&pcur, &mtr); - btr_pcur_commit_specify_mtr(&pcur, &mtr); - - const span name = { - reinterpret_cast(pcur.old_rec), len - }; - if (dict_sys.load_table(name, DICT_ERR_IGNORE_DROP)) { - char* table_name = mem_strdupl(name.data(), len); - row_drop_table_for_mysql(table_name, trx, - SQLCOM_DROP_TABLE); - ut_free(table_name); - trx_commit_for_mysql(trx); - } - - mtr.start(); - btr_pcur_restore_position(BTR_SEARCH_LEAF, &pcur, &mtr); - } - - btr_pcur_close(&pcur); - mtr.commit(); - row_mysql_unlock_data_dictionary(trx); - trx->free(); -} - -/*********************************************************************//** -If a table is not yet in the drop list, adds the table to the list of tables -which the master thread drops in background. We need this on Unix because in -ALTER TABLE MySQL may call drop table even if the table has running queries on -it. Also, if there are running foreign key checks on the table, we drop the -table lazily. -@return whether background DROP TABLE was scheduled for the first time */ -static -bool -row_add_table_to_background_drop_list(table_id_t table_id) -{ - row_mysql_drop_t* drop; - bool added = true; - - mysql_mutex_lock(&row_drop_list_mutex); - - ut_a(row_mysql_drop_list_inited); - - /* Look if the table already is in the drop list */ - for (drop = UT_LIST_GET_FIRST(row_mysql_drop_list); - drop != NULL; - drop = UT_LIST_GET_NEXT(row_mysql_drop_list, drop)) { - - if (drop->table_id == table_id) { - added = false; - goto func_exit; - } - } - - drop = static_cast(ut_malloc_nokey(sizeof *drop)); - drop->table_id = table_id; - - UT_LIST_ADD_LAST(row_mysql_drop_list, drop); - - MONITOR_INC(MONITOR_BACKGROUND_DROP_TABLE); -func_exit: - mysql_mutex_unlock(&row_drop_list_mutex); - return added; -} - /** Reassigns the table identifier of a table. @param[in,out] table table @param[in,out] trx transaction @@ -2769,42 +2478,6 @@ row_mysql_table_id_reassign( return(err); } -/*********************************************************************//** -Setup the pre-requisites for DISCARD TABLESPACE. It will start the transaction, -acquire the data dictionary lock in X mode and open the table. -@return table instance or 0 if not found. */ -static -dict_table_t* -row_discard_tablespace_begin( -/*=========================*/ - const char* name, /*!< in: table name */ - trx_t* trx) /*!< in: transaction handle */ -{ - trx->op_info = "discarding tablespace"; - - trx->dict_operation = true; - - trx_start_if_not_started_xa(trx, true); - - /* Serialize data dictionary operations with dictionary mutex: - this is to avoid deadlocks during data dictionary operations */ - - row_mysql_lock_data_dictionary(trx); - - dict_table_t* table; - - table = dict_table_open_on_name( - name, TRUE, FALSE, DICT_ERR_IGNORE_FK_NOKEY); - - if (table) { - dict_stats_wait_bg_to_stop_using_table(table, trx); - ut_a(!is_system_tablespace(table->space_id)); - ut_ad(!table->n_foreign_key_checks_running); - } - - return(table); -} - /*********************************************************************//** Do the foreign key constraint checks. @return DB_SUCCESS or error code. */ @@ -2858,38 +2531,6 @@ row_discard_tablespace_foreign_key_checks( return(DB_CANNOT_DROP_CONSTRAINT); } -/*********************************************************************//** -Cleanup after the DISCARD TABLESPACE operation. -@return error code. */ -static -dberr_t -row_discard_tablespace_end( -/*=======================*/ - trx_t* trx, /*!< in/out: transaction handle */ - dict_table_t* table, /*!< in/out: table to be discarded */ - dberr_t err) /*!< in: error code */ -{ - if (table != 0) { - dict_table_close(table, TRUE, FALSE); - } - - DBUG_EXECUTE_IF("ib_discard_before_commit_crash", - log_write_up_to(LSN_MAX, true); - DBUG_SUICIDE();); - - trx_commit_for_mysql(trx); - - DBUG_EXECUTE_IF("ib_discard_after_commit_crash", - log_write_up_to(LSN_MAX, true); - DBUG_SUICIDE();); - - row_mysql_unlock_data_dictionary(trx); - - trx->op_info = ""; - - return(err); -} - /*********************************************************************//** Do the DISCARD TABLESPACE operation. @return DB_SUCCESS or error code. */ @@ -2900,17 +2541,17 @@ row_discard_tablespace( trx_t* trx, /*!< in/out: transaction handle */ dict_table_t* table) /*!< in/out: table to be discarded */ { - dberr_t err; + dberr_t err; /* How do we prevent crashes caused by ongoing operations on the table? Old operations could try to access non-existent - pages. MySQL will block all DML on the table using MDL and a + pages. The SQL layer will block all DML on the table using MDL and a DISCARD will not start unless all existing operations on the table to be discarded are completed. - 1) Acquire the data dictionary latch in X mode. To prevent any - internal operations that MySQL is not aware off and also for - the internal SQL parser. + 1) Acquire the data dictionary latch in X mode. This will + prevent any internal operations that are not covered by + MDL or InnoDB table locks. 2) Purge and rollback: we assign a new table id for the table. Since purge and rollback look for the table based on @@ -2943,7 +2584,7 @@ row_discard_tablespace( if (dict_table_has_fts_index(table) || DICT_TF2_FLAG_IS_SET(table, DICT_TF2_FTS_HAS_DOC_ID)) { - fts_drop_tables(trx, table); + fts_drop_tables(trx, *table); } /* Assign a new space ID to the table definition so that purge @@ -2955,23 +2596,6 @@ row_discard_tablespace( return(err); } - /* Discard the physical file that is used for the tablespace. */ - err = fil_delete_tablespace(table->space_id); - switch (err) { - case DB_IO_ERROR: - ib::warn() << "ALTER TABLE " << table->name - << " DISCARD TABLESPACE failed to delete file"; - break; - case DB_TABLESPACE_NOT_FOUND: - ib::warn() << "ALTER TABLE " << table->name - << " DISCARD TABLESPACE failed to find tablespace"; - break; - case DB_SUCCESS: - break; - default: - ut_error; - } - /* All persistent operations successful, update the data dictionary memory cache. */ @@ -2999,73 +2623,83 @@ Discards the tablespace of a table which stored in an .ibd file. Discarding means that this function renames the .ibd file and assigns a new table id for the table. Also the file_unreadable flag is set. @return error code or DB_SUCCESS */ -dberr_t -row_discard_tablespace_for_mysql( -/*=============================*/ - const char* name, /*!< in: table name */ - trx_t* trx) /*!< in: transaction handle */ +dberr_t row_discard_tablespace_for_mysql(dict_table_t *table, trx_t *trx) { - dberr_t err; - dict_table_t* table; + ut_ad(!is_system_tablespace(table->space_id)); + ut_ad(!table->is_temporary()); - /* Open the table and start the transaction if not started. */ + const auto fts_exist = table->flags2 & + (DICT_TF2_FTS_HAS_DOC_ID | DICT_TF2_FTS); - table = row_discard_tablespace_begin(name, trx); + dberr_t err; - if (table == 0) { - err = DB_TABLE_NOT_FOUND; - } else if (table->is_temporary()) { + if (fts_exist) + { + fts_optimize_remove_table(table); + purge_sys.stop_FTS(); + err= fts_lock_tables(trx, *table); + if (err != DB_SUCCESS) + { +rollback: + table->stats_bg_flag= BG_STAT_NONE; + if (fts_exist) + { + purge_sys.resume_FTS(); + fts_optimize_add_table(table); + } + trx->rollback(); + return err; + } + } - ib_senderrf(trx->mysql_thd, IB_LOG_LEVEL_ERROR, - ER_CANNOT_DISCARD_TEMPORARY_TABLE); + row_mysql_lock_data_dictionary(trx); + dict_stats_wait_bg_to_stop_using_table(table, trx); - err = DB_ERROR; + trx->op_info = "discarding tablespace"; + trx->dict_operation= true; - } else if (table->space_id == TRX_SYS_SPACE) { - char table_name[MAX_FULL_NAME_LEN + 1]; + /* Serialize data dictionary operations with dictionary mutex: + this is to avoid deadlocks during data dictionary operations */ - innobase_format_name( - table_name, sizeof(table_name), - table->name.m_name); + err= row_discard_tablespace_foreign_key_checks(trx, table); + if (err != DB_SUCCESS) + { + row_mysql_unlock_data_dictionary(trx); + goto rollback; + } - ib_senderrf(trx->mysql_thd, IB_LOG_LEVEL_ERROR, - ER_TABLE_IN_SYSTEM_TABLESPACE, table_name); + /* Note: The following cannot be rolled back. Rollback would see the + UPDATE of SYS_INDEXES.TABLE_ID as two operations: DELETE and INSERT. + It would invoke btr_free_if_exists() when rolling back the INSERT, + effectively dropping all indexes of the table. Furthermore, calls like + ibuf_delete_for_discarded_space() are already discarding data + before the transaction is committed. - err = DB_ERROR; + It would be better to remove the integrity-breaking + ALTER TABLE...DISCARD TABLESPACE operation altogether. */ + err= row_discard_tablespace(trx, table); + DBUG_EXECUTE_IF("ib_discard_before_commit_crash", + log_write_up_to(LSN_MAX, true); DBUG_SUICIDE();); + /* FTS_ tables may be deleted */ + std::vector deleted; + trx->commit(deleted); + const auto space_id= table->space_id; + pfs_os_file_t d= fil_delete_tablespace(space_id); + table->space= nullptr; + DBUG_EXECUTE_IF("ib_discard_after_commit_crash", DBUG_SUICIDE();); + row_mysql_unlock_data_dictionary(trx); - } else { - ut_ad(!table->n_foreign_key_checks_running); + if (d != OS_FILE_CLOSED) + os_file_close(d); + for (pfs_os_file_t d : deleted) + os_file_close(d); - bool fts_exist = (dict_table_has_fts_index(table) - || DICT_TF2_FLAG_IS_SET( - table, DICT_TF2_FTS_HAS_DOC_ID)); + if (fts_exist) + purge_sys.resume_FTS(); - if (fts_exist) { - row_mysql_unlock_data_dictionary(trx); - fts_optimize_remove_table(table); - row_mysql_lock_data_dictionary(trx); - } - - /* Do foreign key constraint checks. */ - - err = row_discard_tablespace_foreign_key_checks(trx, table); - - if (err == DB_SUCCESS) { - /* Note: This cannot be rolled back. - Rollback would see the UPDATE SYS_INDEXES - as two operations: DELETE and INSERT. - It would invoke btr_free_if_exists() - when rolling back the INSERT, effectively - dropping all indexes of the table. */ - err = row_discard_tablespace(trx, table); - } - - if (fts_exist && err != DB_SUCCESS) { - fts_optimize_add_table(table); - } - } - - return(row_discard_tablespace_end(trx, table, err)); + buf_flush_remove_pages(space_id); + trx->op_info= ""; + return err; } /*********************************************************************//** @@ -3116,532 +2750,6 @@ row_mysql_lock_table( return(err); } -/** Drop ancillary FTS tables as part of dropping a table. -@param[in,out] table Table cache entry -@param[in,out] trx Transaction handle -@return error code or DB_SUCCESS */ -UNIV_INLINE -dberr_t -row_drop_ancillary_fts_tables( - dict_table_t* table, - trx_t* trx) -{ - /* Drop ancillary FTS tables */ - if (dict_table_has_fts_index(table) - || DICT_TF2_FLAG_IS_SET(table, DICT_TF2_FTS_HAS_DOC_ID)) { - - ut_ad(table->get_ref_count() == 0); - ut_ad(trx_is_started(trx)); - - dberr_t err = fts_drop_tables(trx, table); - - if (UNIV_UNLIKELY(err != DB_SUCCESS)) { - ib::error() << " Unable to remove ancillary FTS" - " tables for table " - << table->name << " : " << err; - - return(err); - } - } - - /* The table->fts flag can be set on the table for which - the cluster index is being rebuilt. Such table might not have - DICT_TF2_FTS flag set. So keep this out of above - dict_table_has_fts_index condition */ - if (table->fts != NULL) { - /* fts_que_graph_free_check_lock would try to acquire - dict mutex lock */ - table->fts->dict_locked = true; - - fts_free(table); - } - - return(DB_SUCCESS); -} - -/** Drop a table for MySQL. -If the data dictionary was not already locked by the transaction, -the transaction will be committed. Otherwise, the data dictionary -will remain locked. -@param[in] name Table name -@param[in,out] trx Transaction handle -@param[in] sqlcom type of SQL operation -@param[in] create_failed true=create table failed - because e.g. foreign key column -@param[in] nonatomic Whether it is permitted to release - and reacquire dict_sys.latch -@return error code or DB_SUCCESS */ -dberr_t -row_drop_table_for_mysql( - const char* name, - trx_t* trx, - enum_sql_command sqlcom, - bool create_failed, - bool nonatomic) -{ - dberr_t err; - dict_foreign_t* foreign; - dict_table_t* table; - char* tablename = NULL; - bool locked_dictionary = false; - pars_info_t* info = NULL; - mem_heap_t* heap = NULL; - - - DBUG_ENTER("row_drop_table_for_mysql"); - DBUG_PRINT("row_drop_table_for_mysql", ("table: '%s'", name)); - - ut_a(name != NULL); - - /* Serialize data dictionary operations with dictionary mutex: - no deadlocks can occur then in these operations */ - - trx->op_info = "dropping table"; - - if (trx->dict_operation_lock_mode != RW_X_LATCH) { - /* Prevent foreign key checks etc. while we are - dropping the table */ - - row_mysql_lock_data_dictionary(trx); - - locked_dictionary = true; - nonatomic = true; - } - - ut_d(dict_sys.assert_locked()); - - table = dict_table_open_on_name( - name, TRUE, FALSE, - static_cast( - DICT_ERR_IGNORE_INDEX_ROOT - | DICT_ERR_IGNORE_CORRUPT)); - - if (!table) { - if (locked_dictionary) { - row_mysql_unlock_data_dictionary(trx); - } - trx->op_info = ""; - DBUG_RETURN(DB_TABLE_NOT_FOUND); - } - - pfs_os_file_t detached_handle = OS_FILE_CLOSED; - - const bool is_temp_name = strstr(table->name.m_name, - "/" TEMP_FILE_PREFIX_INNODB); - - if (table->is_temporary()) { - ut_ad(table->space == fil_system.temp_space); - for (dict_index_t* index = dict_table_get_first_index(table); - index != NULL; - index = dict_table_get_next_index(index)) { - btr_free(page_id_t(SRV_TMP_SPACE_ID, index->page)); - } - /* Remove the pointer to this table object from the list - of modified tables by the transaction because the object - is going to be destroyed below. */ - trx->mod_tables.erase(table); - table->release(); - dict_sys.remove(table); - err = DB_SUCCESS; - goto funct_exit_all_freed; - } - - /* This function is called recursively via fts_drop_tables(). */ - if (!trx_is_started(trx)) { - trx_start_for_ddl(trx); - } - - /* Turn on this drop bit before we could release the dictionary - latch */ - table->to_be_dropped = true; - - if (nonatomic) { - /* This trx did not acquire any locks on dictionary - table records yet. Thus it is safe to release and - reacquire the data dictionary latches. */ - if (table->fts) { - row_mysql_unlock_data_dictionary(trx); - fts_optimize_remove_table(table); - row_mysql_lock_data_dictionary(trx); - } - - dict_stats_wait_bg_to_stop_using_table(table, trx); - } - - /* make sure background stats thread is not running on the table */ - ut_ad(!(table->stats_bg_flag & BG_STAT_IN_PROGRESS)); - if (!table->no_rollback()) { - if (table->space != fil_system.sys_space) { - /* Delete the link file if used. */ - if (DICT_TF_HAS_DATA_DIR(table->flags)) { - RemoteDatafile::delete_link_file( - {table->name.m_name, - strlen(table->name.m_name)}); - } - } - - dict_stats_recalc_pool_del(table); - dict_stats_defrag_pool_del(table, NULL); - if (btr_defragment_active) { - btr_defragment_remove_table(table); - } - - if (UNIV_LIKELY(!strstr(name, "/" TEMP_FILE_PREFIX_INNODB))) { - /* Remove any persistent statistics for this table, - in a separate transaction. */ - char errstr[1024]; - err = dict_stats_drop_table(name, errstr, - sizeof errstr); - if (err != DB_SUCCESS) { - ib::warn() << errstr; - } - } - } - - dict_sys.prevent_eviction(table); - dict_table_close(table, TRUE, FALSE); - - /* Check if the table is referenced by foreign key constraints from - some other table (not the table itself) */ - - if (!srv_read_only_mode && trx->check_foreigns) { - - for (dict_foreign_set::iterator it - = table->referenced_set.begin(); - it != table->referenced_set.end(); - ++it) { - - foreign = *it; - - const bool ref_ok = sqlcom == SQLCOM_DROP_DB - && dict_tables_have_same_db( - name, - foreign->foreign_table_name_lookup); - - /* We should allow dropping a referenced table if creating - that referenced table has failed for some reason. For example - if referenced table is created but it column types that are - referenced do not match. */ - if (foreign->foreign_table != table && - !create_failed && !ref_ok) { - - FILE* ef = dict_foreign_err_file; - - /* We only allow dropping a referenced table - if FOREIGN_KEY_CHECKS is set to 0 */ - - err = DB_CANNOT_DROP_CONSTRAINT; - - mysql_mutex_lock(&dict_foreign_err_mutex); - rewind(ef); - ut_print_timestamp(ef); - - fputs(" Cannot drop table ", ef); - ut_print_name(ef, trx, name); - fputs("\n" - "because it is referenced by ", ef); - ut_print_name(ef, trx, - foreign->foreign_table_name); - putc('\n', ef); - mysql_mutex_unlock(&dict_foreign_err_mutex); - - goto funct_exit; - } - } - } - - DBUG_EXECUTE_IF("row_drop_table_add_to_background", goto defer;); - - /* TODO: could we replace the counter n_foreign_key_checks_running - with lock checks on the table? Acquire here an exclusive lock on the - table, and rewrite lock0lock.cc and the lock wait in srv0srv.cc so that - they can cope with the table having been dropped here? Foreign key - checks take an IS or IX lock on the table. */ - - if (table->n_foreign_key_checks_running > 0) { -defer: - /* Rename the table to #sql-ib prefix. This scenario can - occur also for #sql tables when purge is waiting for - dict_sys.mutex so that it could close the table. But - DROP TABLE acquires dict_sys.mutex. */ - if (!is_temp_name) { - heap = mem_heap_create(FN_REFLEN); - const char* tmp_name - = dict_mem_create_temporary_tablename( - heap, table->name.m_name, table->id); - ib::info() << "Deferring DROP TABLE " << table->name - << "; renaming to " << tmp_name; - err = row_rename_table_for_mysql( - table->name.m_name, tmp_name, trx, - false, false); - } else { - err = DB_SUCCESS; - } - if (err == DB_SUCCESS) { - row_add_table_to_background_drop_list(table->id); - } - goto funct_exit; - } - - /* Remove all locks that are on the table or its records, if there - are no references to the table but it has record locks, we release - the record locks unconditionally. One use case is: - - CREATE TABLE t2 (PRIMARY KEY (a)) SELECT * FROM t1; - - If after the user transaction has done the SELECT and there is a - problem in completing the CREATE TABLE operation, MySQL will drop - the table. InnoDB will create a new background transaction to do the - actual drop, the trx instance that is passed to this function. To - preserve existing behaviour we remove the locks but ideally we - shouldn't have to. There should never be record locks on a table - that is going to be dropped. */ - - if (table->get_ref_count() > 0 || lock_table_has_locks(table)) { - goto defer; - } - - /* The "to_be_dropped" marks table that is to be dropped, but - has not been dropped, instead, was put in the background drop - list due to being used by concurrent DML operations. Clear it - here since there are no longer any concurrent activities on it, - and it is free to be dropped */ - table->to_be_dropped = false; - - trx->dict_operation = true; - - /* Mark all indexes unavailable in the data dictionary cache - before starting to drop the table. */ - - unsigned* page_no; - unsigned* page_nos; - heap = mem_heap_create( - 200 + UT_LIST_GET_LEN(table->indexes) * sizeof *page_nos); - tablename = mem_heap_strdup(heap, name); - - page_no = page_nos = static_cast( - mem_heap_alloc( - heap, - UT_LIST_GET_LEN(table->indexes) * sizeof *page_no)); - - for (dict_index_t* index = dict_table_get_first_index(table); - index != NULL; - index = dict_table_get_next_index(index)) { - index->lock.x_lock(SRW_LOCK_CALL); - /* Save the page numbers so that we can restore them - if the operation fails. */ - *page_no++ = index->page; - /* Mark the index unusable. */ - index->page = FIL_NULL; - index->lock.x_unlock(); - } - - /* Deleting a row from SYS_INDEXES table will invoke - dict_drop_index_tree(). */ - info = pars_info_create(); - - pars_info_add_str_literal(info, "name", name); - - if (sqlcom != SQLCOM_TRUNCATE && strchr(name, '/') - && dict_sys.sys_foreign && dict_sys.sys_foreign_cols) { - err = que_eval_sql( - info, - "PROCEDURE DROP_FOREIGN_PROC () IS\n" - "fid CHAR;\n" - - "DECLARE CURSOR fk IS\n" - "SELECT ID FROM SYS_FOREIGN\n" - "WHERE FOR_NAME = :name\n" - "AND TO_BINARY(FOR_NAME) = TO_BINARY(:name)\n" - "FOR UPDATE;\n" - - "BEGIN\n" - "OPEN fk;\n" - "WHILE 1 = 1 LOOP\n" - " FETCH fk INTO fid;\n" - " IF (SQL % NOTFOUND) THEN RETURN; END IF;\n" - " DELETE FROM SYS_FOREIGN_COLS WHERE ID=fid;\n" - " DELETE FROM SYS_FOREIGN WHERE ID=fid;\n" - "END LOOP;\n" - "CLOSE fk;\n" - "END;\n", FALSE, trx); - if (err == DB_SUCCESS) { - info = pars_info_create(); - pars_info_add_str_literal(info, "name", name); - goto do_drop; - } - } else { -do_drop: - if (dict_sys.sys_virtual) { - err = que_eval_sql( - info, - "PROCEDURE DROP_VIRTUAL_PROC () IS\n" - "tid CHAR;\n" - - "BEGIN\n" - "SELECT ID INTO tid FROM SYS_TABLES\n" - "WHERE NAME = :name FOR UPDATE;\n" - "IF (SQL % NOTFOUND) THEN RETURN;" - " END IF;\n" - "DELETE FROM SYS_VIRTUAL" - " WHERE TABLE_ID = tid;\n" - "END;\n", FALSE, trx); - if (err == DB_SUCCESS) { - info = pars_info_create(); - pars_info_add_str_literal( - info, "name", name); - } - } else { - err = DB_SUCCESS; - } - - err = err == DB_SUCCESS ? que_eval_sql( - info, - "PROCEDURE DROP_TABLE_PROC () IS\n" - "tid CHAR;\n" - "iid CHAR;\n" - - "DECLARE CURSOR cur_idx IS\n" - "SELECT ID FROM SYS_INDEXES\n" - "WHERE TABLE_ID = tid FOR UPDATE;\n" - - "BEGIN\n" - "SELECT ID INTO tid FROM SYS_TABLES\n" - "WHERE NAME = :name FOR UPDATE;\n" - "IF (SQL % NOTFOUND) THEN RETURN; END IF;\n" - - "OPEN cur_idx;\n" - "WHILE 1 = 1 LOOP\n" - " FETCH cur_idx INTO iid;\n" - " IF (SQL % NOTFOUND) THEN EXIT; END IF;\n" - " DELETE FROM SYS_FIELDS\n" - " WHERE INDEX_ID = iid;\n" - " DELETE FROM SYS_INDEXES\n" - " WHERE ID = iid AND TABLE_ID = tid;\n" - "END LOOP;\n" - "CLOSE cur_idx;\n" - - "DELETE FROM SYS_COLUMNS WHERE TABLE_ID=tid;\n" - "DELETE FROM SYS_TABLES WHERE NAME=:name;\n" - - "END;\n", FALSE, trx) : err; - } - - switch (err) { - fil_space_t* space; - char* filepath; - case DB_SUCCESS: - if (!table->no_rollback()) { - err = row_drop_ancillary_fts_tables(table, trx); - if (err != DB_SUCCESS) { - break; - } - } - - space = table->space; - ut_ad(!space || space->id == table->space_id); - /* Determine the tablespace filename before we drop - dict_table_t. */ - if (DICT_TF_HAS_DATA_DIR(table->flags)) { - dict_get_and_save_data_dir_path(table, true); - ut_ad(table->data_dir_path || !space); - } - - filepath = space - ? nullptr - : fil_make_filepath(table->data_dir_path, table->name, - IBD, - table->data_dir_path != nullptr); - - trx->mod_tables.erase(table); - dict_sys.remove(table); - - /* Do not attempt to drop known-to-be-missing tablespaces, - nor the system tablespace. */ - if (!space) { - fil_delete_file(filepath); - ut_free(filepath); - break; - } - - ut_ad(!filepath); - - if (space->id != TRX_SYS_SPACE) { - err = fil_delete_tablespace(space->id, false, - &detached_handle); - } - break; - - default: - /* This is some error we do not expect. Print - the error number and rollback the transaction */ - ib::error() << "Unknown error code " << err << " while" - " dropping table: " - << ut_get_name(trx, tablename) << "."; - - trx->error_state = DB_SUCCESS; - trx->rollback(); - trx->error_state = DB_SUCCESS; - - /* Mark all indexes available in the data dictionary - cache again. */ - - page_no = page_nos; - - for (dict_index_t* index = dict_table_get_first_index(table); - index != NULL; - index = dict_table_get_next_index(index)) { - index->lock.x_lock(SRW_LOCK_CALL); - ut_a(index->page == FIL_NULL); - index->page = *page_no++; - index->lock.x_unlock(); - } - } - - if (err != DB_SUCCESS && table != NULL) { - /* Drop table has failed with error but as drop table is not - transaction safe we should mark the table as corrupted to avoid - unwarranted follow-up action on this table that can result - in more serious issues. */ - - table->corrupted = true; - for (dict_index_t* index = UT_LIST_GET_FIRST(table->indexes); - index != NULL; - index = UT_LIST_GET_NEXT(indexes, index)) { - dict_set_corrupted(index, trx, "DROP TABLE"); - } - } - -funct_exit: - if (heap) { - mem_heap_free(heap); - } - -funct_exit_all_freed: - if (locked_dictionary) { - - if (trx_is_started(trx)) { - - trx_commit_for_mysql(trx); - } - - /* Add the table to fts queue if drop table fails */ - if (err != DB_SUCCESS && table->fts) { - fts_optimize_add_table(table); - } - - row_mysql_unlock_data_dictionary(trx); - } - - if (detached_handle != OS_FILE_CLOSED) { - os_file_close(detached_handle); - } - - trx->op_info = ""; - - DBUG_RETURN(err); -} - /****************************************************************//** Delete a single constraint. @return error code or DB_SUCCESS */ @@ -3707,7 +2815,6 @@ row_rename_table_for_mysql( const char* old_name, /*!< in: old table name */ const char* new_name, /*!< in: new table name */ trx_t* trx, /*!< in/out: transaction */ - bool commit, /*!< in: whether to commit trx */ bool use_fk) /*!< in: whether to parse and enforce FOREIGN KEY constraints */ { @@ -3718,14 +2825,12 @@ row_rename_table_for_mysql( ulint n_constraints_to_drop = 0; ibool old_is_tmp, new_is_tmp; pars_info_t* info = NULL; - int retry; char* is_part = NULL; ut_a(old_name != NULL); ut_a(new_name != NULL); ut_ad(trx->state == TRX_STATE_ACTIVE); - const bool dict_locked = trx->dict_operation_lock_mode == RW_X_LATCH; - ut_ad(!commit || dict_locked); + ut_ad(trx->dict_operation_lock_mode == RW_X_LATCH); if (high_level_read_only) { return(DB_READ_ONLY); @@ -3744,7 +2849,7 @@ row_rename_table_for_mysql( old_is_tmp = dict_table_t::is_temporary_name(old_name); new_is_tmp = dict_table_t::is_temporary_name(new_name); - table = dict_table_open_on_name(old_name, dict_locked, FALSE, + table = dict_table_open_on_name(old_name, true, false, DICT_ERR_IGNORE_FK_NOKEY); /* We look for pattern #P# to see if the table is partitioned @@ -3789,16 +2894,19 @@ row_rename_table_for_mysql( normalize_table_name_c_low( par_case_name, old_name, FALSE); #endif - table = dict_table_open_on_name(par_case_name, dict_locked, FALSE, + table = dict_table_open_on_name(par_case_name, true, false, DICT_ERR_IGNORE_FK_NOKEY); } if (!table) { err = DB_TABLE_NOT_FOUND; goto funct_exit; + } - } else if (!table->is_readable() && !table->space - && !(table->flags2 & DICT_TF2_DISCARDED)) { + ut_ad(!table->is_temporary()); + + if (!table->is_readable() && !table->space + && !(table->flags2 & DICT_TF2_DISCARDED)) { err = DB_TABLE_NOT_FOUND; @@ -3826,35 +2934,12 @@ row_rename_table_for_mysql( } } - /* Is a foreign key check running on this table? */ - for (retry = 0; retry < 100 - && table->n_foreign_key_checks_running > 0; ++retry) { - row_mysql_unlock_data_dictionary(trx); - std::this_thread::yield(); - row_mysql_lock_data_dictionary(trx); - } + err = trx_undo_report_rename(trx, table); - if (table->n_foreign_key_checks_running > 0) { - ib::error() << "In ALTER TABLE " - << ut_get_name(trx, old_name) - << " a FOREIGN KEY check is running. Cannot rename" - " table."; - err = DB_TABLE_IN_FK_CHECK; + if (err != DB_SUCCESS) { goto funct_exit; } - if (!table->is_temporary()) { - if (commit) { - dict_stats_wait_bg_to_stop_using_table(table, trx); - } - - err = trx_undo_report_rename(trx, table); - - if (err != DB_SUCCESS) { - goto funct_exit; - } - } - /* We use the private SQL parser of Innobase to generate the query graphs needed in updating the dictionary data from system tables. */ @@ -4106,16 +3191,8 @@ row_rename_table_for_mysql( } funct_exit: - if (table != NULL) { - if (commit && !table->is_temporary()) { - table->stats_bg_flag &= byte(~BG_STAT_SHOULD_QUIT); - } - dict_table_close(table, dict_locked, FALSE); - } - - if (commit) { - DEBUG_SYNC(trx->mysql_thd, "before_rename_table_commit"); - trx_commit_for_mysql(trx); + if (table) { + table->release(); } if (UNIV_LIKELY_NULL(heap)) { @@ -4305,28 +3382,3 @@ not_ok: goto loop; } - -/** Initialize this module */ -void row_mysql_init() -{ - mysql_mutex_init(row_drop_list_mutex_key, &row_drop_list_mutex, nullptr); - UT_LIST_INIT(row_mysql_drop_list, &row_mysql_drop_t::row_mysql_drop_list); - row_mysql_drop_list_inited= true; -} - -void row_mysql_close() -{ - ut_ad(!UT_LIST_GET_LEN(row_mysql_drop_list) || - srv_force_recovery >= SRV_FORCE_NO_BACKGROUND); - if (row_mysql_drop_list_inited) - { - row_mysql_drop_list_inited= false; - mysql_mutex_destroy(&row_drop_list_mutex); - - while (row_mysql_drop_t *drop= UT_LIST_GET_FIRST(row_mysql_drop_list)) - { - UT_LIST_REMOVE(row_mysql_drop_list, drop); - ut_free(drop); - } - } -} diff --git a/storage/innobase/row/row0purge.cc b/storage/innobase/row/row0purge.cc index db895b9a184..1269c7ae86e 100644 --- a/storage/innobase/row/row0purge.cc +++ b/storage/innobase/row/row0purge.cc @@ -111,8 +111,10 @@ row_purge_remove_clust_if_poss_low( MDL_ticket* mdl_ticket = nullptr; dict_table_t *table = nullptr; pfs_os_file_t f = OS_FILE_CLOSED; -retry: + if (table_id) { +retry: + purge_sys.check_stop_FTS(); dict_sys.mutex_lock(); table = dict_table_open_on_id( table_id, true, DICT_TABLE_OP_OPEN_ONLY_IF_CACHED, @@ -184,7 +186,7 @@ close_and_exit: mdl_ticket = nullptr; } } - fil_delete_tablespace(space_id, true, &f); + f = fil_delete_tablespace(space_id); } mtr.commit(); @@ -739,6 +741,12 @@ void purge_sys_t::wait_SYS() std::this_thread::sleep_for(std::chrono::seconds(1)); } +void purge_sys_t::wait_FTS() +{ + while (must_wait_FTS()) + std::this_thread::sleep_for(std::chrono::seconds(1)); +} + /** Reset DB_TRX_ID, DB_ROLL_PTR of a clustered index record whose old history can no longer be observed. @param[in,out] node purge node @@ -1034,11 +1042,13 @@ row_purge_parse_undo_rec( } try_again: + purge_sys.check_stop_FTS(); + node->table = dict_table_open_on_id( table_id, false, DICT_TABLE_OP_NORMAL, node->purge_thd, &node->mdl_ticket); - if (node->table == NULL || node->table->name.is_temporary()) { + if (!node->table) { /* The table has been dropped: no need to do purge and release mdl happened as a part of open process itself */ goto err_exit; diff --git a/storage/innobase/row/row0uins.cc b/storage/innobase/row/row0uins.cc index 51a5d30e7d3..fce9575aa9d 100644 --- a/storage/innobase/row/row0uins.cc +++ b/storage/innobase/row/row0uins.cc @@ -140,6 +140,27 @@ restart: mem_heap_free(heap); } else { switch (node->table->id) { + case DICT_COLUMNS_ID: + /* This is rolling back an INSERT into SYS_COLUMNS. + If it was part of an instant ALTER TABLE operation, we + must evict the table definition, so that it can be + reloaded after the dictionary operation has been + completed. At this point, any corresponding operation + to the metadata record will have been rolled back. */ + ut_ad(!online); + ut_ad(node->trx->dict_operation_lock_mode + == RW_X_LATCH); + ut_ad(node->rec_type == TRX_UNDO_INSERT_REC); + if (rec_get_n_fields_old(rec) + != DICT_NUM_FIELDS__SYS_COLUMNS + || (rec_get_1byte_offs_flag(rec) + ? rec_1_get_field_end_info(rec, 0) != 8 + : rec_2_get_field_end_info(rec, 0) != 8)) { + break; + } + static_assert(!DICT_FLD__SYS_COLUMNS__TABLE_ID, ""); + node->trx->evict_table(mach_read_from_8(rec)); + break; case DICT_INDEXES_ID: ut_ad(!online); ut_ad(node->trx->dict_operation_lock_mode @@ -154,6 +175,8 @@ restart: ut_ad("corrupted SYS_INDEXES record" == 0); } + pfs_os_file_t d = OS_FILE_CLOSED; + if (const uint32_t space_id = dict_drop_index_tree( &node->pcur, node->trx, &mtr)) { if (table) { @@ -185,36 +208,19 @@ restart: } } - fil_delete_tablespace(space_id, true); + d = fil_delete_tablespace(space_id); } mtr.commit(); + if (d != OS_FILE_CLOSED) { + os_file_close(d); + } + mtr.start(); success = btr_pcur_restore_position( BTR_MODIFY_LEAF, &node->pcur, &mtr); ut_a(success); - break; - case DICT_COLUMNS_ID: - /* This is rolling back an INSERT into SYS_COLUMNS. - If it was part of an instant ALTER TABLE operation, we - must evict the table definition, so that it can be - reloaded after the dictionary operation has been - completed. At this point, any corresponding operation - to the metadata record will have been rolled back. */ - ut_ad(!online); - ut_ad(node->trx->dict_operation_lock_mode - == RW_X_LATCH); - ut_ad(node->rec_type == TRX_UNDO_INSERT_REC); - if (rec_get_n_fields_old(rec) - != DICT_NUM_FIELDS__SYS_COLUMNS - || (rec_get_1byte_offs_flag(rec) - ? rec_1_get_field_end_info(rec, 0) != 8 - : rec_2_get_field_end_info(rec, 0) != 8)) { - break; - } - static_assert(!DICT_FLD__SYS_COLUMNS__TABLE_ID, ""); - node->trx->evict_table(mach_read_from_8(rec)); } } diff --git a/storage/innobase/row/row0upd.cc b/storage/innobase/row/row0upd.cc index 0a259726198..d68280cbeb3 100644 --- a/storage/innobase/row/row0upd.cc +++ b/storage/innobase/row/row0upd.cc @@ -281,21 +281,9 @@ row_upd_check_references_constraints( FALSE, FALSE, DICT_ERR_IGNORE_NONE); } - if (foreign_table) { - foreign_table->inc_fk_checks(); - } - - /* NOTE that if the thread ends up waiting for a lock - we will release dict_sys.latch temporarily! - But the inc_fk_checks() protects foreign_table from - being dropped while the check is running. */ - err = row_ins_check_foreign_constraint( FALSE, foreign, table, entry, thr); - if (foreign_table) { - foreign_table->dec_fk_checks(); - } if (ref_table != NULL) { dict_table_close(ref_table, FALSE, FALSE); } diff --git a/storage/innobase/srv/srv0mon.cc b/storage/innobase/srv/srv0mon.cc index eea86c2cae6..cd7e5c526d8 100644 --- a/storage/innobase/srv/srv0mon.cc +++ b/storage/innobase/srv/srv0mon.cc @@ -1090,11 +1090,6 @@ static monitor_info_t innodb_counter_info[] = MONITOR_NONE, MONITOR_DEFAULT_START, MONITOR_MASTER_IDLE_LOOPS}, - {"innodb_background_drop_table_usec", "server", - "Time (in microseconds) spent to process drop table list", - MONITOR_NONE, - MONITOR_DEFAULT_START, MONITOR_SRV_BACKGROUND_DROP_TABLE_MICROSECOND}, - {"innodb_log_flush_usec", "server", "Time (in microseconds) spent to flush log records", MONITOR_NONE, @@ -1189,11 +1184,6 @@ static monitor_info_t innodb_counter_info[] = MONITOR_NONE, MONITOR_DEFAULT_START, MONITOR_BACKGROUND_DROP_INDEX}, - {"ddl_background_drop_tables", "ddl", - "Number of tables in background drop table list", - MONITOR_NONE, - MONITOR_DEFAULT_START, MONITOR_BACKGROUND_DROP_TABLE}, - {"ddl_online_create_index", "ddl", "Number of indexes being created online", MONITOR_NONE, diff --git a/storage/innobase/srv/srv0srv.cc b/storage/innobase/srv/srv0srv.cc index 09f997d3d6d..74da09b605a 100644 --- a/storage/innobase/srv/srv0srv.cc +++ b/storage/innobase/srv/srv0srv.cc @@ -677,7 +677,6 @@ srv_boot(void) { srv_thread_pool_init(); trx_pool_init(); - row_mysql_init(); srv_init(); } @@ -1374,6 +1373,8 @@ void purge_sys_t::stop_SYS() /** Stop purge during FLUSH TABLES FOR EXPORT */ void purge_sys_t::stop() { + dict_sys.assert_not_locked(); + for (;;) { latch.wr_lock(SRW_LOCK_CALL); @@ -1471,10 +1472,7 @@ The master thread is tasked to ensure that flush of log file happens once every second in the background. This is to ensure that not more than one second of trxs are lost in case of crash when innodb_flush_logs_at_trx_commit != 1 */ -static -void -srv_sync_log_buffer_in_background(void) -/*===================================*/ +static void srv_sync_log_buffer_in_background() { time_t current_time = time(NULL); @@ -1496,8 +1494,6 @@ srv_shutdown_print_master_pending( /*==============================*/ time_t* last_print_time, /*!< last time the function print the message */ - ulint n_tables_to_drop, /*!< number of tables to - be dropped */ ulint n_bytes_merged) /*!< number of change buffer just merged */ { @@ -1506,11 +1502,6 @@ srv_shutdown_print_master_pending( if (difftime(current_time, *last_print_time) > 60) { *last_print_time = current_time; - if (n_tables_to_drop) { - ib::info() << "Waiting for " << n_tables_to_drop - << " table(s) to be dropped"; - } - /* Check change buffer merge, we only wait for change buffer merge if it is a slow shutdown */ if (!srv_fast_shutdown && n_bytes_merged) { @@ -1585,14 +1576,6 @@ srv_master_do_active_tasks(void) MONITOR_INC(MONITOR_MASTER_ACTIVE_LOOPS); - /* ALTER TABLE in MySQL requires on Unix that the table handler - can drop tables lazily after there no longer are SELECT - queries to them. */ - srv_main_thread_op_info = "doing background drop tables"; - row_drop_tables_for_mysql_in_background(); - MONITOR_INC_TIME_IN_MICRO_SECS( - MONITOR_SRV_BACKGROUND_DROP_TABLE_MICROSECOND, counter_time); - ut_d(srv_master_do_disabled_loop()); if (srv_shutdown_state > SRV_SHUTDOWN_INITIATED) { @@ -1646,17 +1629,6 @@ srv_master_do_idle_tasks(void) MONITOR_INC(MONITOR_MASTER_IDLE_LOOPS); - - /* ALTER TABLE in MySQL requires on Unix that the table handler - can drop tables lazily after there no longer are SELECT - queries to them. */ - ulonglong counter_time = microsecond_interval_timer(); - srv_main_thread_op_info = "doing background drop tables"; - row_drop_tables_for_mysql_in_background(); - MONITOR_INC_TIME_IN_MICRO_SECS( - MONITOR_SRV_BACKGROUND_DROP_TABLE_MICROSECOND, - counter_time); - ut_d(srv_master_do_disabled_loop()); if (srv_shutdown_state > SRV_SHUTDOWN_INITIATED) { @@ -1672,6 +1644,7 @@ srv_master_do_idle_tasks(void) return; } + ulonglong counter_time = microsecond_interval_timer(); srv_main_thread_op_info = "enforcing dict cache limit"; if (ulint n_evicted = dict_sys.evict_table_LRU(false)) { MONITOR_INC_VALUE( @@ -1692,7 +1665,6 @@ and optionally change buffer merge (on innodb_fast_shutdown=0). */ void srv_shutdown(bool ibuf_merge) { ulint n_bytes_merged = 0; - ulint n_tables_to_drop; time_t now = time(NULL); do { @@ -1700,11 +1672,6 @@ void srv_shutdown(bool ibuf_merge) ut_ad(srv_shutdown_state == SRV_SHUTDOWN_CLEANUP); ++srv_main_shutdown_loops; - /* FIXME: Remove the background DROP TABLE queue; it is not - crash-safe and breaks ACID. */ - srv_main_thread_op_info = "doing background drop tables"; - n_tables_to_drop = row_drop_tables_for_mysql_in_background(); - if (ibuf_merge) { srv_main_thread_op_info = "checking free log space"; log_free_check(); @@ -1717,10 +1684,10 @@ void srv_shutdown(bool ibuf_merge) /* Print progress message every 60 seconds during shutdown */ if (srv_print_verbose_log) { - srv_shutdown_print_master_pending( - &now, n_tables_to_drop, n_bytes_merged); + srv_shutdown_print_master_pending(&now, + n_bytes_merged); } - } while (n_bytes_merged || n_tables_to_drop); + } while (n_bytes_merged); } /** The periodic master task controlling the server. */ diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc index 27b56d84563..9b51d225318 100644 --- a/storage/innobase/srv/srv0start.cc +++ b/storage/innobase/srv/srv0start.cc @@ -1764,9 +1764,6 @@ file_checked: && !srv_read_only_mode) { /* Drop partially created indexes. */ row_merge_drop_temp_indexes(); - /* Drop garbage tables. */ - row_mysql_drop_garbage_tables(); - /* Rollback incomplete non-DDL transactions */ trx_rollback_is_active = true; srv_thread_pool->submit_task(&rollback_all_recovered_task); @@ -1898,10 +1895,6 @@ void srv_shutdown_bg_undo_sources() ut_ad(!srv_read_only_mode); fts_optimize_shutdown(); dict_stats_shutdown(); - while (row_get_background_drop_list_len_low()) { - srv_inc_activity_count(); - std::this_thread::yield(); - } srv_undo_sources = false; } } @@ -2028,7 +2021,6 @@ void innodb_shutdown() dict_sys.close(); btr_search_sys_free(); - row_mysql_close(); srv_free(); fil_system.close(); pars_lexer_close(); diff --git a/storage/innobase/trx/trx0purge.cc b/storage/innobase/trx/trx0purge.cc index f1dce39c21d..300e664bf5a 100644 --- a/storage/innobase/trx/trx0purge.cc +++ b/storage/innobase/trx/trx0purge.cc @@ -694,7 +694,8 @@ not_free: /* Adjust the tablespace metadata. */ mysql_mutex_lock(&fil_system.mutex); - space.set_stopping(true); + ut_d(bool stopped=) space.set_stopping(); + ut_ad(!stopped); space.is_being_truncated = true; if (space.crypt_data) { space.reacquire(); @@ -806,7 +807,7 @@ not_free: mysql_mutex_lock(&fil_system.mutex); ut_ad(&space == purge_sys.truncate.current); ut_ad(space.is_being_truncated); - purge_sys.truncate.current->set_stopping(false); + purge_sys.truncate.current->clear_stopping(); purge_sys.truncate.current->is_being_truncated = false; mysql_mutex_unlock(&fil_system.mutex); diff --git a/storage/innobase/trx/trx0roll.cc b/storage/innobase/trx/trx0roll.cc index 4ccacaff683..662b62539c8 100644 --- a/storage/innobase/trx/trx0roll.cc +++ b/storage/innobase/trx/trx0roll.cc @@ -59,6 +59,8 @@ const trx_t* trx_roll_crash_recv_trx; @retval false if the rollback was aborted by shutdown */ inline bool trx_t::rollback_finish() { + mod_tables.clear(); + if (UNIV_LIKELY(error_state == DB_SUCCESS)) { commit(); @@ -89,6 +91,7 @@ inline bool trx_t::rollback_finish() undo= nullptr; } commit_low(); + commit_cleanup(); return false; } diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc index 916d3e0bd2e..6b4436927c4 100644 --- a/storage/innobase/trx/trx0trx.cc +++ b/storage/innobase/trx/trx0trx.cc @@ -1427,6 +1427,10 @@ inline void trx_t::commit_in_memory(const mtr_t *mtr) ut_ad(!(lock.was_chosen_as_deadlock_victim & byte(~2U))); lock.was_chosen_as_deadlock_victim= false; #endif /* WITH_WSREP */ +} + +void trx_t::commit_cleanup() +{ mutex.wr_lock(); dict_operation= false; @@ -1452,16 +1456,19 @@ void trx_t::commit_low(mtr_t *mtr) ut_ad(!mtr == (aborted || !has_logged_or_recovered())); ut_ad(!mtr || !aborted); - /* undo_no is non-zero if we're doing the final commit. */ if (fts_trx && undo_no) { ut_a(!is_autocommit_non_locking()); - /* FTS-FIXME: Temporarily tolerate DB_DUPLICATE_KEY instead of - dying. This is a possible scenario if there is a crash between + /* MDEV-24088 FIXME: Invoke fts_commit() earlier (before possible + XA PREPARE), so that we will be able to return an error and rollback + the transaction, instead of violating consistency! + + The original claim about DB_DUPLICATE KEY was: + This is a possible scenario if there is a crash between insert to DELETED table committing and transaction committing. The fix would be able to return error from this function */ - if (dberr_t error= fts_commit(this)) - ut_a(error == DB_DUPLICATE_KEY); + if (ut_d(dberr_t error=) fts_commit(this)) + ut_ad(error == DB_DUPLICATE_KEY || error == DB_LOCK_WAIT_TIMEOUT); } #ifndef DBUG_OFF @@ -1498,7 +1505,7 @@ void trx_t::commit_low(mtr_t *mtr) } -void trx_t::commit() +void trx_t::commit_persist() { mtr_t *mtr= nullptr; mtr_t local_mtr; @@ -1511,6 +1518,15 @@ void trx_t::commit() commit_low(mtr); } + +void trx_t::commit() +{ + commit_persist(); + ut_d(for (const auto &p : mod_tables) ut_ad(!p.second.is_dropped())); + commit_cleanup(); +} + + /****************************************************************//** Prepares a transaction for commit/rollback. */ void diff --git a/storage/innobase/ut/ut0ut.cc b/storage/innobase/ut/ut0ut.cc index 41ba54d9a8d..d49fa9fb16c 100644 --- a/storage/innobase/ut/ut0ut.cc +++ b/storage/innobase/ut/ut0ut.cc @@ -428,8 +428,6 @@ ut_strerr( return("End of index"); case DB_IO_ERROR: return("I/O error"); - case DB_TABLE_IN_FK_CHECK: - return("Table is being used in foreign key check"); case DB_NOT_FOUND: return("not found"); case DB_ONLINE_LOG_TOO_BIG: diff --git a/storage/rocksdb/mysql-test/rocksdb/r/innodb_i_s_tables_disabled.result b/storage/rocksdb/mysql-test/rocksdb/r/innodb_i_s_tables_disabled.result index 7cedb9283a6..8f0357a8954 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/innodb_i_s_tables_disabled.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/innodb_i_s_tables_disabled.result @@ -210,7 +210,6 @@ innodb_master_thread_sleeps server 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL N innodb_activity_count server 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Current server activity count innodb_master_active_loops server 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of times master thread performs its tasks when server is active innodb_master_idle_loops server 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of times master thread performs its tasks when server is idle -innodb_background_drop_table_usec server 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Time (in microseconds) spent to process drop table list innodb_log_flush_usec server 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Time (in microseconds) spent to flush log records innodb_dict_lru_usec server 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Time (in microseconds) spent to process DICT LRU list innodb_dict_lru_count_active server 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of tables evicted from DICT LRU list in the active loop @@ -227,7 +226,6 @@ dml_system_inserts dml 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 s dml_system_deletes dml 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of system rows deleted dml_system_updates dml 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 status_counter Number of system rows updated ddl_background_drop_indexes ddl 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of indexes waiting to be dropped after failed index creation -ddl_background_drop_tables ddl 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of tables in background drop table list ddl_online_create_index ddl 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of indexes being created online ddl_pending_alter_table ddl 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of ALTER TABLE, CREATE INDEX, DROP INDEX in progress ddl_sort_file_alter_table ddl 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NULL 0 counter Number of sort files created during alter table From 2c6d5c92c7e0e8b38dcb9fad94c7bf11ef4ba4b6 Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Mon, 24 May 2021 15:41:08 +0530 Subject: [PATCH 038/251] MDEV-25642 InnoDB rename table copy DDL fails while dropping the table When doing a ALTER TABLE ... RENAME, MariaDB doesn't rename original table to #sql-backup, which it does in other cases, but insteads drops the original table directly. However this optimization doesn't work in case of InnoDB table with a foreign key constraint. During copy algorithm, InnoDB fails to rename the foreign key constraint(MDEV-25855). With this optimisation, InnoDB also fails to drop the original table because the table has FOREIGN Key constraint exist in INNODB_SYS_FOREIGN table. This leads to orphan .ibd file in InnoDB dictionary. so disabling this optimization when FK is involved. Reviewer: monty@mariadb.org --- mysql-test/suite/innodb/r/innodb-fk.result | 15 +++++++++++++++ mysql-test/suite/innodb/t/innodb-fk.test | 16 ++++++++++++++++ sql/sql_table.cc | 9 +++++++-- 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/mysql-test/suite/innodb/r/innodb-fk.result b/mysql-test/suite/innodb/r/innodb-fk.result index d3c1aa77eaf..ce873be93da 100644 --- a/mysql-test/suite/innodb/r/innodb-fk.result +++ b/mysql-test/suite/innodb/r/innodb-fk.result @@ -206,3 +206,18 @@ c0123456789012345678 int, FOREIGN KEY (a012345678901234567,c0123456789012345678,b) REFERENCES tx (x1,x2,x3) ) ENGINE=InnoDB; ERROR HY000: Can't create table `test`.`t1` (errno: 150 "Foreign key constraint is incorrectly formed") +# +# MDEV-25642 InnoDB rename table copy DDL fails +# while dropping the table +# +call mtr.add_suppression("InnoDB: In ALTER TABLE `test`.`t1` has or is referenced in foreign key constraints which are not compatible with the new table definition."); +CREATE TABLE t1 (a VARCHAR(10) NOT NULL PRIMARY KEY) ENGINE=InnoDB; +CREATE TABLE t1_fk (a VARCHAR(40), KEY a (a), FULLTEXT KEY(a), CONSTRAINT fk FOREIGN KEY(a) REFERENCES t1 (a) ON UPDATE CASCADE) ENGINE=InnoDB; +ALTER TABLE t1 RENAME TO tm1, ALGORITHM=COPY; +SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN; +ID FOR_NAME REF_NAME N_COLS TYPE +test/fk test/t1_fk test/t1 1 4 +SET FOREIGN_KEY_CHECKS=0; +CREATE TABLE t1 (c1 BIGINT NOT NULL, c2 BIGINT NOT NULL, PRIMARY KEY(c1), UNIQUE KEY(c2)) ENGINE=MEMORY; +ALTER TABLE t1 ENGINE=InnoDB, ALGORITHM=COPY; +DROP TABLE t1, tm1, t1_fk; diff --git a/mysql-test/suite/innodb/t/innodb-fk.test b/mysql-test/suite/innodb/t/innodb-fk.test index fcab4b22eb1..6d5307a1f84 100644 --- a/mysql-test/suite/innodb/t/innodb-fk.test +++ b/mysql-test/suite/innodb/t/innodb-fk.test @@ -244,3 +244,19 @@ CREATE TABLE t1 ( c0123456789012345678 int, FOREIGN KEY (a012345678901234567,c0123456789012345678,b) REFERENCES tx (x1,x2,x3) ) ENGINE=InnoDB; + +--echo # +--echo # MDEV-25642 InnoDB rename table copy DDL fails +--echo # while dropping the table +--echo # +call mtr.add_suppression("InnoDB: In ALTER TABLE `test`.`t1` has or is referenced in foreign key constraints which are not compatible with the new table definition."); + +CREATE TABLE t1 (a VARCHAR(10) NOT NULL PRIMARY KEY) ENGINE=InnoDB; +CREATE TABLE t1_fk (a VARCHAR(40), KEY a (a), FULLTEXT KEY(a), CONSTRAINT fk FOREIGN KEY(a) REFERENCES t1 (a) ON UPDATE CASCADE) ENGINE=InnoDB; +ALTER TABLE t1 RENAME TO tm1, ALGORITHM=COPY; +SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN; +# Enable SET FOREIGN_KEY_CHECKS after fixing MDEV-25885 +SET FOREIGN_KEY_CHECKS=0; +CREATE TABLE t1 (c1 BIGINT NOT NULL, c2 BIGINT NOT NULL, PRIMARY KEY(c1), UNIQUE KEY(c2)) ENGINE=MEMORY; +ALTER TABLE t1 ENGINE=InnoDB, ALGORITHM=COPY; +DROP TABLE t1, tm1, t1_fk; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 8fd9265cf19..f58ce8f997d 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -11009,7 +11009,12 @@ do_continue:; DBUG_PRINT("info", ("is_table_renamed: %d engine_changed: %d", alter_ctx.is_table_renamed(), engine_changed)); - if (!alter_ctx.is_table_renamed()) + /* + InnoDB cannot use the rename optimization when foreign key + constraint is involved because InnoDB fails to drop the + parent table due to foreign key constraint + */ + if (!alter_ctx.is_table_renamed() || alter_ctx.fk_error_if_delete_row) { backup_name.length= my_snprintf(backup_name_buff, sizeof(backup_name_buff), "%s-backup-%lx-%llx", tmp_file_prefix, @@ -11044,7 +11049,7 @@ do_continue:; (void) quick_rm_table(thd, new_db_type, &alter_ctx.new_db, &alter_ctx.tmp_name, FN_IS_TMP); - if (!alter_ctx.is_table_renamed()) + if (!alter_ctx.is_table_renamed() || alter_ctx.fk_error_if_delete_row) { // Restore the backup of the original table to the old name. (void) mysql_rename_table(old_db_type, &alter_ctx.db, &backup_name, From 7e9bc7bf4e79463779a3f8c370c7244ff77ae15d Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 3 May 2021 23:31:33 +0200 Subject: [PATCH 039/251] mdl_dbug_print_locks(): make it useful in gdb too --- sql/mdl.cc | 64 +++++++++++++++++++++++++++--------------------------- sql/mdl.h | 5 ----- 2 files changed, 32 insertions(+), 37 deletions(-) diff --git a/sql/mdl.cc b/sql/mdl.cc index 5e54178db70..4cb1154b8eb 100644 --- a/sql/mdl.cc +++ b/sql/mdl.cc @@ -224,6 +224,35 @@ private: static const uint MAX_SEARCH_DEPTH= 32; }; +#ifndef DBUG_OFF + +/* + Print a list of all locks to DBUG trace to help with debugging +*/ + +static int mdl_dbug_print_lock(MDL_ticket *mdl_ticket, void *arg, bool granted) +{ + String *tmp= (String*) arg; + char buffer[128]; + MDL_key *mdl_key= mdl_ticket->get_key(); + size_t length; + length= my_snprintf(buffer, sizeof(buffer)-1, + "\nname: %s db: %.*s key_name: %.*s (%s)", + mdl_ticket->get_type_name()->str, + (int) mdl_key->db_name_length(), mdl_key->db_name(), + (int) mdl_key->name_length(), mdl_key->name(), + granted ? "granted" : "waiting"); + tmp->append(buffer, length); + return 0; +} + +const char *mdl_dbug_print_locks() +{ + static String tmp; + mdl_iterate(mdl_dbug_print_lock, (void*) &tmp); + return tmp.c_ptr(); +} +#endif /* DBUG_OFF */ /** Enter a node of a wait-for graph. After @@ -2358,7 +2387,9 @@ MDL_context::acquire_lock(MDL_request *mdl_request, double lock_wait_timeout) switch (wait_status) { case MDL_wait::VICTIM: - mdl_dbug_print_locks(); + DBUG_LOCK_FILE; + DBUG_PRINT("mdl_locks", ("%s", mdl_dbug_print_locks())); + DBUG_UNLOCK_FILE; my_error(ER_LOCK_DEADLOCK, MYF(0)); break; case MDL_wait::TIMEOUT: @@ -3241,34 +3272,3 @@ void MDL_ticket::wsrep_report(bool debug) psi_stage->m_name); } #endif /* WITH_WSREP */ - - -#ifndef DBUG_OFF - -/* - Print a list of all locks to DBUG trace to help with debugging -*/ - -static int mdl_dbug_print_lock(MDL_ticket *mdl_ticket, void *arg, bool granted) -{ - String *tmp= (String*) arg; - char buffer[128]; - MDL_key *mdl_key= mdl_ticket->get_key(); - size_t length; - length= my_snprintf(buffer, sizeof(buffer)-1, - "\nname: %s db: %.*s key_name: %.*s (%s)", - mdl_ticket->get_type_name()->str, - (int) mdl_key->db_name_length(), mdl_key->db_name(), - (int) mdl_key->name_length(), mdl_key->name(), - granted ? "granted" : "waiting"); - tmp->append(buffer, length); - return 0; -} - -void mdl_dbug_print_locks() -{ - String tmp; - mdl_iterate(mdl_dbug_print_lock, (void*) &tmp); - DBUG_PRINT("mdl_locks", ("%s", tmp.c_ptr())); -} -#endif /* DBUG_OFF */ diff --git a/sql/mdl.h b/sql/mdl.h index a2cb7c2aa85..55d6ddf845b 100644 --- a/sql/mdl.h +++ b/sql/mdl.h @@ -1106,9 +1106,4 @@ typedef int (*mdl_iterator_callback)(MDL_ticket *ticket, void *arg, bool granted); extern MYSQL_PLUGIN_IMPORT int mdl_iterate(mdl_iterator_callback callback, void *arg); -#ifndef DBUG_OFF -void mdl_dbug_print_locks(); -#else - static inline void mdl_dbug_print_locks() {} -#endif /* DBUG_OFF */ #endif /* MDL_H */ From bafec28e4325e15d1b29b888cfd58ad529c4ce09 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 6 May 2021 19:47:11 +0200 Subject: [PATCH 040/251] rpm packaging: account for fedora > 31 RocksDB failed to package on fedora 32 and 33 with *** ERROR: ambiguous python shebang in /usr/bin/myrocks_hotbackup: #!/usr/bin/env python. Change it to python3 (or python2) explicitly. --- cmake/cpack_rpm.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/cpack_rpm.cmake b/cmake/cpack_rpm.cmake index d78b3c98fe2..6c502126274 100644 --- a/cmake/cpack_rpm.cmake +++ b/cmake/cpack_rpm.cmake @@ -247,7 +247,7 @@ ELSEIF(RPM MATCHES "sles") "mariadb-server = %{version}-%{release}" ) ENDIF() -IF(RPM MATCHES "fedora31" OR RPM MATCHES "(rhel|centos)8") +IF(RPM MATCHES "fedora" OR RPM MATCHES "(rhel|centos)8") SET(PYTHON_SHEBANG "/usr/bin/python3" CACHE STRING "python shebang") ENDIF() From f13b80af39c68a3d6f68c66416978795444759bb Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 9 Jun 2021 13:17:58 +0200 Subject: [PATCH 041/251] MDEV-23933 main.failed_auth_unixsocket fails on arm the idea of main.failed_auth_unixsocket was to have existing user account (root) authenticate with unix_socket, then login with non-existent user name, Non-existent user name forces the server to perform the authentication in the name of some random existing user. But it must still fail at the end, as the user name is wrong. In 10.4 a second predefined user was added, mariadb.sys, so root is not the only user in mysql.global_priv and unix_socket auth must be forced for all existing user accounts, because we cannot know what user account the server will randomly pick for non-existing user auth. --- mysql-test/main/failed_auth_unixsocket.result | 7 +++++-- mysql-test/main/failed_auth_unixsocket.test | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/mysql-test/main/failed_auth_unixsocket.result b/mysql-test/main/failed_auth_unixsocket.result index 32357a5a7a9..7e8b8fe70b9 100644 --- a/mysql-test/main/failed_auth_unixsocket.result +++ b/mysql-test/main/failed_auth_unixsocket.result @@ -1,7 +1,10 @@ -update mysql.global_priv set priv=json_insert(priv, '$.plugin', 'unix_socket') where user='root'; +create table global_priv_backup select * from mysql.global_priv; +update mysql.global_priv set priv=json_insert(priv, '$.plugin', 'unix_socket'); +delete from mysql.global_priv where user != 'root'; flush privileges; connect(localhost,USER,,test,MASTER_PORT,MASTER_SOCKET); ERROR 28000: Access denied for user 'USER'@'localhost' ERROR 28000: Access denied for user 'USER'@'localhost' -update mysql.global_priv set priv=json_compact(json_remove(priv, '$.plugin')) where user='root'; +replace mysql.global_priv select * from global_priv_backup; flush privileges; +drop table global_priv_backup; diff --git a/mysql-test/main/failed_auth_unixsocket.test b/mysql-test/main/failed_auth_unixsocket.test index e163a0c230f..fe80d947036 100644 --- a/mysql-test/main/failed_auth_unixsocket.test +++ b/mysql-test/main/failed_auth_unixsocket.test @@ -4,7 +4,9 @@ # MDEV-3909 remote user enumeration # unix_socket tests # -update mysql.global_priv set priv=json_insert(priv, '$.plugin', 'unix_socket') where user='root'; +create table global_priv_backup select * from mysql.global_priv; +update mysql.global_priv set priv=json_insert(priv, '$.plugin', 'unix_socket'); +delete from mysql.global_priv where user != 'root'; flush privileges; # Make sure that the replace works, even if $USER is 'user' or something else @@ -22,5 +24,6 @@ connect (fail,localhost,$USER); --error ER_ACCESS_DENIED_NO_PASSWORD_ERROR change_user $USER; -update mysql.global_priv set priv=json_compact(json_remove(priv, '$.plugin')) where user='root'; +replace mysql.global_priv select * from global_priv_backup; flush privileges; +drop table global_priv_backup; From 6fbf978eec4506eb46737ac4da00ea04403ae855 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 9 Jun 2021 22:06:11 +0300 Subject: [PATCH 042/251] MDEV-25750: Assertion wait_lock->is_waiting() in lock_wait_rpl_report lock_wait_rpl_report(): Tolerate the loss of a lock wait. commit c68007d958aaab0953a01c96eb02326f19d3c9d7 (MDEV-24738) had introduced this rare failure. --- storage/innobase/lock/lock0lock.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc index 199df390582..95cb27aba10 100644 --- a/storage/innobase/lock/lock0lock.cc +++ b/storage/innobase/lock/lock0lock.cc @@ -1650,8 +1650,10 @@ func_exit: lock_sys.wr_unlock(); return; } + ut_ad(wait_lock->is_waiting()); } - ut_ad(wait_lock->is_waiting()); + else if (!wait_lock->is_waiting()) + goto func_exit; ut_ad(!(wait_lock->type_mode & LOCK_AUTO_INC)); if (wait_lock->is_table()) From 7a1eff0a9d90a45e774ca126ab10f86a78b930f4 Mon Sep 17 00:00:00 2001 From: Elena Stepanova Date: Wed, 9 Jun 2021 15:28:35 +0300 Subject: [PATCH 043/251] MDEV-25884 Tests use environment $USER variable without quotes --- mysql-test/suite/mariabackup/auth_plugin_win.result | 2 +- mysql-test/suite/mariabackup/auth_plugin_win.test | 2 +- mysql-test/suite/plugins/r/unix_socket.result | 4 ++-- mysql-test/suite/plugins/t/unix_socket.test | 12 ++++++------ 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/mysql-test/suite/mariabackup/auth_plugin_win.result b/mysql-test/suite/mariabackup/auth_plugin_win.result index 7a623be147f..caf5d8df87d 100644 --- a/mysql-test/suite/mariabackup/auth_plugin_win.result +++ b/mysql-test/suite/mariabackup/auth_plugin_win.result @@ -1,5 +1,5 @@ INSTALL SONAME 'auth_named_pipe'; CREATE USER 'USERNAME' IDENTIFIED WITH named_pipe; -GRANT ALL PRIVILEGES ON *.* to USERNAME; +GRANT ALL PRIVILEGES ON *.* to 'USERNAME'; DROP USER 'USERNAME'; UNINSTALL SONAME 'auth_named_pipe'; diff --git a/mysql-test/suite/mariabackup/auth_plugin_win.test b/mysql-test/suite/mariabackup/auth_plugin_win.test index 9c8cd5ad411..70ae74b7028 100644 --- a/mysql-test/suite/mariabackup/auth_plugin_win.test +++ b/mysql-test/suite/mariabackup/auth_plugin_win.test @@ -18,7 +18,7 @@ INSTALL SONAME 'auth_named_pipe'; --replace_result $USERNAME USERNAME eval CREATE USER '$USERNAME' IDENTIFIED WITH named_pipe; --replace_result $USERNAME USERNAME -eval GRANT ALL PRIVILEGES ON *.* to $USERNAME; +eval GRANT ALL PRIVILEGES ON *.* to '$USERNAME'; let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; --disable_result_log diff --git a/mysql-test/suite/plugins/r/unix_socket.result b/mysql-test/suite/plugins/r/unix_socket.result index 0e08794fbe6..096b736cd68 100644 --- a/mysql-test/suite/plugins/r/unix_socket.result +++ b/mysql-test/suite/plugins/r/unix_socket.result @@ -2,7 +2,7 @@ install plugin unix_socket soname 'auth_socket.so'; # # with named user # -create user USER identified via unix_socket; +create user 'USER' identified via unix_socket; # # name match = ok # @@ -12,7 +12,7 @@ USER@localhost USER@% test # # name does not match = failure # -drop user USER; +drop user 'USER'; # # and now with anonymous user # diff --git a/mysql-test/suite/plugins/t/unix_socket.test b/mysql-test/suite/plugins/t/unix_socket.test index bd0323c0274..75409ec70b4 100644 --- a/mysql-test/suite/plugins/t/unix_socket.test +++ b/mysql-test/suite/plugins/t/unix_socket.test @@ -12,9 +12,9 @@ eval install plugin unix_socket soname '$AUTH_SOCKET_SO'; --echo # with named user --echo # ---let $replace=create user $USER ---replace_result $replace "create user USER" -eval create user $USER identified via unix_socket; +--let $replace=create user '$USER' +--replace_result $replace "create user 'USER'" +eval create user '$USER' identified via unix_socket; --write_file $MYSQLTEST_VARDIR/tmp/peercred_test.txt --let $replace1=$USER@localhost @@ -34,9 +34,9 @@ EOF --error 1 --exec $MYSQL_TEST -u foobar --plugin-dir=$plugindir < $MYSQLTEST_VARDIR/tmp/peercred_test.txt ---let $replace=drop user $USER ---replace_result $replace "drop user USER" -eval drop user $USER; +--let $replace=drop user '$USER' +--replace_result $replace "drop user 'USER'" +eval drop user '$USER'; --echo # --echo # and now with anonymous user From 0b9a59bbc45203c68df2efd0382f63e694439bb0 Mon Sep 17 00:00:00 2001 From: Elena Stepanova Date: Wed, 9 Jun 2021 15:50:01 +0300 Subject: [PATCH 044/251] MDEV-25884 Tests use environment $USER variable without quotes These are only 10.4+ tests. 10.2+ tests are pushed into 10.2 and will be merged into 10.4+ independently --- .../password_expiration_unix_socket.result | 6 ++-- .../main/password_expiration_unix_socket.test | 18 ++++++------ mysql-test/suite/plugins/r/multiauth.result | 24 ++++++++-------- mysql-test/suite/plugins/t/multiauth.test | 28 +++++++++---------- 4 files changed, 38 insertions(+), 38 deletions(-) diff --git a/mysql-test/main/password_expiration_unix_socket.result b/mysql-test/main/password_expiration_unix_socket.result index 5feee17f205..b37b8868edf 100644 --- a/mysql-test/main/password_expiration_unix_socket.result +++ b/mysql-test/main/password_expiration_unix_socket.result @@ -1,8 +1,8 @@ # # A password cannot expire, if there is no password # -create user USER identified via unix_socket; -alter user USER password expire; +create user 'USER' identified via unix_socket; +alter user 'USER' password expire; 1 1 -drop user USER; +drop user 'USER'; diff --git a/mysql-test/main/password_expiration_unix_socket.test b/mysql-test/main/password_expiration_unix_socket.test index f2579aaf18f..d936d65bc21 100644 --- a/mysql-test/main/password_expiration_unix_socket.test +++ b/mysql-test/main/password_expiration_unix_socket.test @@ -9,16 +9,16 @@ --echo # A password cannot expire, if there is no password --echo # ---let $replace=create user $USER ---replace_result $replace "create user USER" ---eval create user $USER identified via unix_socket +--let $replace=create user '$USER' +--replace_result $replace "create user 'USER'" +--eval create user '$USER' identified via unix_socket ---let $replace=alter user $USER ---replace_result $replace "alter user USER" ---eval alter user $USER password expire +--let $replace=alter user '$USER' +--replace_result $replace "alter user 'USER'" +--eval alter user '$USER' password expire --exec $MYSQL -u $USER -e 'select 1' ---let $replace=drop user $USER ---replace_result $replace "drop user USER" ---eval drop user $USER +--let $replace=drop user '$USER' +--replace_result $replace "drop user 'USER'" +--eval drop user '$USER' diff --git a/mysql-test/suite/plugins/r/multiauth.result b/mysql-test/suite/plugins/r/multiauth.result index 7b6465c3040..8e19433322d 100644 --- a/mysql-test/suite/plugins/r/multiauth.result +++ b/mysql-test/suite/plugins/r/multiauth.result @@ -1,5 +1,5 @@ install soname 'auth_ed25519'; -create user USER identified via unix_socket OR mysql_native_password as password("GOOD"); +create user 'USER' identified via unix_socket OR mysql_native_password as password("GOOD"); create user mysqltest1 identified via unix_socket OR mysql_native_password as password("good"); show create user mysqltest1; CREATE USER for mysqltest1@% @@ -14,8 +14,8 @@ user() current_user() database() mysqltest1@localhost mysqltest1@% test # name does not match, password bad = failure mysqltest: Could not open connection 'default': 1045 Access denied for user 'mysqltest1'@'localhost' (using password: YES) -drop user USER, mysqltest1; -create user USER identified via mysql_native_password as password("GOOD") OR unix_socket; +drop user 'USER', mysqltest1; +create user 'USER' identified via mysql_native_password as password("GOOD") OR unix_socket; create user mysqltest1 identified via mysql_native_password as password("good") OR unix_socket; show create user mysqltest1; CREATE USER for mysqltest1@% @@ -30,8 +30,8 @@ user() current_user() database() mysqltest1@localhost mysqltest1@% test # name does not match, password bad = failure mysqltest: Could not open connection 'default': 1698 Access denied for user 'mysqltest1'@'localhost' -drop user USER, mysqltest1; -create user USER identified via unix_socket OR ed25519 as password("GOOD"); +drop user 'USER', mysqltest1; +create user 'USER' identified via unix_socket OR ed25519 as password("GOOD"); create user mysqltest1 identified via unix_socket OR ed25519 as password("good"); show create user mysqltest1; CREATE USER for mysqltest1@% @@ -46,8 +46,8 @@ user() current_user() database() mysqltest1@localhost mysqltest1@% test # name does not match, password bad = failure mysqltest: Could not open connection 'default': 1045 Access denied for user 'mysqltest1'@'localhost' (using password: YES) -drop user USER, mysqltest1; -create user USER identified via ed25519 as password("GOOD") OR unix_socket; +drop user 'USER', mysqltest1; +create user 'USER' identified via ed25519 as password("GOOD") OR unix_socket; create user mysqltest1 identified via ed25519 as password("good") OR unix_socket; show create user mysqltest1; CREATE USER for mysqltest1@% @@ -62,8 +62,8 @@ user() current_user() database() mysqltest1@localhost mysqltest1@% test # name does not match, password bad = failure mysqltest: Could not open connection 'default': 1698 Access denied for user 'mysqltest1'@'localhost' -drop user USER, mysqltest1; -create user USER identified via ed25519 as password("GOOD") OR unix_socket OR mysql_native_password as password("works"); +drop user 'USER', mysqltest1; +create user 'USER' identified via ed25519 as password("GOOD") OR unix_socket OR mysql_native_password as password("works"); create user mysqltest1 identified via ed25519 as password("good") OR unix_socket OR mysql_native_password as password("works"); show create user mysqltest1; CREATE USER for mysqltest1@% @@ -82,7 +82,7 @@ user() current_user() database() mysqltest1@localhost mysqltest1@% test # name does not match, password bad = failure mysqltest: Could not open connection 'default': 1045 Access denied for user 'mysqltest1'@'localhost' (using password: YES) -drop user USER, mysqltest1; +drop user 'USER', mysqltest1; create user mysqltest1 identified via mysql_native_password as password("good") OR mysql_native_password as password("works"); show create user mysqltest1; CREATE USER for mysqltest1@% @@ -156,7 +156,7 @@ drop user mysqltest1; create user mysqltest1 identified via ed25519 as password("good") OR unix_socket OR mysql_native_password as password("works"); ERROR HY000: Column count of mysql.user is wrong. Expected 3, found 47. Created with MariaDB XX.YY.ZZ, now running XX.YY.ZZ. Please use mysql_upgrade to fix this error # switching back from mysql.user to mysql.global_priv -create user USER identified via mysql_native_password as '1234567890123456789012345678901234567890a' OR unix_socket; +create user 'USER' identified via mysql_native_password as '1234567890123456789012345678901234567890a' OR unix_socket; create user mysqltest1 identified via mysql_native_password as '1234567890123456789012345678901234567890a' OR unix_socket; update mysql.global_priv set priv=replace(priv, '1234567890123456789012345678901234567890a', 'invalid password'); flush privileges; @@ -174,7 +174,7 @@ set password for mysqltest1 = password('bla'); select user(), current_user(), database(); user() current_user() database() mysqltest1@localhost mysqltest1@% test -drop user USER, mysqltest1; +drop user 'USER', mysqltest1; create user mysqltest1 identified via ed25519 as password("good"); show create user mysqltest1; CREATE USER for mysqltest1@% diff --git a/mysql-test/suite/plugins/t/multiauth.test b/mysql-test/suite/plugins/t/multiauth.test index 4cf44fc7c65..253e8823d37 100644 --- a/mysql-test/suite/plugins/t/multiauth.test +++ b/mysql-test/suite/plugins/t/multiauth.test @@ -22,13 +22,13 @@ install soname 'auth_ed25519'; select user(), current_user(), database(); EOF ---let $creplace=create user $USER ---let $dreplace=drop user $USER +--let $creplace=create user '$USER' +--let $dreplace=drop user '$USER' # # socket,password # ---replace_result $creplace "create user USER" +--replace_result $creplace "create user 'USER'" eval $creplace identified via unix_socket OR mysql_native_password as password("GOOD"); create user mysqltest1 identified via unix_socket OR mysql_native_password as password("good"); show create user mysqltest1; @@ -39,13 +39,13 @@ show create user mysqltest1; --echo # name does not match, password bad = failure --error 1 --exec $try_auth -u mysqltest1 -pbad ---replace_result $dreplace "drop user USER" +--replace_result $dreplace "drop user 'USER'" eval $dreplace, mysqltest1; # # password,socket # ---replace_result $creplace "create user USER" +--replace_result $creplace "create user 'USER'" eval $creplace identified via mysql_native_password as password("GOOD") OR unix_socket; create user mysqltest1 identified via mysql_native_password as password("good") OR unix_socket; show create user mysqltest1; @@ -56,13 +56,13 @@ show create user mysqltest1; --echo # name does not match, password bad = failure --error 1 --exec $try_auth -u mysqltest1 -pbad ---replace_result $dreplace "drop user USER" +--replace_result $dreplace "drop user 'USER'" eval $dreplace, mysqltest1; # # socket,ed25519 # ---replace_result $creplace "create user USER" +--replace_result $creplace "create user 'USER'" eval $creplace identified via unix_socket OR ed25519 as password("GOOD"); create user mysqltest1 identified via unix_socket OR ed25519 as password("good"); show create user mysqltest1; @@ -73,13 +73,13 @@ show create user mysqltest1; --echo # name does not match, password bad = failure --error 1 --exec $try_auth -u mysqltest1 -pbad ---replace_result $dreplace "drop user USER" +--replace_result $dreplace "drop user 'USER'" eval $dreplace, mysqltest1; # # ed25519,socket # ---replace_result $creplace "create user USER" +--replace_result $creplace "create user 'USER'" eval $creplace identified via ed25519 as password("GOOD") OR unix_socket; create user mysqltest1 identified via ed25519 as password("good") OR unix_socket; show create user mysqltest1; @@ -90,13 +90,13 @@ show create user mysqltest1; --echo # name does not match, password bad = failure --error 1 --exec $try_auth -u mysqltest1 -pbad ---replace_result $dreplace "drop user USER" +--replace_result $dreplace "drop user 'USER'" eval $dreplace, mysqltest1; # # ed25519,socket,password # ---replace_result $creplace "create user USER" +--replace_result $creplace "create user 'USER'" eval $creplace identified via ed25519 as password("GOOD") OR unix_socket OR mysql_native_password as password("works"); create user mysqltest1 identified via ed25519 as password("good") OR unix_socket OR mysql_native_password as password("works"); show create user mysqltest1; @@ -109,7 +109,7 @@ show create user mysqltest1; --echo # name does not match, password bad = failure --error 1 --exec $try_auth -u mysqltest1 -pbad ---replace_result $dreplace "drop user USER" +--replace_result $dreplace "drop user 'USER'" eval $dreplace, mysqltest1; # @@ -158,7 +158,7 @@ create user mysqltest1 identified via ed25519 as password("good") OR unix_socket # # invalid password,socket # ---replace_result $creplace "create user USER" +--replace_result $creplace "create user 'USER'" eval $creplace identified via mysql_native_password as '1234567890123456789012345678901234567890a' OR unix_socket; create user mysqltest1 identified via mysql_native_password as '1234567890123456789012345678901234567890a' OR unix_socket; update mysql.global_priv set priv=replace(priv, '1234567890123456789012345678901234567890a', 'invalid password'); @@ -172,7 +172,7 @@ show create user mysqltest1; --echo # SET PASSWORD helps set password for mysqltest1 = password('bla'); --exec $try_auth -u mysqltest1 -pbla ---replace_result $dreplace "drop user USER" +--replace_result $dreplace "drop user 'USER'" eval $dreplace, mysqltest1; # From 396864c6b3d2cca9962f7eb58964f50ed6b612dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 10 Jun 2021 11:17:40 +0300 Subject: [PATCH 045/251] Remove orphan type name trx_sig_t This was missed in commit 1d0f70c2f894b27e98773a282871d32802f67964. --- storage/innobase/include/trx0types.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/storage/innobase/include/trx0types.h b/storage/innobase/include/trx0types.h index 097aea519a9..26589bb2a96 100644 --- a/storage/innobase/include/trx0types.h +++ b/storage/innobase/include/trx0types.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2014, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2019, MariaDB Corporation. +Copyright (c) 2017, 2021, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -96,8 +96,6 @@ struct trx_t; struct trx_lock_t; /** Transaction system */ struct trx_sys_t; -/** Signal */ -struct trx_sig_t; /** Rollback segment */ struct trx_rseg_t; /** Transaction undo log */ From e85df7feac529fd995e9aca61b202d82e06c5c0e Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Sat, 15 Jun 2019 16:04:49 +0200 Subject: [PATCH 046/251] MDEV-19702 Refactor Bitmap to be based on ulonglong, not on uint32 Removed Field_map, since it was used only in a single function. Fixed is_indexed_agg_distinct(), since it relied on initialization of Bitmap in constructor. Fixes MDEV-25888 in 10.4 --- sql/sql_bitmap.h | 389 ++++++++++++++++++++-------------------------- sql/sql_select.cc | 14 +- sql/table.h | 3 - 3 files changed, 175 insertions(+), 231 deletions(-) diff --git a/sql/sql_bitmap.h b/sql/sql_bitmap.h index cce80ce2bc8..765e4ee2725 100644 --- a/sql/sql_bitmap.h +++ b/sql/sql_bitmap.h @@ -27,10 +27,36 @@ #include #include +/* An iterator to quickly walk over bits in unlonglong bitmap. */ +class Table_map_iterator +{ + ulonglong bmp; + uint no; +public: + Table_map_iterator(ulonglong t) : bmp(t), no(0) {} + int next_bit() + { + static const char last_bit[16] = { 32, 0, 1, 0, + 2, 0, 1, 0, + 3, 0, 1, 0, + 2, 0, 1, 0 }; + uint bit; + while ((bit= last_bit[bmp & 0xF]) == 32) + { + no += 4; + bmp= bmp >> 4; + if (!bmp) + return BITMAP_END; + } + bmp &= ~(1LL << bit); + return no + bit; + } + int operator++(int) { return next_bit(); } + enum { BITMAP_END= 64 }; +}; template class Bitmap { - /* Workaround GCC optimizer bug (generating SSE instuctions on unaligned data) */ @@ -43,12 +69,38 @@ template class Bitmap #pragma GCC target ("no-sse") #endif - uint32 buffer[(width + 31) / 32]; -public: - Bitmap() +private: + static const int BITS_PER_ELEMENT= sizeof(ulonglong) * 8; + static const int ARRAY_ELEMENTS= (width + BITS_PER_ELEMENT - 1) / BITS_PER_ELEMENT; + static const ulonglong ALL_BITS_SET= ULLONG_MAX; + + ulonglong buffer[ARRAY_ELEMENTS]; + + uint bit_index(uint n) const { - clear_all(); + DBUG_ASSERT(n < width); + return ARRAY_ELEMENTS == 1 ? 0 : n / BITS_PER_ELEMENT; } + ulonglong bit_mask(uint n) const + { + DBUG_ASSERT(n < width); + return ARRAY_ELEMENTS == 1 ? 1ULL << n : 1ULL << (n % BITS_PER_ELEMENT); + } + ulonglong last_element_mask(int n) const + { + DBUG_ASSERT(n % BITS_PER_ELEMENT != 0); + return bit_mask(n) - 1; + } + +public: + /* + The default constructor does nothing. + The caller is supposed to either zero the memory + or to call set_all()/clear_all()/set_prefix() + to initialize bitmap. + */ + Bitmap() { } + explicit Bitmap(uint prefix) { set_prefix(prefix); @@ -57,50 +109,76 @@ public: { set_prefix(prefix); } - uint length() const { return width; } void set_bit(uint n) { - DBUG_ASSERT(n < width); - ((uchar*)buffer)[n / 8] |= (1 << (n & 7)); + buffer[bit_index(n)] |= bit_mask(n); } void clear_bit(uint n) { - DBUG_ASSERT(n < width); - ((uchar*)buffer)[n / 8] &= ~(1 << (n & 7)); + buffer[bit_index(n)] &= ~bit_mask(n); + } + bool is_set(uint n) const + { + return buffer[bit_index(n)] & bit_mask(n); } void set_prefix(uint prefix_size) { set_if_smaller(prefix_size, width); - uint prefix_bytes, prefix_bits, d; - uchar* m = (uchar*)buffer; - if ((prefix_bytes = prefix_size / 8)) - memset(m, 0xff, prefix_bytes); - m += prefix_bytes; - if ((prefix_bits = prefix_size & 7)) - { - *(m++) = (1 << prefix_bits) - 1; - // As the prefix bits are set, lets count this byte too as a prefix byte. - prefix_bytes++; - } - if ((d = (width + 7) / 8 - prefix_bytes)) - memset(m, 0, d); + size_t idx= prefix_size / BITS_PER_ELEMENT; + + for (size_t i= 0; i < idx; i++) + buffer[i]= ALL_BITS_SET; + + if (prefix_size % BITS_PER_ELEMENT) + buffer[idx++]= last_element_mask(prefix_size); + + for (size_t i= idx; i < ARRAY_ELEMENTS; i++) + buffer[i]= 0; + } + bool is_prefix(uint prefix_size) const + { + DBUG_ASSERT(prefix_size <= width); + + size_t idx= prefix_size / BITS_PER_ELEMENT; + + for (size_t i= 0; i < idx; i++) + if (buffer[i] != ALL_BITS_SET) + return false; + + if (prefix_size % BITS_PER_ELEMENT) + if (buffer[idx++] != last_element_mask(prefix_size)) + return false; + + for (size_t i= idx; i < ARRAY_ELEMENTS; i++) + if (buffer[i] != 0) + return false; + + return true; } void set_all() { - set_prefix(width); + if (width % BITS_PER_ELEMENT) + set_prefix(width); + else if (ARRAY_ELEMENTS > 1) + memset(buffer, 0xff, sizeof(buffer)); + else + buffer[0] = ALL_BITS_SET; } void clear_all() { - memset(buffer, 0x00, sizeof(buffer)); + if (ARRAY_ELEMENTS > 1) + memset(buffer, 0, sizeof(buffer)); + else + buffer[0]= 0; } - void intersect(Bitmap & map2) + void intersect(const Bitmap& map2) { - for (uint i = 0; i < array_elements(buffer); i++) + for (size_t i= 0; i < ARRAY_ELEMENTS; i++) buffer[i] &= map2.buffer[i]; } @@ -112,27 +190,13 @@ private: */ void intersect_and_pad(ulonglong map2buff, bool pad_with_ones) { - compile_time_assert(sizeof(ulonglong) == 8); - uint32 tmp[2]; - int8store(tmp, map2buff); + buffer[0] &= map2buff; - buffer[0] &= tmp[0]; - if (array_elements(buffer) > 1) - buffer[1] &= tmp[1]; - - if (array_elements(buffer) <= 2) - return; - if (pad_with_ones) - { - memset((char*)buffer + 8, 0xff , sizeof(buffer) - 8); - if (width != sizeof(buffer) * 8) - { - ((uchar*)buffer)[sizeof(buffer)-1] = last_byte_mask(width); - } - } - else - memset((char*)buffer + 8, 0 , sizeof(buffer) - 8); + for (size_t i= 1; i < ARRAY_ELEMENTS; i++) + buffer[i]= pad_with_ones ? ALL_BITS_SET : 0; + if (ARRAY_ELEMENTS > 1 && (width % BITS_PER_ELEMENT) && pad_with_ones) + buffer[ARRAY_ELEMENTS - 1]= last_element_mask(width); } public: @@ -140,141 +204,110 @@ public: { intersect_and_pad(map2buff, 0); } - /* Use highest bit for all bits above sizeof(ulonglong)*8. */ + /* Use highest bit for all bits above first element. */ void intersect_extended(ulonglong map2buff) { intersect_and_pad(map2buff, (map2buff & (1ULL << 63))); } - void subtract(Bitmap & map2) + void subtract(const Bitmap& map2) { - for (size_t i = 0; i < array_elements(buffer); i++) + for (size_t i= 0; i < ARRAY_ELEMENTS; i++) buffer[i] &= ~(map2.buffer[i]); } - void merge(Bitmap & map2) + void merge(const Bitmap& map2) { - for (size_t i = 0; i < array_elements(buffer); i++) + for (size_t i= 0; i < ARRAY_ELEMENTS; i++) buffer[i] |= map2.buffer[i]; } - bool is_set(uint n) const - { - DBUG_ASSERT(n < width); - return ((uchar*)buffer)[n / 8] & (1 << (n & 7)); - } - bool is_prefix(uint prefix_size) const - { - uint prefix_mask = last_byte_mask(prefix_size); - uchar* m = (uchar*)buffer; - uchar* end_prefix = m + (prefix_size - 1) / 8; - uchar* end; - DBUG_ASSERT(prefix_size <= width); - - /* Empty prefix is always true */ - if (!prefix_size) - return true; - - while (m < end_prefix) - if (*m++ != 0xff) - return false; - - end = ((uchar*)buffer) + (width + 7) / 8 - 1; - if (m == end) - return ((*m & last_byte_mask(width)) == prefix_mask); - - if (*m != prefix_mask) - return false; - - while (++m < end) - if (*m != 0) - return false; - return ((*m & last_byte_mask(width)) == 0); - } bool is_clear_all() const { - for (size_t i= 0; i < array_elements(buffer); i++) + for (size_t i= 0; i < ARRAY_ELEMENTS; i++) if (buffer[i]) return false; return true; } - bool is_set_all() const + bool is_subset(const Bitmap& map2) const { - if (width == sizeof(buffer) * 8) - { - for (size_t i = 0; i < array_elements(buffer); i++) - if (buffer[i] != 0xFFFFFFFFU) - return false; - return true; - } - else - return is_prefix(width); - } - - bool is_subset(const Bitmap & map2) const - { - for (size_t i= 0; i < array_elements(buffer); i++) + for (size_t i= 0; i < ARRAY_ELEMENTS; i++) if (buffer[i] & ~(map2.buffer[i])) return false; return true; } - bool is_overlapping(const Bitmap & map2) const + bool is_overlapping(const Bitmap& map2) const { - for (size_t i = 0; i < array_elements(buffer); i++) + for (size_t i= 0; i < ARRAY_ELEMENTS; i++) if (buffer[i] & map2.buffer[i]) return true; return false; } - bool operator==(const Bitmap & map2) const + bool operator==(const Bitmap& map2) const { - return memcmp(buffer, map2.buffer, sizeof(buffer)) == 0; + if (ARRAY_ELEMENTS > 1) + return !memcmp(buffer,map2.buffer,sizeof(buffer)); + return buffer[0] == map2.buffer[0]; } - bool operator!=(const Bitmap & map2) const + bool operator!=(const Bitmap& map2) const { return !(*this == map2); } + /* + Print hexadecimal representation of bitmap. + Truncate trailing zeros. + */ char *print(char *buf) const { - char *s=buf; - const uchar *e=(uchar *)buffer, *b=e+sizeof(buffer)-1; - while (!*b && b>e) - b--; - if ((*s=_dig_vec_upper[*b >> 4]) != '0') - s++; - *s++=_dig_vec_upper[*b & 15]; - while (--b>=e) + size_t last; /*index of the last non-zero element, or 0. */ + + for (last= ARRAY_ELEMENTS - 1; last && !buffer[last]; last--){} + + const int HEX_DIGITS_PER_ELEMENT= BITS_PER_ELEMENT / 4; + for (size_t i= 0; i < last; i++) { - *s++=_dig_vec_upper[*b >> 4]; - *s++=_dig_vec_upper[*b & 15]; + ulonglong num = buffer[i]; + uint shift = BITS_PER_ELEMENT - 4; + size_t pos= i * HEX_DIGITS_PER_ELEMENT; + for (size_t j= 0; j < HEX_DIGITS_PER_ELEMENT; j++) + { + buf[pos + j]= _dig_vec_upper[(num >> shift) & 0xf]; + shift += 4; + } } - *s=0; + longlong2str(buffer[last], buf, 16); return buf; } ulonglong to_ulonglong() const { - DBUG_ASSERT(sizeof(buffer) >= 4); - uchar *b=(uchar *)buffer; - if (sizeof(buffer) >= 8) - return uint8korr(b); - return (ulonglong) uint4korr(b); + return buffer[0]; } uint bits_set() { - uint res = 0; - for (size_t i = 0; i < array_elements(buffer); i++) - res += my_count_bits_uint32(buffer[i]); + uint res= 0; + for (size_t i= 0; i < ARRAY_ELEMENTS; i++) + res += my_count_bits(buffer[i]); return res; } class Iterator { - Bitmap ↦ - uint no; + const Bitmap& map; + uint offset; + Table_map_iterator tmi; public: - Iterator(Bitmap &map2): map(map2), no(0) {} - int operator++(int) { - if (no == width) return BITMAP_END; - while (!map.is_set(no)) + Iterator(const Bitmap& map2) : map(map2), offset(0), tmi(map2.buffer[0]) {} + int operator++(int) + { + for (;;) { - if ((++no) == width) return BITMAP_END; + int nextbit= tmi++; + + if (nextbit != Table_map_iterator::BITMAP_END) + return offset + nextbit; + + if (offset + BITS_PER_ELEMENT >= map.length()) + return BITMAP_END; + + offset += BITS_PER_ELEMENT; + tmi= Table_map_iterator(map.buffer[offset / BITS_PER_ELEMENT]); } - return no++; } enum { BITMAP_END = width }; }; @@ -283,98 +316,8 @@ public: #pragma GCC pop_options #undef NEED_GCC_NO_SSE_WORKAROUND #endif - }; - -/* An iterator to quickly walk over bits in ulonglong bitmap. */ -class Table_map_iterator -{ - ulonglong bmp; - uint no; -public: - Table_map_iterator(ulonglong t) : bmp(t), no(0) {} - uint next_bit() - { - static const uchar last_bit[16]= {32, 0, 1, 0, - 2, 0, 1, 0, - 3, 0, 1, 0, - 2, 0, 1, 0}; - uint bit; - while ((bit= last_bit[bmp & 0xF]) == 32) - { - no += 4; - bmp= bmp >> 4; - if (!bmp) - return BITMAP_END; - } - bmp &= ~(1ULL << bit); - return no + bit; - } - uint operator++(int) { return next_bit(); } - enum { BITMAP_END= 64 }; -}; - -template <> class Bitmap<64> -{ - ulonglong map; -public: - Bitmap<64>() { } - explicit Bitmap<64>(uint prefix_to_set) { set_prefix(prefix_to_set); } - void init(uint prefix_to_set) { set_prefix(prefix_to_set); } - uint length() const { return 64; } - void set_bit(uint n) { map|= ((ulonglong)1) << n; } - void clear_bit(uint n) { map&= ~(((ulonglong)1) << n); } - void set_prefix(uint n) - { - if (n >= length()) - set_all(); - else - map= (((ulonglong)1) << n)-1; - } - void set_all() { map=~(ulonglong)0; } - void clear_all() { map=(ulonglong)0; } - void intersect(Bitmap<64>& map2) { map&= map2.map; } - void intersect(ulonglong map2) { map&= map2; } - void intersect_extended(ulonglong map2) { map&= map2; } - void subtract(Bitmap<64>& map2) { map&= ~map2.map; } - void merge(Bitmap<64>& map2) { map|= map2.map; } - bool is_set(uint n) const { return MY_TEST(map & (((ulonglong) 1) << n)); } - bool is_prefix(uint n) const { return map == (((ulonglong)1) << n)-1; } - bool is_clear_all() const { return map == (ulonglong)0; } - bool is_set_all() const { return map == ~(ulonglong)0; } - bool is_subset(const Bitmap<64>& map2) const { return !(map & ~map2.map); } - bool is_overlapping(const Bitmap<64>& map2) const { return (map & map2.map)!= 0; } - bool operator==(const Bitmap<64>& map2) const { return map == map2.map; } - char *print(char *buf) const { - longlong2str(longlong(map), buf, 16); - return buf; - } - ulonglong to_ulonglong() const { return map; } - class Iterator : public Table_map_iterator - { - public: - Iterator(Bitmap<64> &map2) : Table_map_iterator(map2.map) {} - }; - uint bits_set() - { - //TODO: use my_count_bits() - uint res= 0, i= 0; - for (; i < 64 ; i++) - { - if (map & ((ulonglong)1< key_map; /* Used for finding keys */ -#elif MAX_INDEXES > 128 -#error "MAX_INDEXES values greater than 128 is not supported." -#else -typedef Bitmap<((MAX_INDEXES+7)/8*8)> key_map; /* Used for finding keys */ -#endif +typedef Bitmap key_map; /* Used for finding keys */ #endif /* SQL_BITMAP_INCLUDED */ diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 1b676a72557..19e4be6f50d 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -7046,7 +7046,6 @@ void optimize_keyuse(JOIN *join, DYNAMIC_ARRAY *keyuse_array) } } - /** Check for the presence of AGGFN(DISTINCT a) queries that may be subject to loose index scan. @@ -7084,7 +7083,6 @@ is_indexed_agg_distinct(JOIN *join, List *out_args) { Item_sum **sum_item_ptr; bool result= false; - Field_map first_aggdistinct_fields; if (join->table_count != 1 || /* reference more than 1 table */ join->select_distinct || /* or a DISTINCT */ @@ -7094,10 +7092,11 @@ is_indexed_agg_distinct(JOIN *join, List *out_args) if (join->make_sum_func_list(join->all_fields, join->fields_list, true)) return false; + Bitmap first_aggdistinct_fields; + bool first_aggdistinct_fields_initialized= false; for (sum_item_ptr= join->sum_funcs; *sum_item_ptr; sum_item_ptr++) { Item_sum *sum_item= *sum_item_ptr; - Field_map cur_aggdistinct_fields; Item *expr; /* aggregate is not AGGFN(DISTINCT) or more than 1 argument to it */ switch (sum_item->sum_func()) @@ -7120,6 +7119,8 @@ is_indexed_agg_distinct(JOIN *join, List *out_args) We don't worry about duplicates as these will be sorted out later in get_best_group_min_max */ + Bitmap cur_aggdistinct_fields; + cur_aggdistinct_fields.clear_all(); for (uint i= 0; i < sum_item->get_arg_count(); i++) { expr= sum_item->get_arg(i); @@ -7138,8 +7139,11 @@ is_indexed_agg_distinct(JOIN *join, List *out_args) If there are multiple aggregate functions, make sure that they all refer to exactly the same set of columns. */ - if (first_aggdistinct_fields.is_clear_all()) - first_aggdistinct_fields.merge(cur_aggdistinct_fields); + if (!first_aggdistinct_fields_initialized) + { + first_aggdistinct_fields= cur_aggdistinct_fields; + first_aggdistinct_fields_initialized=true; + } else if (first_aggdistinct_fields != cur_aggdistinct_fields) return false; } diff --git a/sql/table.h b/sql/table.h index f510aaa6968..273c2159c5e 100644 --- a/sql/table.h +++ b/sql/table.h @@ -1193,9 +1193,6 @@ struct st_cond_statistic; #define CHECK_ROW_FOR_NULLS_TO_REJECT (1 << 0) #define REJECT_ROW_DUE_TO_NULL_FIELDS (1 << 1) -/* Bitmap of table's fields */ -typedef Bitmap Field_map; - class SplM_opt_info; struct vers_select_conds_t; From 152c83d49ca821c54aa49f6b43e33cba63e4d19f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Otto=20Kek=C3=A4l=C3=A4inen?= Date: Sun, 30 May 2021 15:42:04 -0700 Subject: [PATCH 047/251] MDEV-20392: Skip ABI check if 'diff' is not found Not all environments have 'diff' installed. Most notably CentOS 8 does not have diff out-of-the-box. Thus users running 'cmake .' and 'make' would fail to build MariaDB, and they would think the error was in ABI incompatibilities due to the error message emitted by CMake when in reality simply 'diff' was missing. This fixes it and makes the developer experience better by simply skipping the diffing if 'diff' is not found. Closes #1846 --- cmake/do_abi_check.cmake | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmake/do_abi_check.cmake b/cmake/do_abi_check.cmake index 43d8b15a7ab..0ad0fa39670 100644 --- a/cmake/do_abi_check.cmake +++ b/cmake/do_abi_check.cmake @@ -74,7 +74,9 @@ FOREACH(file ${ABI_HEADERS}) FILE(REMOVE ${tmpfile}) EXECUTE_PROCESS( COMMAND diff -w ${file}.pp ${abi_check_out} RESULT_VARIABLE result) - IF(NOT ${result} EQUAL 0) + IF(result MATCHES "No such file or directory") + MESSAGE("Command 'diff' not found. ABI check for ${file} skipped.") + ELSEIF(NOT result EQUAL 0) IF(ABI_UPDATE) EXECUTE_PROCESS(COMMAND mv -v ${abi_check_out} ${file}.pp) ELSE(ABI_UPDATE) @@ -84,4 +86,3 @@ FOREACH(file ${ABI_HEADERS}) ENDIF() FILE(REMOVE ${abi_check_out}) ENDFOREACH() - From 4352c77c5a3ac89acc5fd90a38f806d0ec500aa4 Mon Sep 17 00:00:00 2001 From: Brad Smith Date: Thu, 10 Jun 2021 20:01:44 -0400 Subject: [PATCH 048/251] Link with libexecinfo on OpenBSD for stacktrace functionality. --- cmake/os/OpenBSD.cmake | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 cmake/os/OpenBSD.cmake diff --git a/cmake/os/OpenBSD.cmake b/cmake/os/OpenBSD.cmake new file mode 100644 index 00000000000..a96cc891f38 --- /dev/null +++ b/cmake/os/OpenBSD.cmake @@ -0,0 +1,23 @@ + +# Copyright (c) 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 + +# This file includes OpenBSD specific options and quirks, related to system checks + +# Find libexecinfo (library that contains backtrace_symbols etc) +FIND_LIBRARY(EXECINFO NAMES execinfo) +IF(EXECINFO) + SET(LIBEXECINFO ${EXECINFO}) +ENDIF() From 8a2b4d531dc661ee605eeecdfc901bc833f86564 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Fri, 11 Jun 2021 14:30:42 +1000 Subject: [PATCH 049/251] MDEV-20162: fix connect-abstract test case The check-testcase record uses a mysqltest connection to the database to do the recording. With the server configured as an abstract socket, the mysqltest client cannot connect and fails. We work around this by starting the server as normal and then restart with an abstract socket and test this. This didn't affect Windows as it just did a tcp connection. So this did affect all unix socket based systems except Linux as this was the only one that supported abstract sockets. --- mysql-test/main/connect-abstract.cnf | 3 --- mysql-test/main/connect-abstract.result | 2 -- mysql-test/main/connect-abstract.test | 5 ++++- mysql-test/unstable-tests | 1 - 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/mysql-test/main/connect-abstract.cnf b/mysql-test/main/connect-abstract.cnf index 5798c4f2f2a..ed7dbd838f0 100644 --- a/mysql-test/main/connect-abstract.cnf +++ b/mysql-test/main/connect-abstract.cnf @@ -1,9 +1,6 @@ !include include/default_my.cnf -[mysqld.1] -socket= @ENV.ABSTRACT_SOCKET - # Using @OPT.port here for uniqueness [ENV] ABSTRACT_SOCKET= @mtr-test-abstract-socket-@OPT.port diff --git a/mysql-test/main/connect-abstract.result b/mysql-test/main/connect-abstract.result index 68a9674dfaa..8f7c125196a 100644 --- a/mysql-test/main/connect-abstract.result +++ b/mysql-test/main/connect-abstract.result @@ -1,5 +1,3 @@ -connect con1,localhost,root,,test,,$ABSTRACT_SOCKET; select 1; 1 1 -disconnect con1; diff --git a/mysql-test/main/connect-abstract.test b/mysql-test/main/connect-abstract.test index 0f212fe5a0d..09bc607e0e8 100644 --- a/mysql-test/main/connect-abstract.test +++ b/mysql-test/main/connect-abstract.test @@ -1,6 +1,9 @@ --source include/linux.inc --source include/not_embedded.inc +let $restart_parameters=--socket=$ABSTRACT_SOCKET +--source include/kill_mysqld.inc +--source include/start_mysqld.inc + connect(con1,localhost,root,,test,,$ABSTRACT_SOCKET); select 1; -disconnect con1; diff --git a/mysql-test/unstable-tests b/mysql-test/unstable-tests index df4a1e74447..a76912f4c78 100644 --- a/mysql-test/unstable-tests +++ b/mysql-test/unstable-tests @@ -37,7 +37,6 @@ main.backup_stages : MDEV-23401 - Bad file descriptor main.binary_to_hex : MDEV-20211 - Wrong result main.check_constraint : Modified in 10.4.18 main.connect : MDEV-17282 - Wrong result -main.connect-abstract : MDEV-20162 - Could not execute 'check-testcase' main.connect2 : MDEV-13885 - Server crash main.create : Modified in 10.4.18 main.create_delayed : MDEV-10605 - failed with timeout From 102ff4208d5b3fa695e8bab8fec0ae6ac7309fb6 Mon Sep 17 00:00:00 2001 From: Krunal Bauskar Date: Wed, 9 Jun 2021 13:13:06 +0800 Subject: [PATCH 050/251] =?UTF-8?q?MDEV-25882:=20Statistics=20used=20to=20?= =?UTF-8?q?track=20b-tree=20(non-adaptive)=20searches=20=C2=A0=20=C2=A0=20?= =?UTF-8?q?=C2=A0=20=C2=A0=20=C2=A0=20=C2=A0=20should=20be=20updated=20onl?= =?UTF-8?q?y=20when=20adaptive=20hashing=20is=20turned-on?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently, btr_cur_n_non_sea is used to track the search that missed adaptive hash index. adaptive hash index is turned off by default but the said variable is updated always though the value of it makes sense only when an adaptive index is enabled. It is meant to check how many searches didn't go through an adaptive hash index. Given a global variable that is updated on each search path it causes a contention with a multi-threaded workload. Patch moves the said variables inside a loop that is now updated only when the adaptive hash index is enabled and that in theory should also, reduce the update frequency of the said variable as the majority of the request should be serviced through the adaptive hash index. Variables (btr_cur_n_non_sea and btr_cur_n_sea) are also converted to use distributed counter to avoid contention. User visible changes: This also means that user will now see Innodb_adaptive_hash_non_hash_searches (viewed as part of show status) only if code is compiled with DWITH_INNODB_AHI=ON (default) and it will be updated only if innodb_adaptive_hash_index=1 else it reported as 0. --- storage/innobase/btr/btr0cur.cc | 14 ++++++++------ storage/innobase/handler/ha_innodb.cc | 5 +++-- storage/innobase/include/btr0cur.h | 6 +++--- storage/innobase/include/srv0mon.h | 2 -- storage/innobase/include/srv0srv.h | 4 ++++ storage/innobase/srv/srv0mon.cc | 4 +--- storage/innobase/srv/srv0srv.cc | 21 +++++++++++---------- 7 files changed, 30 insertions(+), 26 deletions(-) diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc index 21b51f2410b..4ceeec9205e 100644 --- a/storage/innobase/btr/btr0cur.cc +++ b/storage/innobase/btr/btr0cur.cc @@ -101,16 +101,16 @@ operations by purge as the previous, when it seems to be growing huge. throughput clearly from about 100000. */ #define BTR_CUR_FINE_HISTORY_LENGTH 100000 +#ifdef BTR_CUR_HASH_ADAPT /** Number of searches down the B-tree in btr_cur_search_to_nth_level(). */ -Atomic_counter btr_cur_n_non_sea; +ib_counter_t btr_cur_n_non_sea; /** Old value of btr_cur_n_non_sea. Copied by srv_refresh_innodb_monitor_stats(). Referenced by srv_printf_innodb_monitor(). */ ulint btr_cur_n_non_sea_old; -#ifdef BTR_CUR_HASH_ADAPT /** Number of successful adaptive hash index lookups in btr_cur_search_to_nth_level(). */ -ulint btr_cur_n_sea; +ib_counter_t btr_cur_n_sea; /** Old value of btr_cur_n_sea. Copied by srv_refresh_innodb_monitor_stats(). Referenced by srv_printf_innodb_monitor(). */ @@ -1403,7 +1403,8 @@ btr_cur_search_to_nth_level_func( # ifdef UNIV_SEARCH_PERF_STAT info->n_searches++; # endif - if (autoinc == 0 + if (!btr_search_enabled) { + } else if (autoinc == 0 && !estimate && latch_mode <= BTR_MODIFY_LEAF && !modify_external @@ -1429,13 +1430,14 @@ btr_cur_search_to_nth_level_func( || mode != PAGE_CUR_LE); ut_ad(cursor->low_match != ULINT_UNDEFINED || mode != PAGE_CUR_LE); - btr_cur_n_sea++; + ++btr_cur_n_sea; DBUG_RETURN(err); + } else { + ++btr_cur_n_non_sea; } # endif /* BTR_CUR_HASH_ADAPT */ #endif /* BTR_CUR_ADAPT */ - btr_cur_n_non_sea++; /* If the hash search did not succeed, do binary search down the tree */ diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 7199fcfb547..bfb587bef6a 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -889,8 +889,9 @@ static MYSQL_THDVAR_STR(tmpdir, static SHOW_VAR innodb_status_variables[]= { #ifdef BTR_CUR_HASH_ADAPT - {"adaptive_hash_hash_searches", &btr_cur_n_sea, SHOW_SIZE_T}, - {"adaptive_hash_non_hash_searches", &btr_cur_n_non_sea, SHOW_SIZE_T}, + {"adaptive_hash_hash_searches", &export_vars.innodb_ahi_hit, SHOW_SIZE_T}, + {"adaptive_hash_non_hash_searches", + &export_vars.innodb_ahi_miss, SHOW_SIZE_T}, #endif {"background_log_sync", &srv_log_writes_and_flush, SHOW_SIZE_T}, {"buffer_pool_dump_status", diff --git a/storage/innobase/include/btr0cur.h b/storage/innobase/include/btr0cur.h index 966cb73cdbf..6668fb6ca67 100644 --- a/storage/innobase/include/btr0cur.h +++ b/storage/innobase/include/btr0cur.h @@ -969,16 +969,16 @@ earlier version of the row. In rollback we are not allowed to free an inherited external field. */ #define BTR_EXTERN_INHERITED_FLAG 64U +#ifdef BTR_CUR_HASH_ADAPT /** Number of searches down the B-tree in btr_cur_search_to_nth_level(). */ -extern Atomic_counter btr_cur_n_non_sea; +extern ib_counter_t btr_cur_n_non_sea; /** Old value of btr_cur_n_non_sea. Copied by srv_refresh_innodb_monitor_stats(). Referenced by srv_printf_innodb_monitor(). */ extern ulint btr_cur_n_non_sea_old; -#ifdef BTR_CUR_HASH_ADAPT /** Number of successful adaptive hash index lookups in btr_cur_search_to_nth_level(). */ -extern ulint btr_cur_n_sea; +extern ib_counter_t btr_cur_n_sea; /** Old value of btr_cur_n_sea. Copied by srv_refresh_innodb_monitor_stats(). Referenced by srv_printf_innodb_monitor(). */ diff --git a/storage/innobase/include/srv0mon.h b/storage/innobase/include/srv0mon.h index 56b56a18bdb..32da0e4e2b4 100644 --- a/storage/innobase/include/srv0mon.h +++ b/storage/innobase/include/srv0mon.h @@ -345,9 +345,7 @@ enum monitor_id_t { /* Adaptive Hash Index related counters */ MONITOR_MODULE_ADAPTIVE_HASH, MONITOR_OVLD_ADAPTIVE_HASH_SEARCH, -#endif /* BTR_CUR_HASH_ADAPT */ MONITOR_OVLD_ADAPTIVE_HASH_SEARCH_BTREE, -#ifdef BTR_CUR_HASH_ADAPT MONITOR_ADAPTIVE_HASH_PAGE_ADDED, MONITOR_ADAPTIVE_HASH_PAGE_REMOVED, MONITOR_ADAPTIVE_HASH_ROW_ADDED, diff --git a/storage/innobase/include/srv0srv.h b/storage/innobase/include/srv0srv.h index d26a3fe97cc..41a0be0c5ff 100644 --- a/storage/innobase/include/srv0srv.h +++ b/storage/innobase/include/srv0srv.h @@ -697,6 +697,10 @@ void srv_master_thread_enable(); /** Status variables to be passed to MySQL */ struct export_var_t{ +#ifdef BTR_CUR_HASH_ADAPT + ulint innodb_ahi_hit; + ulint innodb_ahi_miss; +#endif /* BTR_CUR_HASH_ADAPT */ char innodb_buffer_pool_dump_status[OS_FILE_MAX_PATH + 128];/*!< Buf pool dump status */ char innodb_buffer_pool_load_status[OS_FILE_MAX_PATH + 128];/*!< Buf pool load status */ char innodb_buffer_pool_resize_status[512];/*!< Buf pool resize status */ diff --git a/storage/innobase/srv/srv0mon.cc b/storage/innobase/srv/srv0mon.cc index cd7e5c526d8..50d9ebff962 100644 --- a/storage/innobase/srv/srv0mon.cc +++ b/storage/innobase/srv/srv0mon.cc @@ -959,7 +959,6 @@ static monitor_info_t innodb_counter_info[] = static_cast( MONITOR_EXISTING | MONITOR_DEFAULT_ON), MONITOR_DEFAULT_START, MONITOR_OVLD_ADAPTIVE_HASH_SEARCH}, -#endif /* BTR_CUR_HASH_ADAPT */ {"adaptive_hash_searches_btree", "adaptive_hash_index", "Number of searches using B-tree on an index search", @@ -967,7 +966,6 @@ static monitor_info_t innodb_counter_info[] = MONITOR_EXISTING | MONITOR_DEFAULT_ON), MONITOR_DEFAULT_START, MONITOR_OVLD_ADAPTIVE_HASH_SEARCH_BTREE}, -#ifdef BTR_CUR_HASH_ADAPT {"adaptive_hash_pages_added", "adaptive_hash_index", "Number of index pages on which the Adaptive Hash Index is built", MONITOR_NONE, @@ -1819,11 +1817,11 @@ srv_mon_process_existing_counter( case MONITOR_OVLD_ADAPTIVE_HASH_SEARCH: value = btr_cur_n_sea; break; -#endif /* BTR_CUR_HASH_ADAPT */ case MONITOR_OVLD_ADAPTIVE_HASH_SEARCH_BTREE: value = btr_cur_n_non_sea; break; +#endif /* BTR_CUR_HASH_ADAPT */ case MONITOR_OVLD_PAGE_COMPRESS_SAVED: value = srv_stats.page_compression_saved; diff --git a/storage/innobase/srv/srv0srv.cc b/storage/innobase/srv/srv0srv.cc index 74da09b605a..1f2b05ecfa4 100644 --- a/storage/innobase/srv/srv0srv.cc +++ b/storage/innobase/srv/srv0srv.cc @@ -699,8 +699,8 @@ static void srv_refresh_innodb_monitor_stats(time_t current_time) #ifdef BTR_CUR_HASH_ADAPT btr_cur_n_sea_old = btr_cur_n_sea; -#endif /* BTR_CUR_HASH_ADAPT */ btr_cur_n_non_sea_old = btr_cur_n_non_sea; +#endif /* BTR_CUR_HASH_ADAPT */ log_refresh_stats(); @@ -839,20 +839,18 @@ srv_printf_innodb_monitor( part->latch.rd_unlock(); } + /* btr_cur_n_sea_old and btr_cur_n_non_sea_old are protected by + srv_innodb_monitor_mutex (srv_refresh_innodb_monitor_stats) */ + const ulint with_ahi = btr_cur_n_sea, without_ahi = btr_cur_n_non_sea; fprintf(file, "%.2f hash searches/s, %.2f non-hash searches/s\n", - static_cast(btr_cur_n_sea - btr_cur_n_sea_old) + static_cast(with_ahi - btr_cur_n_sea_old) / time_elapsed, - static_cast(btr_cur_n_non_sea - btr_cur_n_non_sea_old) - / time_elapsed); - btr_cur_n_sea_old = btr_cur_n_sea; -#else /* BTR_CUR_HASH_ADAPT */ - fprintf(file, - "%.2f non-hash searches/s\n", - static_cast(btr_cur_n_non_sea - btr_cur_n_non_sea_old) + static_cast(without_ahi - btr_cur_n_non_sea_old) / time_elapsed); + btr_cur_n_sea_old = with_ahi; + btr_cur_n_non_sea_old = without_ahi; #endif /* BTR_CUR_HASH_ADAPT */ - btr_cur_n_non_sea_old = btr_cur_n_non_sea; fputs("---\n" "LOG\n" @@ -968,6 +966,9 @@ srv_export_innodb_status(void) } #ifdef BTR_CUR_HASH_ADAPT + export_vars.innodb_ahi_hit = btr_cur_n_sea; + export_vars.innodb_ahi_miss = btr_cur_n_non_sea; + ulint mem_adaptive_hash = 0; for (ulong i = 0; i < btr_ahi_parts; i++) { const auto part= &btr_search_sys.parts[i]; From ff3fd02249a7a55623f0a2d0dde8026cd76c3ba2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 11 Jun 2021 13:06:05 +0300 Subject: [PATCH 051/251] MDEV-25288 follow-up: Remove mysql-test/unstable-tests We no longer maintain the unstable-tests collection. In commit 3635280cf7ef74ec18cfb21b21e779725aab186d we added a smoke test collection, which independent MariaDB package maintainers can expect to pass. --- mysql-test/unstable-tests | 844 -------------------------------------- 1 file changed, 844 deletions(-) delete mode 100644 mysql-test/unstable-tests diff --git a/mysql-test/unstable-tests b/mysql-test/unstable-tests deleted file mode 100644 index c38a490a07e..00000000000 --- a/mysql-test/unstable-tests +++ /dev/null @@ -1,844 +0,0 @@ -############################################################################## -# -# List the test cases which, unlike tests from disabled.def files, -# can still be run on the current tree meaningfully, but are known -# or suspected to fail sporadically on different reasons. -# -# Most common reasons are either test failures observed in buildbot, -# or recent modifications to the tests which make their stability -# unknown. -# -# Tests included due to recent modifications are later removed from the -# list, if during a certain period they do not fail (and are not -# modified again). Tests included due to intermittent failures are -# removed when corresponding bug reports are closed. -# -# Separate the test case name and the comment with ':'. -# -# . : MDEV-xxxxx - -# -# '*' wildcard in testcase names is supported. -# -# To use the list, run MTR with --skip-test-list=unstable-tests option. -# -############################################################################## -# -# Based on bb-10.5-release ae7989ca2 (galera.galera_gra_log crashes) -# for main suite changes and failures, and -# 10.5 8e1e2856f2523c225a81840059e93fa9f61fbacf -# for the rest - -main.alter_events : Added in 10.5.9 -main.alter_table_mdev539_maria : MDEV-23922 - Timeout or crash -main.alter_table_trans : MDEV-12084 - timeout -main.alter_user : Modified in 10.5.9 -main.analyze_stmt_slow_query_log : MDEV-12237 - Wrong result -main.auth_named_pipe : MDEV-14724 - System error 2 -main.auto_increment_ranges_innodb : Modified in 10.5.9 -main.backup_stages : MDEV-23401 - Bad file descriptor -main.binary_to_hex : MDEV-20211 - Wrong result -main.check_constraint : Modified in 10.5.9 -main.client_xml : MDEV-24085 - Wrong result -main.column_compression : MDEV-23954 - Wrong result -main.connect : MDEV-17282 - Wrong result -main.connect-abstract : MDEV-20162 - Could not execute 'check-testcase' -main.connect2 : MDEV-13885 - Server crash -main.create : Modified in 10.5.9 -main.create_delayed : MDEV-10605 - failed with timeout -main.create_drop_event : MDEV-16271 - Wrong result -main.create_or_replace : MDEV-22954 - Wrong result -main.cte_nonrecursive : Modified in 10.5.9 -main.cte_nonrecursive_not_embedded : Added in 10.5.9 -main.cte_recursive : Modified in 10.5.9 -main.ctype_binary : MDEV-24080 - Data too long for column -main.ctype_cp932_binlog_row : MDEV-20540 - Wrong result -main.ctype_cp932_binlog_stm : MDEV-20534 - Wrong result -main.ctype_ucs : MDEV-17681 - Data too long for column -main.ctype_upgrade : MDEV-16945 - Error upon mysql_upgrade -main.ctype_utf16 : MDEV-10675 - Timeout or extra warnings -main.ctype_utf16le : MDEV-10675 - Timeout or extra warnings -main.ctype_utf8mb4 : Modified in 10.5.9 -main.ctype_utf8mb4_heap : Include file modified in 10.5.9 -main.ctype_utf8mb4_innodb : MDEV-17744 - Timeout; MDEV-18567 - ASAN use-after-poison; include file modified in 10.5.9 -main.ctype_utf8mb4_myisam : Include file modified in 10.5.9 -main.debug_sync : MDEV-10607 - internal error -main.delayed : MDEV-20961 - Assertion failure -main.derived_cond_pushdown : MDEV-20532 - Floating point differences; modified in 10.5.9 -main.dirty_close : MDEV-19368 - mysqltest failed but provided no output -main.distinct : MDEV-14194 - Crash -main.drop : Modified in 10.5.9 -main.drop_bad_db_type : MDEV-15676 - Wrong result -main.dyncol : MDEV-19455 - Extra warning -main.empty_string_literal : Modified in 10.5.9 -main.events_2 : MDEV-13277 - Crash -main.events_bugs : MDEV-12892 - Crash -main.events_restart : MDEV-12236 - Server shutdown problem -main.events_slowlog : MDEV-12821 - Wrong result -main.failed_auth_unixsocket : MDEV-23933 - Access denied -main.flush : MDEV-19368 - mysqltest failed but provided no output -main.flush_block_commit_notembedded : MDEV-23974 - InnoDB error -main.flush_read_lock : MDEV-22953 - Unknown XID -main.flush_ssl : MDEV-21276 - Aria recovery failure -main.func_gconcat : MDEV-21379 - Valgrind warnings; modified in 10.5.9 -main.func_like : Modified in 10.5.9 -main.func_math : MDEV-20966 - Wrong error code -main.func_str : Modified in 10.5.9 -main.gis : MDEV-13411 - wrong result on P8 -main.gis-json : Modified in 10.5.9 -main.gis_notembedded : MDEV-21264 - Wrong result with non-default charset -main.grant : Modified in 10.5.9 -main.grant_kill : MDEV-23915 - Wrong result -main.grant_slave_admin : Modified in 10.5.9 -main.grant_slave_monitor : Added in 10.5.9 -main.group_by : Modified in 10.5.9 -main.having : MDEV-23420 - Server crash -main.host_cache_size_functionality : MDEV-10606 - sporadic failure on shutdown -main.index_intersect : MDEV-23921 - Wrong result -main.index_intersect_innodb : MDEV-23921 - Wrong result; MDEV-10643 - failed with timeout -main.index_merge_innodb : MDEV-7142 - Plan mismatch -main.information_schema : Modified in 10.5.9 -main.information_schema_all_engines : MDEV-23421 - Wrong result -main.innodb_ext_key : MDEV-20169 - Wrong result -main.innodb_icp : MDEV-20168 - Wrong execution plans -main.innodb_mrr_cpk : MDEV-24737 - Server crash -main.invisible_field_grant_completely : MDEV-22254 - Syscall param write points to uninitialised bytes -main.ipv4_and_ipv6 : MDEV-20964 - Wrong result -main.ipv6 : MDEV-20964 - Wrong result -main.join_cache : MDEV-17743 - Bad address from storage engine MyISAM -main.join_outer : MDEV-24456 - Timeout on riscv64 -main.join_outer_jcl6 : MDEV-24456 - Timeout on riscv64 -main.kill : MDEV-24801 - Wrong errno on reap; modified in 10.5.9 -main.kill-2 : MDEV-13257 - Wrong result -main.kill_processlist-6619 : MDEV-10793 - Wrong result -main.loaddata : MDEV-19368 - mysqltest failed but provided no output -main.locale : MDEV-20521 - Missing warning -main.lock_tables_lost_commit : MDEV-24624 - Timeout -main.lock_user : Modified in 10.5.9 -main.lock_view : Modified in 10.5.9 -main.log_slow : MDEV-13263 - Wrong result -main.log_tables-big : MDEV-13408 - wrong result -main.log_tables_upgrade : MDEV-20962 - Wrong result -main.mdev-504 : MDEV-15171 - warning -main.mdev375 : MDEV-10607 - sporadic "can't connect" -main.mdl : MDEV-22954 - Wrong result -main.merge : MDEV-10607 - sporadic "can't connect" -main.myisam : Modified in 10.5.9 -main.myisam_icp_notembedded : MDEV-23420 - Server crash -main.mysql : MDEV-20156 - Wrong result -main.mysql_client_test : MDEV-19369 - error: 5888, status: 23, errno: 2; MDEV-19511 - Big endian issue -main.mysql_client_test_comp : MDEV-16641 - Error in exec -main.mysql_client_test_nonblock : CONC-208 - Error on Power; MDEV-15096 - exec failed -main.mysql_cp932 : MDEV-21275 - Wrong result -main.mysql_json_mysql_upgrade : Added in 10.5.9 -main.mysql_json_mysql_upgrade_with_plugin_loaded : Added in 10.5.9 -main.mysql_json_table_recreate : Modified in 10.5.9 -main.mysql_upgrade : MDEV-20161 - Wrong result; MDEV-20166 - FATAL ERROR: Upgrade failed; modified in 10.5.9 -main.mysql_upgrade-6984 : MDEV-22514 - Wrong result -main.mysql_upgrade_mysql_json_datatype : Modified in 10.5.9 -main.mysql_upgrade_no_innodb : MDEV-20537 - Wrong result -main.mysql_upgrade_noengine : MDEV-14355 - Wrong result -main.mysql_upgrade_to_100502 : Modified in 10.5.9 -main.mysql_upgrade_view : MDEV-23392 - Wrong result; MDEV-20161 - Wrong result -main.mysqladmin : MDEV-20535 - Wrong result -main.mysqlbinlog : Modified in 10.5.9 -main.mysqlbinlog_row_compressed : MDEV-22964 - Wrong result -main.mysqlcheck : MDEV-20164 - Wrong result -main.mysqld_option_err : MDEV-21236 - Wrong error; MDEV-21571 - Crash on bootstrap -main.mysqldump : Modified in 10.5.9 -main.mysqldump-max : MDEV-21272 - Wrong result -main.mysqldump-system : Added in 10.5.9 -main.mysqlshow : MDEV-20965 - Wrong result -main.mysqlslap : MDEV-11801 - timeout -main.mysqltest : MDEV-13887 - Wrong result -main.old-mode : MDEV-19373 - Wrong result -main.openssl_6975 : MDEV-17184 - Failures with OpenSSL 1.1.1 -main.order_by : Modified in 10.5.9 -main.order_by_optimizer_innodb : MDEV-10683 - Wrong result -main.parser : Modified in 10.5.9 -main.partition_debug_sync : MDEV-15669 - Deadlock found when trying to get lock -main.partition_innodb : MDEV-20169 - Wrong result; MDEV-23427 - Server crash -main.partition_innodb_plugin : MDEV-12901 - Valgrind warnings -main.partition_innodb_semi_consistent : MDEV-19411 - Failed to start mysqld.1 -main.plugin_auth : MDEV-20957 - Upgrade file was not properly created -main.plugin_auth_qa_2 : MDEV-20165 - Wrong result -main.pool_of_threads : MDEV-18135 - SSL error: key too small -main.precedence : Modified in 10.5.9 -main.processlist_notembedded : MDEV-23752 - Not explainable command; modified in 10.5.9 -main.ps : MDEV-11017 - sporadic wrong Prepared_stmt_count -main.ps_error : MDEV-24079 - Memory not freed -main.ps_show_log : Added in 10.5.9 -main.query_cache : MDEV-16180 - Wrong result; modified in 10.5.9 -main.query_cache_debug : MDEV-15281 - Query cache is disabled -main.range : Modified in 10.5.9 -main.range_innodb : MDEV-23371 - Server crash -main.range_notembedded : Added in 10.5.9 -main.range_vs_index_merge_innodb : MDEV-15283 - Server has gone away -main.repair_symlink-5543 : MDEV-23920 - Wrong result; modified in 10.5.9 -main.rowid_filter_innodb : MDEV-20538 - Wrong result -main.select : MDEV-20532 - Floating point differences -main.select_jcl6 : MDEV-20532 - Floating point differences -main.select_pkeycache : MDEV-20532 - Floating point differences -main.select_safe : MDEV-23420 - Server crash -main.set_operation : Modified in 10.5.9 -main.set_password : Modified in 10.5.9 -main.set_statement : MDEV-13183 - Wrong result -main.set_statement_notembedded : MDEV-19414 - Wrong result -main.shm : MDEV-12727 - Mismatch, ERROR 2013 -main.show_explain : MDEV-10674 - Wrong result code -main.skip_grants : Modified in 10.5.9 -main.sp : MDEV-7866 - Mismatch; modified in 10.5.9 -main.sp-big : MDEV-24457 - Result mismatch on riscv64 -main.sp-security : MDEV-10607 - sporadic "can't connect" -main.sp-ucs2 : Modified in 10.5.9 -main.sp_notembedded : MDEV-10607 - internal error -main.sp_trans_log : MDEV-24886 - Timeout -main.ssl : MDEV-17184 - Failures with OpenSSL 1.1.1 -main.ssl_7937 : MDEV-20958 - Wrong result -main.ssl_ca : MDEV-10895 - SSL connection error on Power -main.ssl_cipher : MDEV-17184 - Failures with OpenSSL 1.1.1 -main.ssl_timeout : MDEV-11244 - Crash -main.stat_tables : Modified in 10.5.9 -main.stat_tables_innodb : MDEV-20169 - Wrong result -main.stat_tables_par_innodb : MDEV-14155 - Wrong rounding -main.status : MDEV-13255 - Wrong result -main.subselect : MDEV-20551 - Valgrind failure -main.subselect4 : Modified in 10.5.9 -main.subselect_innodb : MDEV-10614 - Wrong result -main.symlink-myisam-11902 : Modified in 10.5.9 -main.table_value_constr : Modified in 10.5.9 -main.tc_heuristic_recover : MDEV-14189 - Wrong result -main.temp_table_symlink : MDEV-24058 - Wrong error code -main.tls_version : MDEV-23417 - Wrong result -main.type_blob : MDEV-15195 - Wrong result -main.type_datetime_hires : MDEV-10687 - Timeout -main.type_float : MDEV-20532 - Floating point differences -main.type_newdecimal : MDEV-20532 - Floating point differences -main.type_ranges : MDEV-20532 - Floating point differences -main.type_temporal_innodb : MDEV-24025 - Wrong result -main.type_year : Modified in 10.5.9 -main.union : Modified in 10.5.9 -main.user_limits : Modified in 10.5.9 -main.userstat : MDEV-12904 - SSL errors -main.view : Modified in 10.5.9 -main.wait_timeout : MDEV-19023 - Lost connection to MySQL server during query -main.xa : MDEV-11769 - lock wait timeout; modified in 10.5.9 -main.xml : MDEV-21968 - Crash on armhf - -#----------------------------------------------------------------------- - -archive.archive-big : MDEV-20167 - Wrong error code -archive.archive_bitfield : MDEV-11771 - table is marked as crashed -archive.archive_symlink : MDEV-12170 - unexpected error on rmdir -archive.discover : MDEV-10510 - Table is marked as crashed - -#----------------------------------------------------------------------- - -archive-test_sql_discovery.discover : MDEV-16817 - Table marked as crashed - -#----------------------------------------------------------------------- - -binlog.binlog_commit_wait : MDEV-10150 - Mismatch -binlog.binlog_innodb : MDEV-22516 - Wrong result -binlog.binlog_killed : MDEV-12925 - Wrong result -binlog.binlog_max_extension : MDEV-19762 - Crash on shutdown -binlog.binlog_mysqlbinlog_row_innodb : MDEV-20530 - Binary files differ -binlog.binlog_mysqlbinlog_row_myisam : MDEV-20530 - Binary files differ -binlog.binlog_no_uniqfile_crash : MDEV-24078 - Server crash upon shutdown -binlog.binlog_row_binlog : MDEV-23402 - Wrong result -binlog.binlog_stm_binlog : MDEV-20412 - Wrong result -binlog.binlog_stm_mix_innodb_myisam : MDEV-24057 - Wrong result -binlog.binlog_xa_recover : MDEV-12908 - Extra checkpoint -binlog.flashback-largebinlog : MDEV-19764 - Out of memory -binlog.load_data_stm_view : MDEV-16948 - Wrong result -binlog.show_concurrent_rotate : MDEV-20215 - Wrong result - -#----------------------------------------------------------------------- - -binlog_encryption.binlog_xa_recover : MDEV-12908 - Extra checkpoint -binlog_encryption.encrypted_master : MDEV-23905 - Failure upon post-check; MDEV-23637 - Assertion failure; MDEV-14201 - Extra warnings -binlog_encryption.encrypted_master_switch_to_unencrypted : MDEV-14190 - Can't init tc log -binlog_encryption.encrypted_slave : MDEV-18135 - SSL error: key too small -binlog_encryption.encryption_combo : MDEV-14199 - Table is marked as crashed -binlog_encryption.multisource : MDEV-21289 - Wrong error code -binlog_encryption.rpl_binlog_errors : MDEV-12742 - Crash -binlog_encryption.rpl_checksum : MDEV-16951 - Wrong result -binlog_encryption.rpl_corruption : MDEV-20953 - Wrong error code -binlog_encryption.rpl_gtid_basic : MDEV-16947 - Server failed to start -binlog_encryption.rpl_incident : MDEV-21569 - mutex: LOCK_global_system_variables unlocking -binlog_encryption.rpl_loadfile : MDEV-16645 - Timeout in include -binlog_encryption.rpl_mixed_binlog_max_cache_size : MDEV-20956 - Incorrect checksum for freed object -binlog_encryption.rpl_parallel : MDEV-10653 - Timeout in include -binlog_encryption.rpl_parallel_ignored_errors : MDEV-22471 - Slave crash -binlog_encryption.rpl_parallel_stop_on_con_kill : MDEV-24086 - Timeout -binlog_encryption.rpl_relayrotate : MDEV-15194 - Timeout -binlog_encryption.rpl_semi_sync : MDEV-11673 - Valgrind -binlog_encryption.rpl_skip_replication : MDEV-13571 - Unexpected warning; MDEV-20573 - Wrong result -binlog_encryption.rpl_ssl : MDEV-14507 - Timeouts -binlog_encryption.rpl_stm_relay_ign_space : MDEV-19375 - Test assertion failed -binlog_encryption.rpl_temporal_format_default_to_default : MDEV-21273 - Timeout -binlog_encryption.rpl_typeconv : MDEV-14362 - Lost connection to MySQL server during query - -#----------------------------------------------------------------------- - -connect.alter : MDEV-18135 - SSL error: key too small -connect.drop-open-error : MDEV-18135 - SSL error: key too small -connect.json : MDEV-18135 - SSL error: key too small -connect.part_file : MDEV-18135 - SSL error: key too small -connect.part_table : MDEV-18135 - SSL error: key too small -connect.pivot : MDEV-14803 - Failed to discover table -connect.secure_file_priv : MDEV-18135 - SSL error: key too small -connect.vcol : MDEV-12374 - Fails on Windows -connect.zip : MDEV-13884 - Wrong result - -#----------------------------------------------------------------------- - -disks.disks_notembedded : MDEV-21587 - Wrong result - -#----------------------------------------------------------------------- - -encryption.create_or_replace : MDEV-24081 - Lock wait timeout exceeded -encryption.debug_key_management : MDEV-13841 - Timeout -encryption.encrypt_and_grep : MDEV-13765 - Wrong result -encryption.innochecksum : MDEV-13644 - Assertion failure -encryption.innodb-bad-key-change2 : MDEV-19118 - Can't connect to local MySQL server through socket -encryption.innodb-compressed-blob : MDEV-14728 - Unable to get certificate -encryption.innodb-discard-import : MDEV-19113 - Timeout -encryption.innodb-encryption-alter : MDEV-13566 - Lock wait timeout -encryption.innodb-first-page-read : MDEV-14356 - Timeout in wait condition -encryption.innodb-force-corrupt : MDEV-17286 - SSL error -encryption.innodb-missing-key : MDEV-14728 - SSL error -encryption.innodb-page_encryption : MDEV-10641 - mutex problem -encryption.innodb-page_encryption_log_encryption : MDEV-17339 - Crash on restart -encryption.innodb-read-only : MDEV-16563 - Crash on startup -encryption.innodb-remove-encryption : MDEV-16493 - Timeout in wait condition -encryption.innodb-spatial-index : MDEV-13746 - Wrong result -encryption.innodb_encrypt_key_rotation_age : MDEV-19763 - Timeout -encryption.innodb_encrypt_log : MDEV-13725 - Wrong result -encryption.innodb_encrypt_log_corruption : MDEV-14379 - Server crash -encryption.innodb_encrypt_temporary_tables : MDEV-20142 - Wrong result -encryption.innodb_encryption : MDEV-14728 - Unable to get certificate; MDEV-15675 - Timeout -encryption.innodb_encryption-page-compression : MDEV-12630 - Crash or assertion failure; MDEV-21843 - Assertion failure -encryption.innodb_encryption_discard_import : MDEV-16116 - Wrong result -encryption.innodb_encryption_filekeys : MDEV-15673 - Timeout -encryption.innodb_encryption_row_compressed : MDEV-16113 - Crash -encryption.innodb_encryption_tables : MDEV-17339 - Crash on restart -encryption.innodb_first_page : MDEV-10689 - Crash -encryption.innodb_onlinealter_encryption : MDEV-17287 - SIGABRT on server restart - -#----------------------------------------------------------------------- - -engines/funcs.* : Not maintained in timely manner -engines/funcs.rpl_row_until : MDEV-22474 - Warning, slaves cannot process events - -#----------------------------------------------------------------------- - -engines/iuds.* : Not maintained in timely manner - -#----------------------------------------------------------------------- - -engines/rr_trx.* : MDEV-10998 - Not maintained - -#----------------------------------------------------------------------- - -federated.federated_bug_35333 : MDEV-13410 - Wrong result -federated.federated_bug_585688 : MDEV-14805 - Server crash, MDEV-12907 - Valgrind -federated.federated_innodb : MDEV-10617 - Wrong checksum -federated.federated_partition : MDEV-10417 - Fails on Mips -federated.federated_transactions : MDEV-10617 - Wrong checksum -federated.federatedx : MDEV-10617 - Wrong checksum - -#----------------------------------------------------------------------- - -funcs_1.memory_views : MDEV-11773 - timeout -funcs_1.processlist_val_no_prot : MDEV-11223 - Wrong result -funcs_1.processlist_val_ps : MDEV-12175 - Wrong plan - -#----------------------------------------------------------------------- - -funcs_2.memory_charset : MDEV-10290 - Timeout -funcs_2.myisam_charset : MDEV-11535 - Timeout - -#----------------------------------------------------------------------- - -funcs_2/charset.* : MDEV-10999 - Not maintained - -#----------------------------------------------------------------------- - -galera.* : Suite is not stable yet - -#----------------------------------------------------------------------- - -galera_3nodes.* : Suite is not stable yet - -#----------------------------------------------------------------------- - -gcol.innodb_virtual_basic : MDEV-16950 - Failing assertion -gcol.innodb_virtual_debug : MDEV-23111 - Server crash; MDEV-23112 - Server crash -gcol.innodb_virtual_fk : MDEV-20640 - Assertion failure -gcol.innodb_virtual_fk_restart : MDEV-17466 - Assertion failure -gcol.innodb_virtual_purge : MDEV-22952 - Lock wait timeout -gcol.main_alter_table : MDEV-23403 - Wrong result - -#----------------------------------------------------------------------- - -innodb.101_compatibility : MDEV-13891 - Wrong result -innodb.alter_copy : MDEV-16181 - Assertion failure -innodb.alter_crash : MDEV-16944 - The process cannot access the file -innodb.alter_large_dml : MDEV-20148 - Debug sync point wait timed out -innodb.binlog_consistent : MDEV-10618 - Server fails to start -innodb.blob-crash : MDEV-20481 - Crash during recovery -innodb.doublewrite : MDEV-12905 - Server crash -innodb.foreign_key : MDEV-21283 - Extra warning -innodb.group_commit_crash : MDEV-14191 - InnoDB registration failed -innodb.group_commit_crash_no_optimize_thread : MDEV-11770 - Checksum mismatch -innodb.ibuf_not_empty : MDEV-19021 - Wrong result -innodb.innodb-32k-crash : MDEV-20194 - Extra warnings -innodb.innodb-64k-crash : MDEV-13872 - Failure and crash on startup -innodb.innodb-alter : MDEV-22955 - Extra warning -innodb.innodb-alter-debug : MDEV-13182 - InnoDB: adjusting FSP_SPACE_FLAGS -innodb.innodb-alter-table : MDEV-10619 - Testcase timeout -innodb.innodb-bigblob : MDEV-18655 - ASAN unknown crash -innodb.innodb-blob : MDEV-12053 - Client crash -innodb.innodb-change-buffer-recovery : MDEV-19115 - Lost connection to MySQL server during query -innodb.innodb-fk : MDEV-13832 - Assertion failure on shutdown -innodb.innodb-get-fk : MDEV-13276 - Server crash -innodb.innodb-index-online : MDEV-14809 - Cannot save statistics -innodb.innodb-page_compression_default : MDEV-13644 - Assertion failure -innodb.innodb-page_compression_lzma : MDEV-14353 - Wrong result -innodb.innodb-page_compression_snappy : MDEV-13644 - Assertion failure -innodb.innodb-page_compression_tables : MDEV-13644 - Assertion failure -innodb.innodb-page_compression_zip : MDEV-10641 - mutex problem -innodb.innodb-table-online : MDEV-13894 - Wrong result -innodb.innodb-ucs2 : MDEV-24505 - Assertion failure -innodb.innodb-wl5522 : MDEV-13644 - Assertion failure -innodb.innodb-wl5522-1 : MDEV-22945 - Server crash -innodb.innodb-wl5522-debug : MDEV-14200 - Wrong errno -innodb.innodb_buffer_pool_dump_pct : MDEV-20139 - Timeout in wait_condition.inc -innodb.innodb_buffer_pool_resize : MDEV-23637 - Assertion failure -innodb.innodb_buffer_pool_resize_debug : MDEV-22515 - Timeout in wait_condition -innodb.innodb_buffer_pool_resize_with_chunks : MDEV-23637 - Assertion failure -innodb.innodb_bug30423 : MDEV-7311 - Wrong result -innodb.innodb_bug47167 : MDEV-20524 - Table 'user' is marked as crashed and should be repaired -innodb.innodb_bug48024 : MDEV-14352 - Assertion failure -innodb.innodb_bulk_create_index_replication : MDEV-15273 - Slave failed to start -innodb.innodb_defrag_stats_many_tables : MDEV-14198 - Table is full -innodb.innodb_force_recovery_rollback : MDEV-22889 - Wrong result -innodb.innodb_information_schema : MDEV-8851 - Wrong result -innodb.innodb_information_schema_buffer : MDEV-23418 - Wrong result -innodb.innodb_max_recordsize_32k : MDEV-14801 - Operation failed -innodb.innodb_max_recordsize_64k : MDEV-15203 - Wrong result -innodb.innodb_mysql : MDEV-19873 - Wrong result -innodb.innodb_simulate_comp_failures_small : MDEV-20526 - ASAN use-after-poison -innodb.innodb_stats : MDEV-10682 - wrong result -innodb.innodb_stats_persistent : MDEV-21567 - Wrong result in execution plan -innodb.innodb_stats_persistent_debug : MDEV-14801 - Operation failed -innodb.innodb_zip_innochecksum2 : MDEV-13882 - Warning: difficult to find free blocks -innodb.instant_alter_extend : MDEV-20963 - Binary files differ -innodb.log_corruption : MDEV-13251 - Wrong result -innodb.log_data_file_size : MDEV-14204 - Server failed to start; MDEV-20648 - Assertion failure -innodb.log_file_name : MDEV-14193 - Exception -innodb.log_file_size : MDEV-15668 - Not found pattern -innodb.max_record_size : MDEV-23420 - Server crash -innodb.monitor : MDEV-16179 - Wrong result -innodb.purge_secondary : MDEV-15681 - Wrong result -innodb.purge_thread_shutdown : MDEV-13792 - Wrong result -innodb.read_only_recovery : MDEV-13886 - Server crash -innodb.recovery_shutdown : MDEV-15671 - Checksum mismatch in datafile -innodb.row_format_redundant : MDEV-15192 - Trying to access missing tablespace -innodb.table_definition_cache_debug : MDEV-14206 - Extra warning -innodb.table_flags : MDEV-13572 - Wrong result; MDEV-19374 - Server failed to start -innodb.temp_table_savepoint : MDEV-24077 - Assertion failure -innodb.temporary_table : MDEV-13265 - Wrong result -innodb.undo_truncate : MDEV-17340 - Server hung; MDEV-20840 - Sporadic timeout -innodb.undo_truncate_recover : MDEV-17679 - Server has gone away; MDEV-19200 - Shutdown fails -innodb.update_time : MDEV-14804 - Wrong result -innodb.xa_recovery : MDEV-15279 - mysqld got exception - -#----------------------------------------------------------------------- - -innodb_fts.fulltext2 : MDEV-24074 - Server crash -innodb_fts.innodb_fts_misc : MDEV-22955 - Extra warning -innodb_fts.innodb_fts_misc_debug : MDEV-14156 - Unexpected warning -innodb_fts.innodb_fts_plugin : MDEV-13888 - Errors in server log -innodb_fts.innodb_fts_stopword_charset : MDEV-13259 - Table crashed -innodb_fts.sync_ddl : MDEV-21568 - Errno: 2000; MDEV-18654 - Assertion failure - -#----------------------------------------------------------------------- - -innodb_gis.alter_spatial_index : MDEV-13745 - Server crash -innodb_gis.gis_split_nan : MDEV-21678 - Cannot get geometry object -innodb_gis.rtree_compress2 : MDEV-16269 - Wrong result -innodb_gis.rtree_concurrent_srch : MDEV-15284 - Wrong result with embedded -innodb_gis.rtree_purge : MDEV-15275 - Timeout -innodb_gis.rtree_recovery : MDEV-15274 - Error on check -innodb_gis.rtree_split : MDEV-14208 - Too many arguments -innodb_gis.rtree_undo : MDEV-14456 - Timeout in include file -innodb_gis.types : MDEV-15679 - Table is marked as crashed - -#----------------------------------------------------------------------- - -innodb_zip.cmp_per_index : MDEV-14490 - Table is marked as crashed -innodb_zip.create_options : MDEV-24076 - Assertion failure -innodb_zip.index_large_prefix_4k : MDEV-21679 - Row size too large -innodb_zip.innochecksum : MDEV-14486 - Server failed to shut down -innodb_zip.innochecksum_3 : MDEV-13279 - Extra warnings -innodb_zip.wl5522_debug_zip : MDEV-11600 - Operating system error number 2 -innodb_zip.wl6470_1 : MDEV-14240 - Assertion failure -innodb_zip.wl6501_1 : MDEV-10891 - Can't create UNIX socket -innodb_zip.wl6501_scale_1 : MDEV-13254 - Timeout, MDEV-14104 - Error 192 - -#----------------------------------------------------------------------- - -maria.insert_select : MDEV-12757 - Timeout -maria.insert_select-7314 : MDEV-16492 - Timeout -maria.maria : MDEV-14430 - Extra warning -maria.maria-no-logging : MDEV-20196 - Crash on shutdown or server can't start - -#----------------------------------------------------------------------- - -mariabackup.absolute_ibdata_paths : MDEV-16571 - Wrong result -mariabackup.apply-log-only : MDEV-20135 - Timeout -mariabackup.backup_ssl : MDEV-24073 - Server crash upon shutdown -mariabackup.data_directory : MDEV-15270 - Error on exec -mariabackup.full_backup : MDEV-16571 - Wrong result -mariabackup.huge_lsn : MDEV-18569 - Table doesn't exist -mariabackup.incremental_backup : MDEV-21222 - Memory allocation failure -mariabackup.incremental_encrypted : MDEV-15667 - timeout -mariabackup.incremental_rocksdb : MDEV-20954 - Cannot access the file -mariabackup.innodb_redo_overwrite : MDEV-24023 - Wrong result -mariabackup.log_checksum_mismatch : MDEV-16571 - Wrong result -mariabackup.mdev-14447 : MDEV-15201 - Timeout -mariabackup.partial_exclude : MDEV-15270 - Error on exec -mariabackup.undo_space_id : MDEV-24022 - InnoDB error -mariabackup.unencrypted_page_compressed : MDEV-18653 - Wrong error -mariabackup.xb_compressed_encrypted : MDEV-14812 - Segmentation fault -mariabackup.xb_file_key_management : MDEV-16571 - Wrong result -mariabackup.xb_page_compress : MDEV-14810 - status: 1, errno: 11 -mariabackup.xb_partition : MDEV-17584 - Crash upon shutdown -mariabackup.xb_rocksdb : MDEV-17338 - Server hung on shutdown - -#----------------------------------------------------------------------- - -mroonga/storage.column_datetime_32bit_2038 : Wrong result on Alpha -mroonga/storage.column_datetime_32bit_before_unix_epoch : Wrong result on Alpha -mroonga/storage.column_datetime_32bit_max : Wrong result on Alpha -mroonga/storage.column_datetime_32bit_out_of_range : Wrong result on Alpha -mroonga/storage.index_multiple_column_unique_date_32bit_equal : Wrong result on Alpha -mroonga/storage.index_multiple_column_unique_date_order_32bit_desc : Wrong result on Alpha -mroonga/storage.index_multiple_column_unique_datetime_index_read : MDEV-8643 - Valgrind -mroonga/storage.repair_table_no_index_file : MDEV-9364 - wrong result, MDEV-14807 - wrong error message - -#----------------------------------------------------------------------- - -mroonga/wrapper.repair_table_no_index_file : MDEV-14807 - Wrong error message - -#----------------------------------------------------------------------- - -multi_source.gtid : MDEV-14202 - Crash -multi_source.info_logs : MDEV-12629 - Valgrind; MDEV-10042 - wrong result; MDEV-21290 - Wrong result -multi_source.load_data : MDEV-21235 - Slave crash -multi_source.mdev-8874 : MDEV-19415 - AddressSanitizer: heap-use-after-free -multi_source.mdev-9544 : MDEV-19415 - AddressSanitizer: heap-use-after-free -multi_source.multisource : MDEV-10417 - Fails on Mips -multi_source.status_vars : MDEV-4632 - failed while waiting for Slave_received_heartbeats - -#----------------------------------------------------------------------- - -oqgraph.social : MDEV-22280 - Timeout - -#----------------------------------------------------------------------- - -parts.partition_alter1_1_2_innodb : MDEV-18655 - ASAN unknown crash -parts.partition_alter1_1_innodb : MDEV-18655 - ASAN unknown crash -parts.partition_alter1_2_innodb : MDEV-18655 - ASAN unknown crash -parts.partition_alter2_2_maria : MDEV-14364 - Lost connection to MySQL server during query -parts.partition_auto_increment_archive : MDEV-16491 - Marked as crashed and should be repaired -parts.partition_auto_increment_maria : MDEV-14430 - Extra warning -parts.partition_basic_innodb : MDEV-20214 - ASAN error -parts.partition_debug_innodb : MDEV-10891 - Can't create UNIX socket; MDEV-15095 - Table doesn't exist -parts.partition_exch_qa_10 : MDEV-11765 - wrong result -parts.partition_innodb_status_file : MDEV-12901 - Valgrind -parts.partition_special_innodb : MDEV-16942 - Timeout - -#----------------------------------------------------------------------- - -perfschema.bad_option_1 : MDEV-21571 - Crash on bootstrap -perfschema.connect_attrs : MDEV-17283 - Wrong result -perfschema.dml_file_instances : MDEV-15179 - Wrong result -perfschema.dml_threads : MDEV-17746 - Wrong errno -perfschema.func_file_io : MDEV-5708 - fails for s390x -perfschema.func_mutex : MDEV-5708 - fails for s390x -perfschema.hostcache_ipv4_addrinfo_again_allow : MDEV-12759 - Crash -perfschema.hostcache_ipv6_addrinfo_again_allow : MDEV-12752 - Crash -perfschema.hostcache_ipv6_addrinfo_bad_allow : MDEV-13260 - Crash -perfschema.hostcache_ipv6_ssl : MDEV-10696 - Crash -perfschema.memory_aggregate_no_a : MDEV-22949 - Wrong result -perfschema.memory_aggregate_no_a_no_h : MDEV-22949 - Wrong result -perfschema.memory_aggregate_no_a_no_u : MDEV-22949 - Wrong result -perfschema.memory_aggregate_no_a_no_u_no_h : MDEV-22949 - Wrong result -perfschema.nesting : MDEV-23458 - Wrong result -perfschema.pfs_upgrade_event : MDEV-20957 - Wrong result -perfschema.pfs_upgrade_func : MDEV-20957 - Upgrade file was not properly created -perfschema.pfs_upgrade_proc : MDEV-20533 - Upgrade file was not properly created -perfschema.pfs_upgrade_table : MDEV-20533 - Exec failed -perfschema.pfs_upgrade_view : MDEV-20533 - Upgrade file was not properly created -perfschema.privilege_table_io : MDEV-13184 - Extra lines -perfschema.relaylog : MDEV-18134 - Wrong result; MDEV-24075 - Extra warning -perfschema.rpl_gtid_func : MDEV-16897 - Wrong result -perfschema.show_aggregate : MDEV-22962 - Wrong results -perfschema.socket_instances_func : MDEV-20140 - Wrong result -perfschema.socket_summary_by_event_name_func : MDEV-10622 - Wrong result -perfschema.socket_summary_by_instance_func : MDEV-19413 - Wrong result -perfschema.stage_mdl_function : MDEV-20157 - Wrong result -perfschema.stage_mdl_global : MDEV-11803 - wrong result on slow builders -perfschema.stage_mdl_procedure : MDEV-11545 - Missing row -perfschema.stage_mdl_table : MDEV-12638 - Wrong result -perfschema.start_server_low_digest : MDEV-21221 - Wrong result -perfschema.threads_history : MDEV-22948 - Wrong result -perfschema.threads_mysql : MDEV-10677 - Wrong result - -#----------------------------------------------------------------------- - -perfschema_stress.* : MDEV-10996 - Not maintained - -#----------------------------------------------------------------------- - -plugins.feedback_plugin_send : MDEV-7932, MDEV-11118 - Connection problems and such -plugins.multiauth : MDEV-20163 - Plugin could not be loaded -plugins.processlist : MDEV-16574 - Wrong result -plugins.server_audit : MDEV-14295 - Wrong result -plugins.thread_pool_server_audit : MDEV-14295 - Wrong result - -#----------------------------------------------------------------------- - -rocksdb.* : Too many crashes in various tests -rocksdb.2pc_group_commit : MDEV-14455 - Wrong result -rocksdb.allow_no_primary_key_with_sk : MDEV-16639 - Server crash -rocksdb.autoinc_crash_safe_partition : MDEV-16639, MDEV-16637 - Server crash -rocksdb.autoinc_vars_thread : MDEV-16573 - Debug sync timed out -rocksdb.bloomfilter2 : MDEV-16564 - Wrong result -rocksdb.deadlock : MDEV-16033 - Timeout -rocksdb.drop_index_inplace : MDEV-14162 - Crash on shutdown -rocksdb.drop_table : MDEV-14308 - Timeout -rocksdb.drop_table3 : MDEV-16949 - Server crash -rocksdb.dup_key_update : MDEV-17284 - Wrong result -rocksdb.locking_issues : MDEV-14464 - Wrong result -rocksdb.mariadb_ignore_dirs : MDEV-16639 - Server crash -rocksdb.mariadb_port_fixes : MDEV-16387 - Wrong plan -rocksdb.max_open_files : MDEV-16639 - Server crash -rocksdb.perf_context : MDEV-17285 - Wrong results -rocksdb.rocksdb_cf_options : MDEV-16639 - Server crash -rocksdb.rocksdb_cf_per_partition : MDEV-16636 - Wrong result -rocksdb.rocksdb_parts : MDEV-13843 - Wrong result -rocksdb.ttl_secondary : MDEV-16943 - Timeout -rocksdb.unique_check : MDEV-16576 - Wrong errno -rocksdb.use_direct_reads_writes : MDEV-16646 - Server crash -rocksdb.write_sync : MDEV-16965 - WRong result - -#----------------------------------------------------------------------- - -rocksdb_rpl.mdev12179 : MDEV-16632 - Crash -rocksdb_rpl.rpl_binlog_xid_count : MDEV-16644 - Crash - -#----------------------------------------------------------------------- - -rocksdb_sys_vars.rocksdb_rate_limiter_bytes_per_sec_basic : MDEV-16639 - Crash - -#----------------------------------------------------------------------- - -roles.create_and_grant_role : MDEV-11772 - wrong result - -#----------------------------------------------------------------------- - -rpl.circular_serverid0 : MDEV-19372 - ASAN heap-use-after-free -rpl.create_or_replace2 : MDEV-19412 - Lost connection to MySQL server -rpl.create_or_replace_mix : MDEV-20523 - Wrong result -rpl.create_or_replace_statement : MDEV-20523 - Wrong result -rpl.create_select : MDEV-14121 - Assertion failure -rpl.last_insert_id : MDEV-10625 - warnings in error log -rpl.rpl_auto_increment : MDEV-10417 - Fails on Mips -rpl.rpl_auto_increment_bug45679 : MDEV-10417 - Fails on Mips -rpl.rpl_auto_increment_update_failure : MDEV-10625 - warnings in error log -rpl.rpl_binlog_errors : MDEV-12742 - Crash -rpl.rpl_binlog_grant : MDEV-21274 - Lost connection at handshake -rpl.rpl_cant_read_event_incident : MDEV-20960 - Abort on shutdown -rpl.rpl_checksum_cache : MDEV-22510 - Server crash -rpl.rpl_circular_for_4_hosts : MDEV-20536 - Server crash -rpl.rpl_colSize : MDEV-16112 - Server crash -rpl.rpl_corruption : MDEV-20527 - Slave stopped with wrong error code -rpl.rpl_ctype_latin1 : MDEV-14813 - Wrong result on Mac -rpl.rpl_ddl : MDEV-10417 - Fails on Mips -rpl.rpl_domain_id_filter_io_crash : MDEV-12729 - Timeout in include file, MDEV-13677 - Server crash -rpl.rpl_domain_id_filter_master_crash : MDEV-19043 - Table marked as crashed -rpl.rpl_domain_id_filter_restart : MDEV-10684 - Wrong result; MDEV-19043 - Table marked as crashed -rpl.rpl_drop_db_fail : MDEV-16898 - Slave fails to start -rpl.rpl_extra_col_master_innodb : MDEV-16570 - Extra warning -rpl.rpl_extra_col_master_myisam : MDEV-23372 - Extra warning -rpl.rpl_flushlog_loop : MDEV-21570 - Server crash -rpl.rpl_get_lock : MDEV-19368 - mysqltest failed but provided no output -rpl.rpl_gtid_basic : MDEV-10681 - server startup problem -rpl.rpl_gtid_crash : MDEV-13643 - Lost connection -rpl.rpl_gtid_delete_domain : MDEV-14463 - Timeout -rpl.rpl_gtid_errorhandling : MDEV-13261 - Crash -rpl.rpl_gtid_mdev9033 : MDEV-10680 - warnings -rpl.rpl_gtid_reconnect : MDEV-14497 - Crash -rpl.rpl_gtid_startpos : MDEV-20141 - mysqltest failed but provided no output -rpl.rpl_gtid_stop_start : MDEV-10629 - Crash on shutdown, MDEV-12629 - Valgrind warnings -rpl.rpl_gtid_until : MDEV-10625 - warnings in error log -rpl.rpl_innodb_bug30888 : MDEV-10417 - Fails on Mips -rpl.rpl_insert : MDEV-9329 - Fails on Ubuntu/s390x -rpl.rpl_insert_delayed : MDEV-9329 - Fails on Ubuntu/s390x -rpl.rpl_insert_id : MDEV-15197 - Wrong result -rpl.rpl_insert_id_pk : MDEV-16567 - Assertion failure -rpl.rpl_insert_ignore : MDEV-14365 - Lost connection to MySQL server during query -rpl.rpl_invoked_features : MDEV-10417 - Fails on Mips -rpl.rpl_ipv4_as_ipv6 : MDEV-20147 - Incorrect checksum for freed object -rpl.rpl_mariadb_slave_capability : MDEV-11018 - Extra lines in binlog -rpl.rpl_mdev12179 : MDEV-19043 - Table marked as crashed -rpl.rpl_mdev6020 : MDEV-23426 - Server crash, ASAN failures; MDEV-15272 - Server crash -rpl.rpl_mixed_mixing_engines : MDEV-21266 - Timeout -rpl.rpl_multi_engine : MDEV-23419 - Server crash -rpl.rpl_non_direct_row_mixing_engines : MDEV-16561 - Timeout in master_pos_wait -rpl.rpl_old_master : MDEV-22956 - Assertion failure -rpl.rpl_parallel : MDEV-10653 - Timeouts -rpl.rpl_parallel_conflicts : MDEV-15272 - Server crash -rpl.rpl_parallel_multilevel : MDEV-20160 - Server crash -rpl.rpl_parallel_multilevel2 : MDEV-14723 - Timeout -rpl.rpl_parallel_optimistic : MDEV-15278 - Failed to sync with master -rpl.rpl_parallel_optimistic_nobinlog : MDEV-15278 - Failed to sync with master -rpl.rpl_parallel_optimistic_until : MDEV-23021 - Query didn't return a result set -rpl.rpl_parallel_retry : MDEV-11119 - Crash; MDEV-17109 - Timeout -rpl.rpl_parallel_stop_on_con_kill : MDEV-24110 - Slave crash -rpl.rpl_parallel_temptable : MDEV-10356 - Crash; MDEV-19076 - Wrong result -rpl.rpl_partition_innodb : MDEV-10417 - Fails on Mips -rpl.rpl_password_boundaries : MDEV-11534 - Slave IO warnings -rpl.rpl_rewrt_db : MDEV-24060 - Server did not start -rpl.rpl_row_001 : MDEV-16653 - MTR's internal check fails -rpl.rpl_row_basic_11bugs : MDEV-12171 - Server failed to start -rpl.rpl_row_basic_2myisam : MDEV-13875 - command "diff_files" failed -rpl.rpl_row_corruption : MDEV-21569 - mutex: LOCK_global_system_variables unlocking -rpl.rpl_row_drop_create_temp_table : MDEV-14487 - Wrong result -rpl.rpl_row_end_of_statement_loss : MDEV-21237 - Server crash -rpl.rpl_row_img_blobs : MDEV-13875 - command "diff_files" failed -rpl.rpl_row_img_eng_min : MDEV-13875 - diff_files failed -rpl.rpl_row_img_eng_noblob : MDEV-13875 - command "diff_files" failed -rpl.rpl_row_index_choice : MDEV-15196 - Slave crash -rpl.rpl_row_sp001 : MDEV-9329 - Fails on Ubuntu/s390x -rpl.rpl_row_until : MDEV-14052 - Master will not send events with checksum -rpl.rpl_semi_sync : MDEV-24118 - Assertion failure -rpl.rpl_semi_sync_event_after_sync : MDEV-11806 - warnings -rpl.rpl_semi_sync_skip_repl : MDEV-23371 - Server crash -rpl.rpl_semi_sync_uninstall_plugin : MDEV-7140 - Assorted failures; MDEV-24561 - Wrong usage of mutex -rpl.rpl_semi_sync_wait_point : MDEV-11807 - timeout in wait condition -rpl.rpl_show_slave_hosts : MDEV-10681 - Crash -rpl.rpl_shutdown_wait_slaves : MDEV-22517 - Timeout on sync_with_master -rpl.rpl_skip_replication : MDEV-23372 - Extra warning -rpl.rpl_slave_load_tmpdir_not_exist : MDEV-23372 - Extra warning -rpl.rpl_slow_query_log : MDEV-13250 - Test abort -rpl.rpl_sp_effects : MDEV-13249 - Crash -rpl.rpl_start_stop_slave : MDEV-13567 - Sync slave timeout -rpl.rpl_stm_relay_ign_space : MDEV-14360 - Test assertion -rpl.rpl_stm_start_stop_slave : MDEV-23180 - ASAN heap-use-after-free -rpl.rpl_stm_stop_middle_group : MDEV-13791 - Server crash -rpl.rpl_sync : MDEV-10633 - Database page corruption -rpl.rpl_temporary_error2 : MDEV-10634 - Wrong number of retries -rpl.rpl_test_framework : MDEV-19368 - mysqltest failed but provided no output -rpl.rpl_trigger : MDEV-18055 - Wrong result -rpl.rpl_truncate_3innodb : MDEV-19454 - Syntax error -rpl.rpl_upgrade_master_info : MDEV-16567 - Assertion failure -rpl.rpl_user_variables : MDEV-20522 - Wrong result -rpl.rpl_variables : MDEV-20150 - Server crash -rpl.sec_behind_master-5114 : MDEV-13878 - Wrong result - -#----------------------------------------------------------------------- - -rpl/extra/rpl_tests.* : MDEV-10994 - Not maintained - -#----------------------------------------------------------------------- - -s3.replication_partition : MDEV-24087 - Replication failure - -#----------------------------------------------------------------------- - -sphinx.* : MDEV-10986 - Tests have not been maintained -sphinx.sphinx : MDEV-10986 - Sporadic failures -sphinx.union-5539 : MDEV-10986 - Sporadic failures - -#----------------------------------------------------------------------- - -spider.* : MDEV-9329, MDEV-18737 - tests are too memory-consuming -spider.basic_sql : MDEV-11186 - Internal check fails - -#----------------------------------------------------------------------- - -spider/bg.* : MDEV-24059 - Timeout -spider/bg.ha : MDEV-9329 - failures on s390x -spider/bg.ha_part : MDEV-9329 - Fails on Ubuntu/s390x -spider/bg.spider3_fixes : MDEV-12639 - Syntax error -spider/bg.spider3_fixes_part : MDEV-24809 - Timeout -spider/bg.spider_fixes : MDEV-9329 - failures on s390x -spider/bg.vp_fixes : MDEV-9329 - Fails on Ubuntu/s390x - -#----------------------------------------------------------------------- - -spider/handler.* : MDEV-10987, MDEV-10990 - Tests have not been maintained - -#----------------------------------------------------------------------- - -sql_sequence.concurrent_create : MDEV-16635 - Server crash -sql_sequence.kill : MDEV-23393 - Server crash -sql_sequence.read_only : MDEV-22956 - Failing assertion - -#----------------------------------------------------------------------- - -storage_engine.* : Tests are not always timely maintained - -#----------------------------------------------------------------------- - -stress.ddl_innodb : MDEV-10635 - Testcase timeout -stress.misc : MDEV-23420 - Server crash - -#----------------------------------------------------------------------- - -sys_vars.autocommit_func2 : MDEV-9329 - Fails on Ubuntu/s390x -sys_vars.host_cache_size_auto : MDEV-20112 - Wrong result -sys_vars.innodb_buffer_pool_dump_at_shutdown_basic : MDEV-14280 - Unexpected error -sys_vars.innodb_checksum_algorithm_basic : MDEV-21568 - Errno: 2000 -sys_vars.innodb_fatal_semaphore_wait_threshold : MDEV-22961 - Server failed to dissapear -sys_vars.innodb_flush_method_func : MDEV-24810 - Server failed to restart -sys_vars.keep_files_on_create_basic : MDEV-10676 - timeout -sys_vars.log_slow_admin_statements_func : MDEV-12235 - Server crash -sys_vars.slow_query_log_func : MDEV-14273 - Wrong result -sys_vars.thread_cache_size_func : MDEV-11775 - Wrong result -sys_vars.wait_timeout_func : MDEV-12896 - Wrong result - -unit.conc_basic-t : MDEV-15286 - not ok 7 - test_reconnect_maxpackage -unit.conc_bulk1 : MDEV-19410 - LeakSanitizer: detected memory leaks -unit.conc_errors : MDEV-18634 - ASAN global-buffer-overflow -unit.conc_misc : MDEV-14811 - not ok 12 - test_conc49 -unit.conc_ps_bugs : MDEV-13252 - not ok 44 test_bug4236 -unit.ma_pagecache_consist_64kRD : MDEV-19367 - AddressSanitizer CHECK failed -unit.ma_pagecache_consist_64kWR : MDEV-19367 - AddressSanitizer CHECK failed -unit.ma_test_loghandler : MDEV-10638 - record read not ok -unit.mf_iocache : MDEV-20952 - ASAN stack-buffer-overflow - -#----------------------------------------------------------------------- - -vcol.not_supported : MDEV-10639 - Testcase timeout -vcol.vcol_keys_innodb : MDEV-10639 - Testcase timeout -vcol.vcol_misc : MDEV-16651 - Wrong error message - -#----------------------------------------------------------------------- - -versioning.replace : MDEV-22960 - OS errors, crash -versioning.update : MDEV-22475 - Wrong result code - -#----------------------------------------------------------------------- - -wsrep.foreign_key : MDEV-14725 - WSREP has not yet prepared node -wsrep.mdev_6832 : MDEV-14195 - Check testcase failed -wsrep.pool_of_threads : MDEV-17345 - WSREP has not yet prepared node for application use - -#----------------------------------------------------------------------- - -wsrep_info.plugin : MDEV-22470 - WSREP: no nodes coming from prim view, prim not possible From 89342a3bd5e127a9060ec2a938cf36479388fcb1 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 9 Jun 2021 18:32:09 +0200 Subject: [PATCH 052/251] change maturity to gamma --- VERSION | 2 +- mysql-test/suite/sys_vars/r/sysvars_star.result | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index b9abaef7e76..ecd6263f7b4 100644 --- a/VERSION +++ b/VERSION @@ -1,4 +1,4 @@ MYSQL_VERSION_MAJOR=10 MYSQL_VERSION_MINOR=6 MYSQL_VERSION_PATCH=2 -SERVER_MATURITY=beta +SERVER_MATURITY=gamma diff --git a/mysql-test/suite/sys_vars/r/sysvars_star.result b/mysql-test/suite/sys_vars/r/sysvars_star.result index b03e288f04e..54af0aa3014 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_star.result +++ b/mysql-test/suite/sys_vars/r/sysvars_star.result @@ -60,7 +60,7 @@ VARIABLE_NAME PLUGIN_MATURITY SESSION_VALUE NULL GLOBAL_VALUE alpha GLOBAL_VALUE_ORIGIN CONFIG -DEFAULT_VALUE alpha +DEFAULT_VALUE beta VARIABLE_SCOPE GLOBAL VARIABLE_TYPE ENUM VARIABLE_COMMENT The lowest desirable plugin maturity. Plugins less mature than that will not be installed or loaded From 3648b333c74b5c36776db30a4370bafa28a73ef0 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 9 Jun 2021 18:31:23 +0200 Subject: [PATCH 053/251] cleanup: formatting also avoid an oxymoron of using `MYSQL_PLUGIN_IMPORT` under `#ifdef MYSQL_SERVER`, and empty_clex_str is so trivial that a plugin can define it if needed. --- plugin/type_inet/sql_type_inet.cc | 9 ++---- sql/field.cc | 6 ++-- sql/field.h | 11 +++----- sql/item.h | 18 ++++-------- sql/sql_base.cc | 46 +++++++++++++++---------------- sql/sql_insert.cc | 11 ++++---- sql/sql_lex.h | 2 +- sql/sql_load.cc | 4 +-- sql/sql_parse.cc | 6 ++-- sql/sql_prepare.cc | 10 ++----- sql/sql_string.cc | 7 ++--- sql/sql_string.h | 21 ++++++-------- storage/oqgraph/ha_oqgraph.cc | 4 ++- 13 files changed, 65 insertions(+), 90 deletions(-) diff --git a/plugin/type_inet/sql_type_inet.cc b/plugin/type_inet/sql_type_inet.cc index 822502053e0..8ae6fbfaeee 100644 --- a/plugin/type_inet/sql_type_inet.cc +++ b/plugin/type_inet/sql_type_inet.cc @@ -1342,15 +1342,13 @@ Type_handler_inet6::character_or_binary_string_to_native(THD *thd, Inet6_null tmp(*str); if (tmp.is_null()) thd->push_warning_wrong_value(Sql_condition::WARN_LEVEL_WARN, - name().ptr(), - ErrConvString(str).ptr()); + name().ptr(), ErrConvString(str).ptr()); return tmp.is_null() || tmp.to_native(to); } bool -Type_handler_inet6::Item_save_in_value(THD *thd, - Item *item, +Type_handler_inet6::Item_save_in_value(THD *thd, Item *item, st_value *value) const { value->m_type= DYN_COL_STRING; @@ -1366,8 +1364,7 @@ Type_handler_inet6::Item_save_in_value(THD *thd, FROM t1; */ thd->push_warning_wrong_value(Sql_condition::WARN_LEVEL_WARN, - name().ptr(), - ErrConvString(str).ptr()); + name().ptr(), ErrConvString(str).ptr()); value->m_type= DYN_COL_NULL; return true; } diff --git a/sql/field.cc b/sql/field.cc index 38c3e1ea70e..1ad945a97b6 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -1891,8 +1891,7 @@ void Field::copy_from_tmp(int row_offset) bool Field::send(Protocol *protocol) { - char buff[MAX_FIELD_WIDTH]; - String tmp(buff,sizeof(buff),charset()); + StringBuffer tmp(charset()); val_str(&tmp); return protocol->store(tmp.ptr(), tmp.length(), tmp.charset()); } @@ -9401,8 +9400,7 @@ String *Field_set::val_str(String *val_buffer, { if (val_buffer->length()) val_buffer->append(&field_separator, 1, &my_charset_latin1); - String str(typelib->type_names[bitnr], - typelib->type_lengths[bitnr], + String str(typelib->type_names[bitnr], typelib->type_lengths[bitnr], field_charset()); val_buffer->append(str); } diff --git a/sql/field.h b/sql/field.h index 08a334e5a6f..e5f47300ca7 100644 --- a/sql/field.h +++ b/sql/field.h @@ -4805,14 +4805,11 @@ private: class Field_set final :public Field_enum { public: Field_set(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, - uchar null_bit_arg, - enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg, - uint32 packlength_arg, + uchar null_bit_arg, enum utype unireg_check_arg, + const LEX_CSTRING *field_name_arg, uint32 packlength_arg, const TYPELIB *typelib_arg, const DTCollation &collation) - :Field_enum(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, - unireg_check_arg, field_name_arg, - packlength_arg, - typelib_arg, collation), + :Field_enum(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, unireg_check_arg, + field_name_arg, packlength_arg, typelib_arg, collation), empty_set_string("", 0, collation.collation) { flags=(flags & ~ENUM_FLAG) | SET_FLAG; diff --git a/sql/item.h b/sql/item.h index 8aede90e988..8ab4c8a3bd1 100644 --- a/sql/item.h +++ b/sql/item.h @@ -7517,27 +7517,21 @@ public: Item_type_holder do not need cleanup() because its time of live limited by single SP/PS execution. */ -class Item_type_holder: public Item, - public Type_handler_hybrid_field_type +class Item_type_holder: public Item, public Type_handler_hybrid_field_type { protected: const TYPELIB *enum_set_typelib; public: - Item_type_holder(THD *thd, - Item *item, - const Type_handler *handler, - const Type_all_attributes *attr, - bool maybe_null_arg) - :Item(thd), - Type_handler_hybrid_field_type(handler), + Item_type_holder(THD *thd, Item *item, const Type_handler *handler, + const Type_all_attributes *attr, bool maybe_null_arg) + :Item(thd), Type_handler_hybrid_field_type(handler), enum_set_typelib(attr->get_typelib()) { name= item->name; Type_std_attributes::set(*attr); set_maybe_null(maybe_null_arg); - copy_flags(item, - item_base_t::IS_EXPLICIT_NAME | - item_base_t::IS_IN_WITH_CYCLE); + copy_flags(item, item_base_t::IS_EXPLICIT_NAME | + item_base_t::IS_IN_WITH_CYCLE); } const Type_handler *type_handler() const override diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 68524cbb1f2..1ba01671201 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -4532,9 +4532,9 @@ error: @retval TRUE Failure (OOM). */ -bool DML_prelocking_strategy:: -handle_routine(THD *thd, Query_tables_list *prelocking_ctx, - Sroutine_hash_entry *rt, sp_head *sp, bool *need_prelocking) +bool DML_prelocking_strategy::handle_routine(THD *thd, + Query_tables_list *prelocking_ctx, Sroutine_hash_entry *rt, + sp_head *sp, bool *need_prelocking) { /* We assume that for any "CALL proc(...)" statement sroutines_list will @@ -4668,8 +4668,8 @@ prepare_fk_prelocking_list(THD *thd, Query_tables_list *prelocking_ctx, // FK_OPTION_RESTRICT and FK_OPTION_NO_ACTION only need read access thr_lock_type lock_type; - if ((op & (1 << TRG_EVENT_DELETE) && fk_modifies_child(fk->delete_method)) - || (op & (1 << TRG_EVENT_UPDATE) && fk_modifies_child(fk->update_method))) + if ((op & trg2bit(TRG_EVENT_DELETE) && fk_modifies_child(fk->delete_method)) + || (op & trg2bit(TRG_EVENT_UPDATE) && fk_modifies_child(fk->update_method))) lock_type= TL_WRITE_ALLOW_WRITE; else lock_type= TL_READ; @@ -4715,9 +4715,9 @@ prepare_fk_prelocking_list(THD *thd, Query_tables_list *prelocking_ctx, @retval TRUE Failure (OOM). */ -bool DML_prelocking_strategy:: -handle_table(THD *thd, Query_tables_list *prelocking_ctx, - TABLE_LIST *table_list, bool *need_prelocking) +bool DML_prelocking_strategy::handle_table(THD *thd, + Query_tables_list *prelocking_ctx, TABLE_LIST *table_list, + bool *need_prelocking) { DBUG_ENTER("handle_table"); TABLE *table= table_list->table; @@ -4846,9 +4846,9 @@ err: @retval TRUE Failure (OOM). */ -bool DML_prelocking_strategy:: -handle_view(THD *thd, Query_tables_list *prelocking_ctx, - TABLE_LIST *table_list, bool *need_prelocking) +bool DML_prelocking_strategy::handle_view(THD *thd, + Query_tables_list *prelocking_ctx, TABLE_LIST *table_list, + bool *need_prelocking) { if (table_list->view->uses_stored_routines()) { @@ -4886,9 +4886,9 @@ handle_view(THD *thd, Query_tables_list *prelocking_ctx, @retval TRUE Failure (OOM). */ -bool Lock_tables_prelocking_strategy:: -handle_table(THD *thd, Query_tables_list *prelocking_ctx, - TABLE_LIST *table_list, bool *need_prelocking) +bool Lock_tables_prelocking_strategy::handle_table(THD *thd, + Query_tables_list *prelocking_ctx, TABLE_LIST *table_list, + bool *need_prelocking) { TABLE_LIST **last= prelocking_ctx->query_tables_last; @@ -4919,9 +4919,9 @@ handle_table(THD *thd, Query_tables_list *prelocking_ctx, a simple view, but one that uses stored routines. */ -bool Alter_table_prelocking_strategy:: -handle_routine(THD *thd, Query_tables_list *prelocking_ctx, - Sroutine_hash_entry *rt, sp_head *sp, bool *need_prelocking) +bool Alter_table_prelocking_strategy::handle_routine(THD *thd, + Query_tables_list *prelocking_ctx, Sroutine_hash_entry *rt, + sp_head *sp, bool *need_prelocking) { return FALSE; } @@ -4945,9 +4945,9 @@ handle_routine(THD *thd, Query_tables_list *prelocking_ctx, @retval TRUE Failure (OOM). */ -bool Alter_table_prelocking_strategy:: -handle_table(THD *thd, Query_tables_list *prelocking_ctx, - TABLE_LIST *table_list, bool *need_prelocking) +bool Alter_table_prelocking_strategy::handle_table(THD *thd, + Query_tables_list *prelocking_ctx, TABLE_LIST *table_list, + bool *need_prelocking) { return FALSE; } @@ -4960,9 +4960,9 @@ handle_table(THD *thd, Query_tables_list *prelocking_ctx, to be materialized. */ -bool Alter_table_prelocking_strategy:: -handle_view(THD *thd, Query_tables_list *prelocking_ctx, - TABLE_LIST *table_list, bool *need_prelocking) +bool Alter_table_prelocking_strategy::handle_view(THD *thd, + Query_tables_list *prelocking_ctx, TABLE_LIST *table_list, + bool *need_prelocking) { return FALSE; } diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 9bdd40010df..24ffad7368a 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -2977,8 +2977,8 @@ public: }; -bool Delayed_prelocking_strategy:: -handle_table(THD *thd, Query_tables_list *prelocking_ctx, +bool Delayed_prelocking_strategy::handle_table(THD *thd, + Query_tables_list *prelocking_ctx, TABLE_LIST *table_list, bool *need_prelocking) { DBUG_ASSERT(table_list->lock_type == TL_WRITE_DELAYED); @@ -2992,10 +2992,9 @@ handle_table(THD *thd, Query_tables_list *prelocking_ctx, } -bool Delayed_prelocking_strategy:: -handle_routine(THD *thd, Query_tables_list *prelocking_ctx, - Sroutine_hash_entry *rt, sp_head *sp, - bool *need_prelocking) +bool Delayed_prelocking_strategy::handle_routine(THD *thd, + Query_tables_list *prelocking_ctx, Sroutine_hash_entry *rt, + sp_head *sp, bool *need_prelocking) { /* LEX used by the delayed insert thread has no routines. */ DBUG_ASSERT(0); diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 94575c074ef..45e5f2381bd 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -388,7 +388,7 @@ void binlog_unsafe_map_init(); #ifdef MYSQL_SERVER extern const LEX_STRING empty_lex_str; -extern MYSQL_PLUGIN_IMPORT const LEX_CSTRING empty_clex_str; +extern const LEX_CSTRING empty_clex_str; extern const LEX_CSTRING star_clex_str; extern const LEX_CSTRING param_clex_str; diff --git a/sql/sql_load.cc b/sql/sql_load.cc index 0e3cdaac569..49de7f73cab 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -51,11 +51,11 @@ public: int level; String field; String value; - XML_TAG(int l, String f, String v); + XML_TAG(int l, const String &f, const String &v); }; -XML_TAG::XML_TAG(int l, String f, String v) +XML_TAG::XML_TAG(int l, const String &f, const String &v) { level= l; field.append(f); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 04af54ae8d9..c99d3fb3e75 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -10364,10 +10364,8 @@ bool parse_sql(THD *thd, Parser_state *parser_state, /* Parse the query. */ - bool mysql_parse_status= - ((thd->variables.sql_mode & MODE_ORACLE) ? - ORAparse(thd) : - MYSQLparse(thd)) != 0; + bool mysql_parse_status= thd->variables.sql_mode & MODE_ORACLE + ? ORAparse(thd) : MYSQLparse(thd); DBUG_ASSERT(opt_bootstrap || mysql_parse_status || thd->lex->select_stack_top == 0); thd->lex->current_select= thd->lex->first_select_lex(); diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 1db04c4656f..2b6cbce98e1 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -5002,8 +5002,7 @@ bool Prepared_statement::execute(String *expanded_query, bool open_cursor) /* Allocate query. */ if (expanded_query->length() && - alloc_query(thd, (char*) expanded_query->ptr(), - expanded_query->length())) + alloc_query(thd, expanded_query->ptr(), expanded_query->length())) { my_error(ER_OUTOFMEMORY, MYF(ME_FATAL), expanded_query->length()); goto error; @@ -5040,12 +5039,9 @@ bool Prepared_statement::execute(String *expanded_query, bool open_cursor) if (query_cache_send_result_to_client(thd, thd->query(), thd->query_length()) <= 0) { - MYSQL_QUERY_EXEC_START(thd->query(), - thd->thread_id, - thd->get_db(), + MYSQL_QUERY_EXEC_START(thd->query(), thd->thread_id, thd->get_db(), &thd->security_ctx->priv_user[0], - (char *) thd->security_ctx->host_or_ip, - 1); + (char *) thd->security_ctx->host_or_ip, 1); error= mysql_execute_command(thd); MYSQL_QUERY_EXEC_DONE(error); } diff --git a/sql/sql_string.cc b/sql/sql_string.cc index 053591d8c4e..ff81a5f5ca4 100644 --- a/sql/sql_string.cc +++ b/sql/sql_string.cc @@ -848,10 +848,9 @@ bool Binary_string::copy_printable_hhhh(CHARSET_INFO *to_cs, */ -int sortcmp(const String *s,const String *t, CHARSET_INFO *cs) +int sortcmp(const Binary_string *s, const Binary_string *t, CHARSET_INFO *cs) { - return cs->strnncollsp(s->ptr(), s->length(), - t->ptr(), t->length()); + return cs->strnncollsp(s->ptr(), s->length(), t->ptr(), t->length()); } @@ -873,7 +872,7 @@ int sortcmp(const String *s,const String *t, CHARSET_INFO *cs) */ -int stringcmp(const String *s,const String *t) +int stringcmp(const Binary_string *s, const Binary_string *t) { uint32 s_len=s->length(),t_len=t->length(),len=MY_MIN(s_len,t_len); int cmp= len ? memcmp(s->ptr(), t->ptr(), len) : 0; diff --git a/sql/sql_string.h b/sql/sql_string.h index 76079f99f8d..d7661605492 100644 --- a/sql/sql_string.h +++ b/sql/sql_string.h @@ -42,10 +42,11 @@ typedef struct st_mem_root MEM_ROOT; #define ASSERT_LENGTH(A) DBUG_ASSERT(str_length + (uint32) (A) <= Alloced_length) #include "pack.h" -int sortcmp(const String *a,const String *b, CHARSET_INFO *cs); +class Binary_string; +int sortcmp(const Binary_string *s, const Binary_string *t, CHARSET_INFO *cs); +int stringcmp(const Binary_string *s, const Binary_string *t); String *copy_if_not_alloced(String *a,String *b,uint32 arg_length); -inline uint32 copy_and_convert(char *to, size_t to_length, - CHARSET_INFO *to_cs, +inline uint32 copy_and_convert(char *to, size_t to_length, CHARSET_INFO *to_cs, const char *from, size_t from_length, CHARSET_INFO *from_cs, uint *errors) { @@ -787,8 +788,7 @@ class String: public Charset, public Binary_string { public: String() { } - String(size_t length_arg) - :Binary_string(length_arg) + String(size_t length_arg) :Binary_string(length_arg) { } /* NOTE: If one intend to use the c_ptr() method, the following two @@ -796,16 +796,13 @@ public: room for zero termination). */ String(const char *str, size_t len, CHARSET_INFO *cs) - :Charset(cs), - Binary_string(str, len) + :Charset(cs), Binary_string(str, len) { } String(char *str, size_t len, CHARSET_INFO *cs) - :Charset(cs), - Binary_string(str, len) + :Charset(cs), Binary_string(str, len) { } String(const String &str) - :Charset(str), - Binary_string(str) + :Charset(str), Binary_string(str) { } void set(String &str,size_t offset,size_t arg_length) @@ -994,8 +991,6 @@ public: } void strip_sp(); - friend int sortcmp(const String *a,const String *b, CHARSET_INFO *cs); - friend int stringcmp(const String *a,const String *b); friend String *copy_if_not_alloced(String *a,String *b,uint32 arg_length); friend class Field; uint32 numchars() const diff --git a/storage/oqgraph/ha_oqgraph.cc b/storage/oqgraph/ha_oqgraph.cc index c2f52e2e5a2..39d10699d32 100644 --- a/storage/oqgraph/ha_oqgraph.cc +++ b/storage/oqgraph/ha_oqgraph.cc @@ -80,6 +80,8 @@ static my_bool g_allow_create_integer_latch = FALSE; using namespace open_query; +static const LEX_CSTRING empty_lex_cstring= {"", 0}; + // Table of varchar latch operations. // In the future this needs to be refactactored to live somewhere else struct oqgraph_latch_op_table { const char *key; int latch; }; @@ -623,7 +625,7 @@ int ha_oqgraph::open(const char *name, int mode, uint test_if_locked) } if (enum open_frm_error err= open_table_from_share(thd, share, - &empty_clex_str, + &empty_lex_cstring, (uint) (HA_OPEN_KEYFILE | HA_TRY_READ_ONLY), EXTRA_RECORD, thd->open_options, edges, FALSE)) From 59b51e6aa7d0b91e4c5678a116e9ba695238853c Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 2 Oct 2020 00:03:20 +0200 Subject: [PATCH 054/251] cleanup: Field_set::empty_set_string in particular, it overwrites pre-allocated buffer in val_buffer, so following val_buffer->append()'s cause totally unnecessary mallocs. --- sql/field.cc | 10 ---------- sql/field.h | 5 +---- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/sql/field.cc b/sql/field.cc index 1ad945a97b6..561e3f9c985 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -9381,16 +9381,6 @@ String *Field_set::val_str(String *val_buffer, ulonglong tmp=(ulonglong) Field_enum::val_int(); uint bitnr=0; - /* - Some callers expect *val_buffer to contain the result, - so we assign to it, rather than doing 'return &empty_set_string. - */ - *val_buffer= empty_set_string; - if (tmp == 0) - { - return val_buffer; - } - val_buffer->set_charset(field_charset()); val_buffer->length(0); diff --git a/sql/field.h b/sql/field.h index e5f47300ca7..4b64742b7b3 100644 --- a/sql/field.h +++ b/sql/field.h @@ -4809,8 +4809,7 @@ public: const LEX_CSTRING *field_name_arg, uint32 packlength_arg, const TYPELIB *typelib_arg, const DTCollation &collation) :Field_enum(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, unireg_check_arg, - field_name_arg, packlength_arg, typelib_arg, collation), - empty_set_string("", 0, collation.collation) + field_name_arg, packlength_arg, typelib_arg, collation) { flags=(flags & ~ENUM_FLAG) | SET_FLAG; } @@ -4833,8 +4832,6 @@ public: { return &type_handler_set; } bool has_charset() const override { return true; } Binlog_type_info binlog_type_info() const override; -private: - const String empty_set_string; }; From abc3889f1cf0514615007e44cef6672ed8813ff6 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 28 Sep 2020 10:51:18 +0200 Subject: [PATCH 055/251] cleanup: rename Protocol::store() to Protocol::store_datetime() to match the naming pattern of all other Protocol::store_xxx() methods --- sql/field.cc | 8 ++++---- sql/protocol.cc | 6 +++--- sql/protocol.h | 8 ++++---- sql/sql_show.cc | 2 +- sql/sql_type.cc | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/sql/field.cc b/sql/field.cc index 561e3f9c985..37d16d33212 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -5459,7 +5459,7 @@ bool Field_timestamp0::send(Protocol *protocol) { MYSQL_TIME ltime; Field_timestamp0::get_date(<ime, date_mode_t(0)); - return protocol->store(<ime, 0); + return protocol->store_datetime(<ime, 0); } @@ -5619,7 +5619,7 @@ bool Field_timestamp_with_dec::send(Protocol *protocol) { MYSQL_TIME ltime; Field_timestamp::get_date(<ime, date_mode_t(0)); - return protocol->store(<ime, dec); + return protocol->store_datetime(<ime, dec); } @@ -6906,7 +6906,7 @@ bool Field_datetime0::send(Protocol *protocol) { MYSQL_TIME tm; Field_datetime0::get_date(&tm, date_mode_t(0)); - return protocol->store(&tm, 0); + return protocol->store_datetime(&tm, 0); } @@ -7034,7 +7034,7 @@ bool Field_datetime_with_dec::send(Protocol *protocol) { MYSQL_TIME ltime; get_date(<ime, date_mode_t(0)); - return protocol->store(<ime, dec); + return protocol->store_datetime(<ime, dec); } diff --git a/sql/protocol.cc b/sql/protocol.cc index 70b526b581f..c0a5f2327a0 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -1589,7 +1589,7 @@ bool Protocol_text::store(Field *field) } -bool Protocol_text::store(MYSQL_TIME *tm, int decimals) +bool Protocol_text::store_datetime(MYSQL_TIME *tm, int decimals) { #ifndef DBUG_OFF DBUG_ASSERT(valid_handler(field_pos, PROTOCOL_SEND_DATETIME)); @@ -1807,7 +1807,7 @@ bool Protocol_binary::store(Field *field) } -bool Protocol_binary::store(MYSQL_TIME *tm, int decimals) +bool Protocol_binary::store_datetime(MYSQL_TIME *tm, int decimals) { char buff[12],*pos; uint length; @@ -1841,7 +1841,7 @@ bool Protocol_binary::store_date(MYSQL_TIME *tm) { tm->hour= tm->minute= tm->second=0; tm->second_part= 0; - return Protocol_binary::store(tm, 0); + return Protocol_binary::store_datetime(tm, 0); } diff --git a/sql/protocol.h b/sql/protocol.h index 1beb1175a11..0a309ee75be 100644 --- a/sql/protocol.h +++ b/sql/protocol.h @@ -138,7 +138,7 @@ public: CHARSET_INFO *fromcs, CHARSET_INFO *tocs)=0; virtual bool store_float(float from, uint32 decimals)=0; virtual bool store_double(double from, uint32 decimals)=0; - virtual bool store(MYSQL_TIME *time, int decimals)=0; + virtual bool store_datetime(MYSQL_TIME *time, int decimals)=0; virtual bool store_date(MYSQL_TIME *time)=0; virtual bool store_time(MYSQL_TIME *time, int decimals)=0; virtual bool store(Field *field)=0; @@ -217,7 +217,7 @@ public: bool store_decimal(const my_decimal *) override; bool store_str(const char *from, size_t length, CHARSET_INFO *fromcs, CHARSET_INFO *tocs) override; - bool store(MYSQL_TIME *time, int decimals) override; + bool store_datetime(MYSQL_TIME *time, int decimals) override; bool store_date(MYSQL_TIME *time) override; bool store_time(MYSQL_TIME *time, int decimals) override; bool store_float(float nr, uint32 decimals) override; @@ -265,7 +265,7 @@ public: bool store_decimal(const my_decimal *) override; bool store_str(const char *from, size_t length, CHARSET_INFO *fromcs, CHARSET_INFO *tocs) override; - bool store(MYSQL_TIME *time, int decimals) override; + bool store_datetime(MYSQL_TIME *time, int decimals) override; bool store_date(MYSQL_TIME *time) override; bool store_time(MYSQL_TIME *time, int decimals) override; bool store_float(float nr, uint32 decimals) override; @@ -316,7 +316,7 @@ public: { return false; } - bool store(MYSQL_TIME *, int) override { return false; } + bool store_datetime(MYSQL_TIME *, int) override { return false; } bool store_date(MYSQL_TIME *) override { return false; } bool store_time(MYSQL_TIME *, int) override { return false; } bool store_float(float, uint32) override { return false; } diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 53c5f6d741d..e2ffc3c5da9 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -9840,7 +9840,7 @@ static bool show_create_trigger_impl(THD *thd, Trigger *trigger) thd->variables.time_zone->gmt_sec_to_TIME(×tamp, (my_time_t)(trigger->create_time/100)); timestamp.second_part= (trigger->create_time % 100) * 10000; - p->store(×tamp, 2); + p->store_datetime(×tamp, 2); } else p->store_null(); diff --git a/sql/sql_type.cc b/sql/sql_type.cc index 0700dcea9d4..36f9c278702 100644 --- a/sql/sql_type.cc +++ b/sql/sql_type.cc @@ -7522,7 +7522,7 @@ bool Type_handler::Item_send_timestamp(Item *item, if (native.is_null()) return protocol->store_null(); native.to_TIME(protocol->thd, &buf->value.m_time); - return protocol->store(&buf->value.m_time, item->decimals); + return protocol->store_datetime(&buf->value.m_time, item->decimals); } @@ -7532,7 +7532,7 @@ bool Type_handler:: item->get_date(protocol->thd, &buf->value.m_time, Datetime::Options(protocol->thd)); if (!item->null_value) - return protocol->store(&buf->value.m_time, item->decimals); + return protocol->store_datetime(&buf->value.m_time, item->decimals); return protocol->store_null(); } From 4d0b33958df8efb8d5c55ae6c78cfd032a732029 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 13 Oct 2020 14:24:29 +0200 Subject: [PATCH 056/251] don't show DBUG_ASSERT to plugins --- sql/sql_basic_types.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sql/sql_basic_types.h b/sql/sql_basic_types.h index 3200228618f..f592aed05a8 100644 --- a/sql/sql_basic_types.h +++ b/sql/sql_basic_types.h @@ -150,9 +150,11 @@ public: explicit time_round_mode_t(ulonglong mode) :m_mode((value_t) mode) { +#ifdef MYSQL_SERVER DBUG_ASSERT(mode == FRAC_NONE || mode == FRAC_TRUNCATE || mode == FRAC_ROUND); +#endif } // Conversion operators explicit operator ulonglong() const From 773ee80fabc49407578aec011889cd1a927992bf Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 13 Oct 2020 13:29:05 +0200 Subject: [PATCH 057/251] federatedx: ha_federatedx::get_txn -> static --- storage/federatedx/CMakeLists.txt | 4 +--- storage/federatedx/ha_federatedx.h | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/storage/federatedx/CMakeLists.txt b/storage/federatedx/CMakeLists.txt index 67b6c1c96bb..5f983b5d637 100644 --- a/storage/federatedx/CMakeLists.txt +++ b/storage/federatedx/CMakeLists.txt @@ -1,4 +1,2 @@ -SET(FEDERATEDX_PLUGIN_STATIC "federatedx") -SET(FEDERATEDX_PLUGIN_DYNAMIC "ha_federatedx") -SET(FEDERATEDX_SOURCES ha_federatedx.cc federatedx_txn.cc federatedx_io.cc federatedx_io_null.cc federatedx_io_mysql.cc) +SET(FEDERATEDX_SOURCES ha_federatedx.cc federatedx_txn.cc federatedx_io.cc federatedx_io_null.cc federatedx_io_mysql.cc) MYSQL_ADD_PLUGIN(federatedx ${FEDERATEDX_SOURCES} STORAGE_ENGINE) diff --git a/storage/federatedx/ha_federatedx.h b/storage/federatedx/ha_federatedx.h index 38eae265edf..665cb303fba 100644 --- a/storage/federatedx/ha_federatedx.h +++ b/storage/federatedx/ha_federatedx.h @@ -258,7 +258,6 @@ public: void stmt_autocommit(); }; - /* Class definition for the storage engine */ @@ -296,8 +295,7 @@ private: bool records_in_range, bool eq_range); int stash_remote_error(); - federatedx_txn *get_txn(THD *thd, bool no_create= FALSE); - + static federatedx_txn *get_txn(THD *thd, bool no_create= FALSE); static int disconnect(handlerton *hton, MYSQL_THD thd); static int savepoint_set(handlerton *hton, MYSQL_THD thd, void *sv); static int savepoint_rollback(handlerton *hton, MYSQL_THD thd, void *sv); From f4943b4ace129aa4ff4374791dc81c7535679e9e Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 10 Jun 2021 13:43:52 +0200 Subject: [PATCH 058/251] cleanup perfschema.short_options_1 test the test tests whether short options work on the server command line * remove 'show variables' for variables not affected by short options * remove options, that are not short * remove options, that cannot be tested from SQL * in particular, -T12 doesn't affect the test output, but cases ~30sec delay on shutdown * use -W1 as -W2 is the default, so doesn't affect the test output --- mysql-test/suite/perfschema/r/short_option_1.result | 7 +------ mysql-test/suite/perfschema/t/short_option_1-master.opt | 2 +- mysql-test/suite/perfschema/t/short_option_1.test | 4 ---- 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/mysql-test/suite/perfschema/r/short_option_1.result b/mysql-test/suite/perfschema/r/short_option_1.result index 89bdf21cecf..3582375a0a2 100644 --- a/mysql-test/suite/perfschema/r/short_option_1.result +++ b/mysql-test/suite/perfschema/r/short_option_1.result @@ -13,11 +13,6 @@ utf8mb3 show global variables like 'character_set_system'; Variable_name Value character_set_system utf8mb3 -show global variables like 'general_log'; -Variable_name Value -general_log ON -show global variables like 'new'; -Variable_name Value show global variables like 'log_warnings'; Variable_name Value -log_warnings 2 +log_warnings 1 diff --git a/mysql-test/suite/perfschema/t/short_option_1-master.opt b/mysql-test/suite/perfschema/t/short_option_1-master.opt index a9cda7a08ed..13005cd1ee4 100644 --- a/mysql-test/suite/perfschema/t/short_option_1-master.opt +++ b/mysql-test/suite/perfschema/t/short_option_1-master.opt @@ -1 +1 @@ --a -Cutf8 --collation-server=utf8_bin -T12 -W2 +-a -Cutf8 -W1 diff --git a/mysql-test/suite/perfschema/t/short_option_1.test b/mysql-test/suite/perfschema/t/short_option_1.test index 4d00c3729d8..825066830f3 100644 --- a/mysql-test/suite/perfschema/t/short_option_1.test +++ b/mysql-test/suite/perfschema/t/short_option_1.test @@ -11,8 +11,4 @@ show global variables like 'sql_mode'; select @@character_set_server; show global variables like 'character_set_system'; -show global variables like 'general_log'; - -show global variables like 'new'; - show global variables like 'log_warnings'; From 82c07b178abfa9395f1d67747148a431d6eb6ae7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 11 Jun 2021 15:58:50 +0300 Subject: [PATCH 059/251] MDEV-25288 follow-up: Remove traces of unstable-tests --- .travis.yml | 1 - appveyor.yml | 2 +- debian/mariadb-test-data.install | 1 - debian/rules | 9 ++------- debian/tests/upstream | 3 +-- mysql-test/README | 11 ++++------- 6 files changed, 8 insertions(+), 19 deletions(-) diff --git a/.travis.yml b/.travis.yml index f7f57b752d4..5c227b49b09 100644 --- a/.travis.yml +++ b/.travis.yml @@ -224,7 +224,6 @@ script: - cd mysql-test - travis_wait 30 ./mtr --force --max-test-fail=20 --parallel=4 --testcase-timeout=${TEST_CASE_TIMEOUT} --suite=${MYSQL_TEST_SUITES} - --skip-test-list=unstable-tests --skip-test=binlog.binlog_unsafe after_script: diff --git a/appveyor.yml b/appveyor.yml index d5cd5231e6c..355c7f5aeeb 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -16,6 +16,6 @@ platform: x64 test_script: - set PATH=C:\Strawberry\perl\bin;%PATH%;C:\Program Files (x86)\Windows Kits\10\Debuggers\x64 - cd %APPVEYOR_BUILD_FOLDER%\win_build\mysql-test - - perl mysql-test-run.pl --force --max-test-fail=10 --parallel=4 --testcase-timeout=10 --skip-test-list=unstable-tests --suite=main + - perl mysql-test-run.pl --force --max-test-fail=10 --parallel=4 --testcase-timeout=10 --suite=main image: Visual Studio 2019 diff --git a/debian/mariadb-test-data.install b/debian/mariadb-test-data.install index 26b69c2941b..718fc0e122c 100644 --- a/debian/mariadb-test-data.install +++ b/debian/mariadb-test-data.install @@ -4,4 +4,3 @@ 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 diff --git a/debian/rules b/debian/rules index 53c702f2b4c..123a0b9305e 100755 --- a/debian/rules +++ b/debian/rules @@ -74,11 +74,7 @@ override_dh_auto_clean: @echo "RULES.$@" dh_testdir dh_testroot - rm -rf $(BUILDDIR) builddir-native - - [ ! -f debian/mysql-test-unstable-tests.orig ] || \ - mv debian/mysql-test-unstable-tests.orig mysql-test/unstable-tests - + rm -rf $(BUILDDIR) builddir-native mysql-test/unstable-tests debconf-updatepo # Update po-files when clean runs before each build override_dh_auto_configure: @@ -121,8 +117,7 @@ override_dh_auto_build: override_dh_auto_test: @echo "RULES.$@" dh_testdir - # Skip unstable tests if such are defined for arch - cp mysql-test/unstable-tests debian/mysql-test-unstable-tests.orig + touch mysql-test/unstable-tests [ ! -f debian/unstable-tests.$(DEB_HOST_ARCH) ] || cat debian/unstable-tests.$(DEB_HOST_ARCH) >> mysql-test/unstable-tests # Run testsuite ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS))) diff --git a/debian/tests/upstream b/debian/tests/upstream index 4e9b3a7cc8b..51b0a60a0ac 100644 --- a/debian/tests/upstream +++ b/debian/tests/upstream @@ -22,8 +22,7 @@ echo "using tmpdir: $WORKDIR/tmp" echo "Setting up skip-tests-list" -# Use unstable-tests list as base to skip all tests considered unstable -cp /usr/share/mysql/mysql-test/unstable-tests $SKIP_TEST_LST +touch $SKIP_TEST_LST # Also use arch specific skiplists if such files exist for filename in /usr/share/mysql/mysql-test/unstable-tests.* diff --git a/mysql-test/README b/mysql-test/README index 6c7f004a54d..14e9b3647ac 100644 --- a/mysql-test/README +++ b/mysql-test/README @@ -2,10 +2,8 @@ This directory contains test suites for the MariaDB server. To run currently existing test cases, execute ./mysql-test-run in this directory. Some tests are known to fail on some platforms or be otherwise unreliable. -The file "unstable-tests" contains the list of such tests along with -a comment for every test. -To exclude them from the test run, execute - # ./mysql-test-run --skip-test-list=unstable-tests +In the file collections/smoke_test there is a list of tests that are +expected to be stable. In general you do not have to have to do "make install", and you can have a co-existing MariaDB installation, the tests will not conflict with it. @@ -15,7 +13,7 @@ In Red Hat distributions, you should run the script as user "mysql". The user is created with nologin shell, so the best bet is something like # su - # cd /usr/share/mysql-test - # su -s /bin/bash mysql -c "./mysql-test-run --skip-test-list=unstable-tests" + # su -s /bin/bash mysql -c ./mysql-test-run This will use the installed MariaDB executables, but will run a private copy of the server process (using data files within /usr/share/mysql-test), @@ -27,8 +25,7 @@ the listed failures occur for you. To clean up afterwards, remove the created "var" subdirectory, e.g. # su -s /bin/bash - mysql -c "rm -rf /usr/share/mysql-test/var" -If one or more tests fail on your system on reasons other than listed -in lists of unstable tests, please read the following manual section +If tests fail on your system, please read the following manual section for instructions on how to report the problem: https://mariadb.com/kb/en/reporting-bugs From 6c39eaeb126328e7813b146ecf652d51e4508981 Mon Sep 17 00:00:00 2001 From: Sujatha Date: Thu, 9 Apr 2020 20:45:45 +0530 Subject: [PATCH 060/251] MDEV-21117: refine the server binlog-based recovery for semisync Problem: ======= When the semisync master is crashed and restarted as slave it could recover transactions that former slaves may never have seen. A known method existed to clear out all prepared transactions with --tc-heuristic-recover=rollback does not care to adjust binlog accordingly. Fix: === The binlog-based recovery is made to concern of the slave semisync role of post-crash restarted server. No changes in behavior is done to the "normal" binloggging server and the semisync master. When the restarted server is configured with --rpl-semi-sync-slave-enabled=1 the refined recovery attempts to roll back prepared transactions and truncate binlog accordingly. In case of a partially committed (that is committed at least in one of the engine participants) such transaction gets committed. It's guaranteed no (partially as well) committed transactions exist beyond the truncate position. In case there exists a non-transactional replication event (being in a way a committed transaction) past the computed truncate position the recovery ends with an error. As after master crash and failover to slave, the demoted-to-slave ex-master must be ready to face and accept its own (generated by) events, without generally necessary --replicate-same-server-id. So the acceptance conditions are relaxed for the semisync slave to accept own events without that option. While gtid_strict_mode ON ensures no duplicate transaction can be (re-)executed the master_use_gtid=none slave has to be configured with --replicate-same-server-id. *NOTE* for reviewers. This patch does not handle the user XA which is done in next git commit. --- .../r/binlog_truncate_active_log.result | 237 +++++ .../r/binlog_truncate_multi_engine.result | 189 ++++ .../binlog/r/binlog_truncate_multi_log.result | 53 ++ .../r/binlog_truncate_multi_log_unsafe.result | 58 ++ .../binlog/t/binlog_truncate_active_log.inc | 57 ++ .../binlog/t/binlog_truncate_active_log.test | 102 ++ .../binlog/t/binlog_truncate_multi_engine.inc | 73 ++ .../binlog/t/binlog_truncate_multi_engine.opt | 1 + .../t/binlog_truncate_multi_engine.test | 60 ++ .../binlog/t/binlog_truncate_multi_log.test | 77 ++ .../t/binlog_truncate_multi_log_unsafe.test | 119 +++ .../mariabackup/include/have_rocksdb.inc | 4 - .../rpl/r/rpl_semi_sync_fail_over.result | 129 +++ .../suite/rpl/t/rpl_semi_sync_crash.inc | 77 ++ .../suite/rpl/t/rpl_semi_sync_fail_over.cnf | 11 + .../suite/rpl/t/rpl_semi_sync_fail_over.test | 144 +++ sql/handler.cc | 256 ++++- sql/handler.h | 34 +- sql/log.cc | 896 ++++++++++++++++-- sql/log.h | 14 +- sql/log_event.cc | 31 +- sql/log_event.h | 29 +- sql/log_event_server.cc | 68 +- sql/slave.cc | 26 +- storage/innobase/log/log0log.cc | 1 + 25 files changed, 2619 insertions(+), 127 deletions(-) create mode 100644 mysql-test/suite/binlog/r/binlog_truncate_active_log.result create mode 100644 mysql-test/suite/binlog/r/binlog_truncate_multi_engine.result create mode 100644 mysql-test/suite/binlog/r/binlog_truncate_multi_log.result create mode 100644 mysql-test/suite/binlog/r/binlog_truncate_multi_log_unsafe.result create mode 100644 mysql-test/suite/binlog/t/binlog_truncate_active_log.inc create mode 100644 mysql-test/suite/binlog/t/binlog_truncate_active_log.test create mode 100644 mysql-test/suite/binlog/t/binlog_truncate_multi_engine.inc create mode 100644 mysql-test/suite/binlog/t/binlog_truncate_multi_engine.opt create mode 100644 mysql-test/suite/binlog/t/binlog_truncate_multi_engine.test create mode 100644 mysql-test/suite/binlog/t/binlog_truncate_multi_log.test create mode 100644 mysql-test/suite/binlog/t/binlog_truncate_multi_log_unsafe.test delete mode 100644 mysql-test/suite/mariabackup/include/have_rocksdb.inc create mode 100644 mysql-test/suite/rpl/r/rpl_semi_sync_fail_over.result create mode 100644 mysql-test/suite/rpl/t/rpl_semi_sync_crash.inc create mode 100644 mysql-test/suite/rpl/t/rpl_semi_sync_fail_over.cnf create mode 100644 mysql-test/suite/rpl/t/rpl_semi_sync_fail_over.test diff --git a/mysql-test/suite/binlog/r/binlog_truncate_active_log.result b/mysql-test/suite/binlog/r/binlog_truncate_active_log.result new file mode 100644 index 00000000000..3ad9f5c560c --- /dev/null +++ b/mysql-test/suite/binlog/r/binlog_truncate_active_log.result @@ -0,0 +1,237 @@ +call mtr.add_suppression("Can.t init tc log"); +call mtr.add_suppression("Aborting"); +RESET MASTER; +CREATE TABLE t (f INT) ENGINE=INNODB; +CREATE TABLE t2 (f INT) ENGINE=INNODB; +CREATE TABLE tm (f INT) ENGINE=Aria; +# Case A. +connect master1,localhost,root,,; +connect master2,localhost,root,,; +connect master3,localhost,root,,; +connection default; +INSERT INTO t VALUES (10); +INSERT INTO tm VALUES (10); +connection master1; +SET DEBUG_SYNC= "commit_before_get_LOCK_commit_ordered SIGNAL master1_ready WAIT_FOR signal_never_arrives"; +INSERT INTO t VALUES (20); +connection master2; +SET DEBUG_SYNC= "now WAIT_FOR master1_ready"; +SET DEBUG_SYNC= "commit_before_get_LOCK_after_binlog_sync SIGNAL master2_ready"; +DELETE FROM t2 WHERE f = 0 /* no such record */; +connection master3; +SET DEBUG_SYNC= "now WAIT_FOR master2_ready"; +SELECT @@global.gtid_binlog_pos as 'Before the crash'; +Before the crash +0-1-7 +connection default; +# Kill the server +disconnect master1; +disconnect master2; +disconnect master3; +# restart: --rpl-semi-sync-slave-enabled=1 +FOUND 1 /Successfully truncated.*to remove transactions starting from GTID 0-1-6/ in mysqld.1.err +Pre-crash binlog file content: +include/show_binlog_events.inc +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; CREATE TABLE t (f INT) ENGINE=INNODB +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; CREATE TABLE t2 (f INT) ENGINE=INNODB +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; CREATE TABLE tm (f INT) ENGINE=Aria +master-bin.000001 # Gtid # # BEGIN GTID #-#-# +master-bin.000001 # Query # # use `test`; INSERT INTO t VALUES (10) +master-bin.000001 # Xid # # COMMIT /* XID */ +master-bin.000001 # Gtid # # BEGIN GTID #-#-# +master-bin.000001 # Query # # use `test`; INSERT INTO tm VALUES (10) +master-bin.000001 # Query # # COMMIT +SELECT @@global.gtid_binlog_pos as 'After the crash'; +After the crash +0-1-5 +"One row should be present in table 't'" +SELECT * FROM t; +f +10 +DELETE FROM t; +# Case B. +connect master1,localhost,root,,; +connect master2,localhost,root,,; +connect master3,localhost,root,,; +connection default; +INSERT INTO t VALUES (10); +INSERT INTO tm VALUES (10); +connection master1; +SET DEBUG_SYNC= "commit_before_get_LOCK_commit_ordered SIGNAL master1_ready WAIT_FOR signal_never_arrives"; +DELETE FROM t2 WHERE f = 0; +connection master2; +SET DEBUG_SYNC= "now WAIT_FOR master1_ready"; +SET DEBUG_SYNC= "commit_before_get_LOCK_after_binlog_sync SIGNAL master2_ready"; +INSERT INTO t VALUES (20); +connection master3; +SET DEBUG_SYNC= "now WAIT_FOR master2_ready"; +SELECT @@global.gtid_binlog_pos as 'Before the crash'; +Before the crash +0-1-10 +connection default; +# Kill the server +disconnect master1; +disconnect master2; +disconnect master3; +# restart: --rpl-semi-sync-slave-enabled=1 +FOUND 1 /Successfully truncated.*to remove transactions starting from GTID 0-1-10/ in mysqld.1.err +Pre-crash binlog file content: +include/show_binlog_events.inc +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000002 # Gtid # # BEGIN GTID #-#-# +master-bin.000002 # Query # # use `test`; DELETE FROM t +master-bin.000002 # Xid # # COMMIT /* XID */ +master-bin.000002 # Gtid # # BEGIN GTID #-#-# +master-bin.000002 # Query # # use `test`; INSERT INTO t VALUES (10) +master-bin.000002 # Xid # # COMMIT /* XID */ +master-bin.000002 # Gtid # # BEGIN GTID #-#-# +master-bin.000002 # Query # # use `test`; INSERT INTO tm VALUES (10) +master-bin.000002 # Query # # COMMIT +master-bin.000002 # Gtid # # BEGIN GTID #-#-# +master-bin.000002 # Query # # use `test`; DELETE FROM t2 WHERE f = 0 +master-bin.000002 # Query # # COMMIT +SELECT @@global.gtid_binlog_pos as 'After the crash'; +After the crash +0-1-9 +"One row should be present in table 't'" +SELECT * FROM t; +f +10 +DELETE FROM t; +# Case C. +CREATE PROCEDURE sp_blank_xa() +BEGIN +XA START 'blank'; +DELETE FROM t2 WHERE f = 0 /* no such record */; +XA END 'blank'; +XA PREPARE 'blank'; +END| +connect master1,localhost,root,,; +connect master2,localhost,root,,; +connect master3,localhost,root,,; +connection default; +INSERT INTO t VALUES (10); +INSERT INTO tm VALUES (10); +connection master1; +SET DEBUG_SYNC= "commit_before_get_LOCK_commit_ordered SIGNAL master1_ready WAIT_FOR signal_never_arrives"; +INSERT INTO t VALUES (20); +connection master2; +SET DEBUG_SYNC= "now WAIT_FOR master1_ready"; +SET DEBUG_SYNC= "commit_before_get_LOCK_after_binlog_sync SIGNAL master2_ready"; +CALL sp_blank_xa; +connection master3; +SET DEBUG_SYNC= "now WAIT_FOR master2_ready"; +SELECT @@global.gtid_binlog_pos as 'Before the crash'; +Before the crash +0-1-15 +connection default; +# Kill the server +disconnect master1; +disconnect master2; +disconnect master3; +# restart: --rpl-semi-sync-slave-enabled=1 +FOUND 1 /Successfully truncated.*to remove transactions starting from GTID 0-1-14/ in mysqld.1.err +Pre-crash binlog file content: +include/show_binlog_events.inc +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000003 # Gtid # # BEGIN GTID #-#-# +master-bin.000003 # Query # # use `test`; DELETE FROM t +master-bin.000003 # Xid # # COMMIT /* XID */ +master-bin.000003 # Gtid # # GTID #-#-# +master-bin.000003 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_blank_xa`() +BEGIN +XA START 'blank'; +DELETE FROM t2 WHERE f = 0 /* no such record */; +XA END 'blank'; +XA PREPARE 'blank'; +END +master-bin.000003 # Gtid # # BEGIN GTID #-#-# +master-bin.000003 # Query # # use `test`; INSERT INTO t VALUES (10) +master-bin.000003 # Xid # # COMMIT /* XID */ +master-bin.000003 # Gtid # # BEGIN GTID #-#-# +master-bin.000003 # Query # # use `test`; INSERT INTO tm VALUES (10) +master-bin.000003 # Query # # COMMIT +SELECT @@global.gtid_binlog_pos as 'After the crash'; +After the crash +0-1-13 +"One row should be present in table 't'" +SELECT * FROM t; +f +10 +DELETE FROM t; +DROP PROCEDURE sp_blank_xa; +# Case D. +CREATE PROCEDURE sp_xa() +BEGIN +XA START 'xid'; +DELETE FROM t WHERE f = 10; +XA END 'xid'; +XA PREPARE 'xid'; +END| +connect master1,localhost,root,,; +connect master2,localhost,root,,; +connect master3,localhost,root,,; +connection default; +INSERT INTO t VALUES (10); +INSERT INTO tm VALUES (10); +connection master1; +SET DEBUG_SYNC= "commit_before_get_LOCK_commit_ordered SIGNAL master1_ready WAIT_FOR signal_never_arrives"; +CALL sp_xa; +connection master2; +SET DEBUG_SYNC= "now WAIT_FOR master1_ready"; +SET DEBUG_SYNC= "commit_before_get_LOCK_after_binlog_sync SIGNAL master2_ready"; +INSERT INTO t2 VALUES (20); +connection master3; +SET DEBUG_SYNC= "now WAIT_FOR master2_ready"; +SELECT @@global.gtid_binlog_pos as 'Before the crash'; +Before the crash +0-1-20 +connection default; +# Kill the server +disconnect master1; +disconnect master2; +disconnect master3; +# restart: --rpl-semi-sync-slave-enabled=1 +FOUND 1 /Successfully truncated.*to remove transactions starting from GTID 0-1-20/ in mysqld.1.err +Pre-crash binlog file content: +include/show_binlog_events.inc +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000004 # Gtid # # BEGIN GTID #-#-# +master-bin.000004 # Query # # use `test`; DELETE FROM t +master-bin.000004 # Xid # # COMMIT /* XID */ +master-bin.000004 # Gtid # # GTID #-#-# +master-bin.000004 # Query # # use `test`; DROP PROCEDURE sp_blank_xa +master-bin.000004 # Gtid # # GTID #-#-# +master-bin.000004 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_xa`() +BEGIN +XA START 'xid'; +DELETE FROM t WHERE f = 10; +XA END 'xid'; +XA PREPARE 'xid'; +END +master-bin.000004 # Gtid # # BEGIN GTID #-#-# +master-bin.000004 # Query # # use `test`; INSERT INTO t VALUES (10) +master-bin.000004 # Xid # # COMMIT /* XID */ +master-bin.000004 # Gtid # # BEGIN GTID #-#-# +master-bin.000004 # Query # # use `test`; INSERT INTO tm VALUES (10) +master-bin.000004 # Query # # COMMIT +master-bin.000004 # Gtid # # XA START X'786964',X'',1 GTID #-#-# +master-bin.000004 # Query # # use `test`; DELETE FROM t WHERE f = 10 +master-bin.000004 # Query # # XA END X'786964',X'',1 +master-bin.000004 # XA_prepare # # XA PREPARE X'786964',X'',1 +SELECT @@global.gtid_binlog_pos as 'After the crash'; +After the crash +0-1-19 +"One row should be present in table 't'" +SELECT * FROM t; +f +10 +DELETE FROM t; +DROP PROCEDURE sp_xa; +# Cleanup +DROP TABLE t,t2,tm; +# End of the tests diff --git a/mysql-test/suite/binlog/r/binlog_truncate_multi_engine.result b/mysql-test/suite/binlog/r/binlog_truncate_multi_engine.result new file mode 100644 index 00000000000..b8fd04497f2 --- /dev/null +++ b/mysql-test/suite/binlog/r/binlog_truncate_multi_engine.result @@ -0,0 +1,189 @@ +call mtr.add_suppression("Can.t init tc log"); +call mtr.add_suppression("Aborting"); +CREATE TABLE t1 (a INT PRIMARY KEY, b MEDIUMTEXT) ENGINE=Innodb; +CREATE TABLE t2 (a INT PRIMARY KEY, b MEDIUMTEXT) ENGINE=rocksdb; +# +# +# Case "A" : "neither engine committed => rollback & binlog truncate" +# +RESET MASTER; +FLUSH LOGS; +SET GLOBAL max_binlog_size= 4096; +connect con1,localhost,root,,; +List of binary logs before rotation +show binary logs; +Log_name File_size +master-bin.000001 # +master-bin.000002 # +INSERT INTO t1 VALUES (1, REPEAT("x", 1)); +INSERT INTO t2 VALUES (1, REPEAT("x", 1)); +BEGIN; +INSERT INTO t2 VALUES (2, REPEAT("x", 4100)); +INSERT INTO t1 VALUES (2, REPEAT("x", 4100)); +SET DEBUG_SYNC= "commit_after_release_LOCK_log SIGNAL con1_ready WAIT_FOR signal_no_signal"; +COMMIT; +connection default; +SET DEBUG_SYNC= "now WAIT_FOR con1_ready"; +List of binary logs after rotation +show binary logs; +Log_name File_size +master-bin.000001 # +master-bin.000002 # +master-bin.000003 # +# restart the server with --rpl-semi-sync-slave-enabled=1 +# the server is restarted +# restart: --rpl-semi-sync-slave-enabled=1 +connection default; +# +# *** Summary: 1 row should be present in both tables; binlog is truncated; number of binlogs at reconnect - 3: +# +SELECT COUNT(*) FROM t1; +COUNT(*) +1 +SELECT COUNT(*) FROM t2; +COUNT(*) +1 +SELECT @@GLOBAL.gtid_binlog_state; +@@GLOBAL.gtid_binlog_state +0-1-2 +SELECT @@GLOBAL.gtid_binlog_pos; +@@GLOBAL.gtid_binlog_pos +0-1-2 +List of binary logs at the end of the tests +show binary logs; +Log_name File_size +master-bin.000001 # +master-bin.000002 # +master-bin.000003 # +# *** +DELETE FROM t1; +DELETE FROM t2; +disconnect con1; +# +Proof of the truncated binlog file is readable (two transactions must be seen): +/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; +/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; +DELIMITER /*!*/; +START TRANSACTION +/*!*/; +COMMIT/*!*/; +START TRANSACTION +/*!*/; +COMMIT/*!*/; +DELIMITER ; +# End of log file +ROLLBACK /* added by mysqlbinlog */; +/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; +/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/; +# +# +# Case "B" : "one engine has committed its transaction branch" +# +RESET MASTER; +FLUSH LOGS; +SET GLOBAL max_binlog_size= 4096; +connect con1,localhost,root,,; +List of binary logs before rotation +show binary logs; +Log_name File_size +master-bin.000001 # +master-bin.000002 # +INSERT INTO t1 VALUES (1, REPEAT("x", 1)); +INSERT INTO t2 VALUES (1, REPEAT("x", 1)); +SET GLOBAL debug_dbug="d,enable_log_write_upto_crash"; +BEGIN; +INSERT INTO t2 VALUES (2, REPEAT("x", 4100)); +INSERT INTO t1 VALUES (2, REPEAT("x", 4100)); +COMMIT; +connection default; +# restart: --rpl-semi-sync-slave-enabled=1 +connection default; +# +# *** Summary: 2 rows should be present in both tables; no binlog truncation; one extra binlog file compare with A; number of binlogs at reconnect - 4: +# +SELECT COUNT(*) FROM t1; +COUNT(*) +2 +SELECT COUNT(*) FROM t2; +COUNT(*) +2 +SELECT @@GLOBAL.gtid_binlog_state; +@@GLOBAL.gtid_binlog_state +0-1-3 +SELECT @@GLOBAL.gtid_binlog_pos; +@@GLOBAL.gtid_binlog_pos +0-1-3 +List of binary logs at the end of the tests +show binary logs; +Log_name File_size +master-bin.000001 # +master-bin.000002 # +master-bin.000003 # +master-bin.000004 # +# *** +DELETE FROM t1; +DELETE FROM t2; +disconnect con1; +# +# +# +# Case "C" : "both engines have committed its transaction branch" +# +RESET MASTER; +FLUSH LOGS; +SET GLOBAL max_binlog_size= 4096; +connect con1,localhost,root,,; +List of binary logs before rotation +show binary logs; +Log_name File_size +master-bin.000001 # +master-bin.000002 # +INSERT INTO t1 VALUES (1, REPEAT("x", 1)); +INSERT INTO t2 VALUES (1, REPEAT("x", 1)); +BEGIN; +INSERT INTO t2 VALUES (2, REPEAT("x", 4100)); +INSERT INTO t1 VALUES (2, REPEAT("x", 4100)); +SET DEBUG_SYNC= "commit_after_run_commit_ordered SIGNAL con1_ready WAIT_FOR signal_no_signal"; +COMMIT; +connection default; +SET DEBUG_SYNC= "now WAIT_FOR con1_ready"; +List of binary logs after rotation +show binary logs; +Log_name File_size +master-bin.000001 # +master-bin.000002 # +master-bin.000003 # +# restart the server with --rpl-semi-sync-slave-enabled=1 +# the server is restarted +# restart: --rpl-semi-sync-slave-enabled=1 +connection default; +# +# *** Summary: 2 rows should be present in both tables; no binlog truncation; the same # of binlog files as in B; number of binlogs at reconnect - 4: +# +SELECT COUNT(*) FROM t1; +COUNT(*) +2 +SELECT COUNT(*) FROM t2; +COUNT(*) +2 +SELECT @@GLOBAL.gtid_binlog_state; +@@GLOBAL.gtid_binlog_state +0-1-3 +SELECT @@GLOBAL.gtid_binlog_pos; +@@GLOBAL.gtid_binlog_pos +0-1-3 +List of binary logs at the end of the tests +show binary logs; +Log_name File_size +master-bin.000001 # +master-bin.000002 # +master-bin.000003 # +master-bin.000004 # +# *** +DELETE FROM t1; +DELETE FROM t2; +disconnect con1; +# +DROP TABLE t1, t2; +# End of the tests diff --git a/mysql-test/suite/binlog/r/binlog_truncate_multi_log.result b/mysql-test/suite/binlog/r/binlog_truncate_multi_log.result new file mode 100644 index 00000000000..e11a40feb2f --- /dev/null +++ b/mysql-test/suite/binlog/r/binlog_truncate_multi_log.result @@ -0,0 +1,53 @@ +call mtr.add_suppression("Can.t init tc log"); +call mtr.add_suppression("Aborting"); +SET @@global.max_binlog_size= 4096; +RESET MASTER; +FLUSH LOGS; +CREATE TABLE ti (a INT PRIMARY KEY, b MEDIUMTEXT) ENGINE=Innodb; +CREATE TABLE tm (a INT PRIMARY KEY, b MEDIUMTEXT) ENGINE=MyISAM; +connect master1,localhost,root,,; +"List of binary logs before rotation" +show binary logs; +Log_name File_size +master-bin.000001 # +master-bin.000002 # +INSERT INTO ti VALUES(1,"I am gonna survive"); +INSERT INTO tm VALUES(1,"me too!"); +SET DEBUG_SYNC= "commit_after_release_LOCK_after_binlog_sync SIGNAL master1_ready WAIT_FOR con1_go"; +INSERT INTO ti VALUES (2, REPEAT("x", 4100)); +connect master2,localhost,root,,; +SET DEBUG_SYNC= "now WAIT_FOR master1_ready"; +SET DEBUG_SYNC= "commit_before_get_LOCK_commit_ordered SIGNAL master2_ready WAIT_FOR master2_go"; +INSERT INTO ti VALUES (3, "not gonna survive"); +connection default; +SET DEBUG_SYNC= "now WAIT_FOR master2_ready"; +"List of binary logs before crash" +show binary logs; +Log_name File_size +master-bin.000001 # +master-bin.000002 # +master-bin.000003 # +# The gtid binlog state prior the crash will be truncated at the end of the test +SELECT @@global.gtid_binlog_state; +@@global.gtid_binlog_state +0-1-6 +connection default; +# Kill the server +disconnect master1; +disconnect master2; +# restart: --rpl-semi-sync-slave-enabled=1 +FOUND 1 /truncated binlog file:.*master.*000002/ in mysqld.1.err +"One record should be present in table" +SELECT * FROM ti; +a b +1 I am gonna survive +# The truncated gtid binlog state +SELECT @@global.gtid_binlog_state; +@@global.gtid_binlog_state +0-1-4 +SELECT @@global.gtid_binlog_pos; +@@global.gtid_binlog_pos +0-1-4 +# Cleanup +DROP TABLE ti; +# End of the tests diff --git a/mysql-test/suite/binlog/r/binlog_truncate_multi_log_unsafe.result b/mysql-test/suite/binlog/r/binlog_truncate_multi_log_unsafe.result new file mode 100644 index 00000000000..0ee9a7c871d --- /dev/null +++ b/mysql-test/suite/binlog/r/binlog_truncate_multi_log_unsafe.result @@ -0,0 +1,58 @@ +SET @@global.max_binlog_size= 4096; +call mtr.add_suppression("Table '.*tm' is marked as crashed and should be repaired"); +call mtr.add_suppression("Got an error from unknown thread"); +call mtr.add_suppression("Checking table: '.*tm'"); +call mtr.add_suppression("Recovering table: '.*tm'"); +call mtr.add_suppression("Cannot truncate the binary log to file"); +call mtr.add_suppression("Crash recovery failed"); +call mtr.add_suppression("Can.t init tc log"); +call mtr.add_suppression("Aborting"); +call mtr.add_suppression("Found 1 prepared transactions"); +call mtr.add_suppression("mysqld: Table.*tm.*is marked as crashed"); +call mtr.add_suppression("Checking table.*tm"); +RESET MASTER; +FLUSH LOGS; +CREATE TABLE ti (a INT PRIMARY KEY, b MEDIUMTEXT) ENGINE=Innodb; +CREATE TABLE tm (f INT) ENGINE=MYISAM; +INSERT INTO tm VALUES(1); +connect master1,localhost,root,,; +connect master2,localhost,root,,; +connect master3,localhost,root,,; +connection master1; +SET DEBUG_SYNC= "commit_after_release_LOCK_after_binlog_sync SIGNAL master1_ready WAIT_FOR master1_go"; +INSERT INTO ti VALUES (5 - 1, REPEAT("x", 4100)); +connection master2; +SET DEBUG_SYNC= "commit_before_get_LOCK_commit_ordered SIGNAL master2_ready WAIT_FOR master2_go"; +INSERT INTO ti VALUES (5, REPEAT("x", 1)); +connection master3; +SET DEBUG_SYNC= "now WAIT_FOR master2_ready"; +SET DEBUG_SYNC= "commit_before_get_LOCK_after_binlog_sync SIGNAL master3_ready"; +INSERT INTO tm VALUES (2); +connection default; +SET DEBUG_SYNC= "now WAIT_FOR master3_ready"; +# The gtid binlog state prior the crash must be restored at the end of the test; +SELECT @@global.gtid_binlog_state; +@@global.gtid_binlog_state +0-1-9 +# Kill the server +# Failed restart as the semisync slave +# Normal restart +# restart +FOUND 1 /Cannot truncate the binary log to file/ in mysqld.1.err +# Proof that the in-doubt transactions are recovered by the 2nd normal server restart +SELECT COUNT(*) = 5 as 'True' FROM ti; +True +1 +SELECT COUNT(*) <= 1 FROM tm; +COUNT(*) <= 1 +1 +# The gtid binlog state prior the crash is restored now +SELECT @@GLOBAL.gtid_binlog_state; +@@GLOBAL.gtid_binlog_state +0-1-9 +SELECT @@GLOBAL.gtid_binlog_pos; +@@GLOBAL.gtid_binlog_pos +0-1-9 +# Cleanup +DROP TABLE ti, tm; +End of test diff --git a/mysql-test/suite/binlog/t/binlog_truncate_active_log.inc b/mysql-test/suite/binlog/t/binlog_truncate_active_log.inc new file mode 100644 index 00000000000..0bc83477d91 --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_truncate_active_log.inc @@ -0,0 +1,57 @@ +connect(master1,localhost,root,,); +connect(master2,localhost,root,,); +connect(master3,localhost,root,,); + +--connection default + +# First to commit few transactions +INSERT INTO t VALUES (10); +INSERT INTO tm VALUES (10); + +--connection master1 +# Hold insert after write to binlog and before "run_commit_ordered" in engine +SET DEBUG_SYNC= "commit_before_get_LOCK_commit_ordered SIGNAL master1_ready WAIT_FOR signal_never_arrives"; +--send_eval $query1 + +--connection master2 +SET DEBUG_SYNC= "now WAIT_FOR master1_ready"; +SET DEBUG_SYNC= "commit_before_get_LOCK_after_binlog_sync SIGNAL master2_ready"; +--send_eval $query2 + +--connection master3 +SET DEBUG_SYNC= "now WAIT_FOR master2_ready"; +SELECT @@global.gtid_binlog_pos as 'Before the crash'; + +--connection default +--source include/kill_mysqld.inc +--disconnect master1 +--disconnect master2 +--disconnect master3 + +# +# Server restart +# +--let $restart_parameters= --rpl-semi-sync-slave-enabled=1 +--source include/start_mysqld.inc + +# Check error log for a successful truncate message. +--let $log_error_ = $MYSQLTEST_VARDIR/log/mysqld.1.err + +--let SEARCH_FILE=$log_error_ +--let SEARCH_PATTERN=Successfully truncated.*to remove transactions starting from GTID $truncate_gtid_pos + +--source include/search_pattern_in_file.inc + +--echo Pre-crash binlog file content: +--let $binlog_file= query_get_value(show binary logs, Log_name, $binlog_file_index) +--source include/show_binlog_events.inc + +SELECT @@global.gtid_binlog_pos as 'After the crash'; +--echo "One row should be present in table 't'" +SELECT * FROM t; + +# prepare binlog file index for the next test +--inc $binlog_file_index + +# Local cleanup +DELETE FROM t; diff --git a/mysql-test/suite/binlog/t/binlog_truncate_active_log.test b/mysql-test/suite/binlog/t/binlog_truncate_active_log.test new file mode 100644 index 00000000000..dbba8697b86 --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_truncate_active_log.test @@ -0,0 +1,102 @@ +# ==== Purpose ==== +# +# Test verifies the truncation of single binary log file. +# +# ==== References ==== +# +# MDEV-21117: recovery for --rpl-semi-sync-slave-enabled server + +--source include/have_innodb.inc +--source include/have_aria.inc +# File: binlog_truncate_active_log.inc included in test makes use of +# 'debug_sync' facility. +--source include/have_debug_sync.inc +--source include/have_binlog_format_statement.inc + +call mtr.add_suppression("Can.t init tc log"); +call mtr.add_suppression("Aborting"); + +# The following cases are tested: +# A. 2pc transaction is followed by a blank "zero-engines" one +# B. 2pc transaction follows the blank one +# C. Similarly to A, with the XA blank transaction + +RESET MASTER; +CREATE TABLE t (f INT) ENGINE=INNODB; +CREATE TABLE t2 (f INT) ENGINE=INNODB; +CREATE TABLE tm (f INT) ENGINE=Aria; + +# Old (pre-crash) binlog file index initial value. +# It keeps incremented at the end of each case. +--let $binlog_file_index=1 + +--echo # Case A. +# Using 'debug_sync' hold 'query1' execution after 'query1' is flushed and +# synced to binary log but not yet committed. In an another connection hold +# 'query2' execution after 'query2' is flushed and synced to binlog. +# Crash and restart server with --rpl-semi-sync-slave-enabled=1 +# +# During recovery of binary log 'query1' status is checked with InnoDB engine, +# it will be in prepared but not yet commited. All transactions starting from +# 'query1' onwards will be removed from the binary log. +# Show-binlog-events is to prove that. + +--let $truncate_gtid_pos = 0-1-6 +--let $query1 = INSERT INTO t VALUES (20) +--let $query2 = DELETE FROM t2 WHERE f = 0 /* no such record */ +--source binlog_truncate_active_log.inc + +--echo # Case B. +# The inverted sequence ends up to truncate starting from $query2 +--let $truncate_gtid_pos = 0-1-10 +--let $query1 = DELETE FROM t2 WHERE f = 0 +--let $query2 = INSERT INTO t VALUES (20) +--source binlog_truncate_active_log.inc + + +--echo # Case C. +delimiter |; +CREATE PROCEDURE sp_blank_xa() +BEGIN + XA START 'blank'; + DELETE FROM t2 WHERE f = 0 /* no such record */; + XA END 'blank'; + XA PREPARE 'blank'; +END| +delimiter ;| + +# The same as in A with $query2 being the zero-engine XA transaction. +# Both $query1 and $query2 are going to be truncated. +--let $truncate_gtid_pos = 0-1-14 +--let $query1 = INSERT INTO t VALUES (20) +--let $query2 = CALL sp_blank_xa +--source binlog_truncate_active_log.inc + +DROP PROCEDURE sp_blank_xa; + + +--echo # Case D. +delimiter |; +CREATE PROCEDURE sp_xa() +BEGIN + XA START 'xid'; + DELETE FROM t WHERE f = 10; + XA END 'xid'; + XA PREPARE 'xid'; +END| +delimiter ;| + +# The same as in B with $query1 being the prepared XA transaction. +# Truncation must occurs at $query2. +--let $truncate_gtid_pos = 0-1-20 +--let $query1 = CALL sp_xa +--let $query2 = INSERT INTO t2 VALUES (20) +--source binlog_truncate_active_log.inc + +DROP PROCEDURE sp_xa; + + +--echo # Cleanup +DROP TABLE t,t2,tm; + +--echo # End of the tests diff --git a/mysql-test/suite/binlog/t/binlog_truncate_multi_engine.inc b/mysql-test/suite/binlog/t/binlog_truncate_multi_engine.inc new file mode 100644 index 00000000000..52ce4741eaa --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_truncate_multi_engine.inc @@ -0,0 +1,73 @@ +# +# Invoked by binlog_truncate_multi_engine.test +# Parameters: +# $debug_sync_action describes debug-sync actions +# $kill_server 1 when to crash, 0 for regular restart +# $restart_parameters the caller may simulate partial commit at recovery +# $test_outcome summary of extected results +# $MYSQLD_DATADIR + +--echo # +--echo # +--echo # Case $case : $description +--echo # +RESET MASTER; +FLUSH LOGS; +SET GLOBAL max_binlog_size= 4096; + +connect(con1,localhost,root,,); +--echo List of binary logs before rotation +--source include/show_binary_logs.inc +INSERT INTO t1 VALUES (1, REPEAT("x", 1)); +INSERT INTO t2 VALUES (1, REPEAT("x", 1)); +if (`SELECT $case = "B"`) +{ + --write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect +wait-binlog_truncate_multi_engine.test +EOF + + SET GLOBAL debug_dbug="d,enable_log_write_upto_crash"; +} +BEGIN; + INSERT INTO t2 VALUES (2, REPEAT("x", 4100)); + INSERT INTO t1 VALUES (2, REPEAT("x", 4100)); + +if (`SELECT $debug_sync_action != ""`) +{ + --eval SET DEBUG_SYNC= $debug_sync_action +} +send COMMIT; + +--connection default +if (`SELECT $case = "B"`) +{ + --source include/wait_until_disconnected.inc + --source include/start_mysqld.inc +} +if (`SELECT $case != "B"`) +{ + SET DEBUG_SYNC= "now WAIT_FOR con1_ready"; + --echo List of binary logs after rotation + --source include/show_binary_logs.inc + + --echo # restart the server with $restart_parameters + --echo # the server is restarted + --source include/restart_mysqld.inc +} + +--connection default +--echo # +--echo # *** Summary: $test_outcome: +--echo # +SELECT COUNT(*) FROM t1; +SELECT COUNT(*) FROM t2; +SELECT @@GLOBAL.gtid_binlog_state; +SELECT @@GLOBAL.gtid_binlog_pos; +--echo List of binary logs at the end of the tests +--source include/show_binary_logs.inc +--echo # *** +# cleanup +DELETE FROM t1; +DELETE FROM t2; +--disconnect con1 +--echo # diff --git a/mysql-test/suite/binlog/t/binlog_truncate_multi_engine.opt b/mysql-test/suite/binlog/t/binlog_truncate_multi_engine.opt new file mode 100644 index 00000000000..03e7d74f6db --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_truncate_multi_engine.opt @@ -0,0 +1 @@ +--plugin-load=$HA_ROCKSDB_SO diff --git a/mysql-test/suite/binlog/t/binlog_truncate_multi_engine.test b/mysql-test/suite/binlog/t/binlog_truncate_multi_engine.test new file mode 100644 index 00000000000..f8e32f16f0f --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_truncate_multi_engine.test @@ -0,0 +1,60 @@ +# ==== Purpose ==== +# +# Test verifies truncation of multiple binary logs with multiple transactional +# storage engines +# +# ==== References ==== +# +# MDEV-21117: recovery for --rpl-semi-sync-slave-enabled server + +--source include/have_rocksdb.inc +--source include/have_innodb.inc +--source include/have_debug.inc +--source include/have_debug_sync.inc +--source include/have_binlog_format_row.inc + +--let $old_max_binlog_size= `select @@global.max_binlog_size` +call mtr.add_suppression("Can.t init tc log"); +call mtr.add_suppression("Aborting"); +--let $MYSQLD_DATADIR= `SELECT @@datadir` + +CREATE TABLE t1 (a INT PRIMARY KEY, b MEDIUMTEXT) ENGINE=Innodb; +CREATE TABLE t2 (a INT PRIMARY KEY, b MEDIUMTEXT) ENGINE=rocksdb; + +--let $case = "A" +--let $description = "neither engine committed => rollback & binlog truncate" +# Hold off engine commits after write to binlog and its rotation. +# The transaction is killed along with the server after that. +--let $shutdown_timeout=0 +--let $debug_sync_action = "commit_after_release_LOCK_log SIGNAL con1_ready WAIT_FOR signal_no_signal" +--let $restart_parameters = --rpl-semi-sync-slave-enabled=1 +--let $test_outcome= 1 row should be present in both tables; binlog is truncated; number of binlogs at reconnect - 3 +--source binlog_truncate_multi_engine.inc +--echo Proof of the truncated binlog file is readable (two transactions must be seen): +--exec $MYSQL_BINLOG --short-form --skip-annotate-row-events $MYSQLD_DATADIR/master-bin.000002 + +--let $case = "B" +--let $description = "one engine has committed its transaction branch" +# Hold off after one engine has committed. +--let $shutdown_timeout=0 +--let $debug_sync_action = "" +# Both debug_sync and debug-dbug are required to make sure Engines remember the commit state +# debug_sync alone will not help. +--let $restart_parameters = --rpl-semi-sync-slave-enabled=1 +--let $test_outcome= 2 rows should be present in both tables; no binlog truncation; one extra binlog file compare with A; number of binlogs at reconnect - 4 +--source binlog_truncate_multi_engine.inc + +--let $case = "C" +--let $description= "both engines have committed its transaction branch" +--let $debug_sync_action = "commit_after_run_commit_ordered SIGNAL con1_ready WAIT_FOR signal_no_signal" +# Hold off after both engines have committed. The server is shut down. +--let $shutdown_timeout= +--let $restart_parameters = --rpl-semi-sync-slave-enabled=1 +--let $test_outcome= 2 rows should be present in both tables; no binlog truncation; the same # of binlog files as in B; number of binlogs at reconnect - 4 +--source binlog_truncate_multi_engine.inc + + + +DROP TABLE t1, t2; + +--echo # End of the tests diff --git a/mysql-test/suite/binlog/t/binlog_truncate_multi_log.test b/mysql-test/suite/binlog/t/binlog_truncate_multi_log.test new file mode 100644 index 00000000000..4ea7f9a559e --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_truncate_multi_log.test @@ -0,0 +1,77 @@ +# ==== Purpose ==== +# +# Test verifies truncation of multiple binary logs. +# +# ==== References ==== +# MDEV-21117: recovery for --rpl-semi-sync-slave-enabled server + +--source include/have_innodb.inc +--source include/have_debug_sync.inc +--source include/have_binlog_format_row.inc + +call mtr.add_suppression("Can.t init tc log"); +call mtr.add_suppression("Aborting"); + +SET @@global.max_binlog_size= 4096; + +RESET MASTER; +FLUSH LOGS; +CREATE TABLE ti (a INT PRIMARY KEY, b MEDIUMTEXT) ENGINE=Innodb; +CREATE TABLE tm (a INT PRIMARY KEY, b MEDIUMTEXT) ENGINE=MyISAM; + +connect(master1,localhost,root,,); +--echo "List of binary logs before rotation" +--source include/show_binary_logs.inc + +# Some load to either non- and transactional egines +# that should not affect the following recovery: +INSERT INTO ti VALUES(1,"I am gonna survive"); +INSERT INTO tm VALUES(1,"me too!"); + +# hold on near engine commit +SET DEBUG_SYNC= "commit_after_release_LOCK_after_binlog_sync SIGNAL master1_ready WAIT_FOR con1_go"; +--send INSERT INTO ti VALUES (2, REPEAT("x", 4100)) + +connect(master2,localhost,root,,); +# The 2nd trx for recovery, it does not rotate binlog +SET DEBUG_SYNC= "now WAIT_FOR master1_ready"; +SET DEBUG_SYNC= "commit_before_get_LOCK_commit_ordered SIGNAL master2_ready WAIT_FOR master2_go"; +--send INSERT INTO ti VALUES (3, "not gonna survive") + +--connection default +SET DEBUG_SYNC= "now WAIT_FOR master2_ready"; +--echo "List of binary logs before crash" +--source include/show_binary_logs.inc +--echo # The gtid binlog state prior the crash will be truncated at the end of the test +SELECT @@global.gtid_binlog_state; + +--connection default +--source include/kill_mysqld.inc +--disconnect master1 +--disconnect master2 + +# +# Server restart +# +--let $restart_parameters= --rpl-semi-sync-slave-enabled=1 +--source include/start_mysqld.inc + +# Check error log for a successful truncate message. +let $log_error_ = $MYSQLTEST_VARDIR/log/mysqld.1.err; + +--let SEARCH_FILE=$log_error_ +--let SEARCH_PATTERN=truncated binlog file:.*master.*000002 +--source include/search_pattern_in_file.inc + + +--echo "One record should be present in table" +SELECT * FROM ti; + +--echo # The truncated gtid binlog state +SELECT @@global.gtid_binlog_state; +SELECT @@global.gtid_binlog_pos; + +--echo # Cleanup +DROP TABLE ti; + +--echo # End of the tests diff --git a/mysql-test/suite/binlog/t/binlog_truncate_multi_log_unsafe.test b/mysql-test/suite/binlog/t/binlog_truncate_multi_log_unsafe.test new file mode 100644 index 00000000000..04d8619e24e --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_truncate_multi_log_unsafe.test @@ -0,0 +1,119 @@ +# ==== Purpose ==== +# The test verifies attempt to recover by the semisync slave server whose +# binlog is unsafe for truncation. +# +# ==== Implementation ==== +# 2 binlog files are created with the 1st one destined to be the binlog +# checkpoint file for recovery. +# The final group of events is replication unsafe (myisam INSERT). +# Therefore the semisync slave recovery may not. +# +# Steps: +# 0 - Set max_binlog_size= 4096, to help an insert into a +# transaction table 'ti' get binlog rotated while the +# transaction won't be committed, being stopped at +# a prior to commit debug_sync point +# 1 - insert into a non-transactional 'tm' table completes with +# binary logging as well +# 2 - kill and attempt to restart the server as semisync slave that +# must produce an expected unsafe-to-recover error +# 3 - complete the test with a normal restart that successfully finds and +# commits the transaction in doubt. +# +# ==== References ==== +# +# MDEV-21117: recovery for --rpl-semi-sync-slave-enabled server +# + +--source include/have_innodb.inc +--source include/have_debug_sync.inc +--source include/have_binlog_format_row.inc + +SET @@global.max_binlog_size= 4096; + +call mtr.add_suppression("Table '.*tm' is marked as crashed and should be repaired"); +call mtr.add_suppression("Got an error from unknown thread"); +call mtr.add_suppression("Checking table: '.*tm'"); +call mtr.add_suppression("Recovering table: '.*tm'"); +call mtr.add_suppression("Cannot truncate the binary log to file"); +call mtr.add_suppression("Crash recovery failed"); +call mtr.add_suppression("Can.t init tc log"); +call mtr.add_suppression("Aborting"); +call mtr.add_suppression("Found 1 prepared transactions"); +call mtr.add_suppression("mysqld: Table.*tm.*is marked as crashed"); +call mtr.add_suppression("Checking table.*tm"); + +RESET MASTER; +FLUSH LOGS; +CREATE TABLE ti (a INT PRIMARY KEY, b MEDIUMTEXT) ENGINE=Innodb; +CREATE TABLE tm (f INT) ENGINE=MYISAM; + +--let $row_count = 5 +--let $i = `select $row_count-2` +--disable_query_log +while ($i) +{ + --eval INSERT INTO ti VALUES ($i, REPEAT("x", 1)) + --dec $i +} +--enable_query_log +INSERT INTO tm VALUES(1); + +connect(master1,localhost,root,,); +connect(master2,localhost,root,,); +connect(master3,localhost,root,,); + +--connection master1 + +# The 1st trx binlogs, rotate binlog and hold on before committing at engine +SET DEBUG_SYNC= "commit_after_release_LOCK_after_binlog_sync SIGNAL master1_ready WAIT_FOR master1_go"; +--send_eval INSERT INTO ti VALUES ($row_count - 1, REPEAT("x", 4100)) + +--connection master2 + +# The 2nd trx for recovery, it does not rotate binlog +SET DEBUG_SYNC= "commit_before_get_LOCK_commit_ordered SIGNAL master2_ready WAIT_FOR master2_go"; +--send_eval INSERT INTO ti VALUES ($row_count, REPEAT("x", 1)) + +--connection master3 +SET DEBUG_SYNC= "now WAIT_FOR master2_ready"; +SET DEBUG_SYNC= "commit_before_get_LOCK_after_binlog_sync SIGNAL master3_ready"; +--send INSERT INTO tm VALUES (2) + +--connection default +SET DEBUG_SYNC= "now WAIT_FOR master3_ready"; +--echo # The gtid binlog state prior the crash must be restored at the end of the test; +SELECT @@global.gtid_binlog_state; +--source include/kill_mysqld.inc + +# +# Server restarts +# +--echo # Failed restart as the semisync slave +--error 1 +--exec $MYSQLD_LAST_CMD --rpl-semi-sync-slave-enabled=1 >> $MYSQLTEST_VARDIR/log/mysqld.1.err 2>&1 + +--echo # Normal restart +--source include/start_mysqld.inc + +# Check error log for correct messages. +let $log_error_ = $MYSQLTEST_VARDIR/log/mysqld.1.err; + +--let SEARCH_FILE=$log_error_ +--let SEARCH_PATTERN=Cannot truncate the binary log to file +--source include/search_pattern_in_file.inc + +--echo # Proof that the in-doubt transactions are recovered by the 2nd normal server restart +--eval SELECT COUNT(*) = $row_count as 'True' FROM ti +# myisam table may require repair (which is not tested here) +--disable_warnings +SELECT COUNT(*) <= 1 FROM tm; +--enable_warnings + +--echo # The gtid binlog state prior the crash is restored now +SELECT @@GLOBAL.gtid_binlog_state; +SELECT @@GLOBAL.gtid_binlog_pos; + +--echo # Cleanup +DROP TABLE ti, tm; +--echo End of test diff --git a/mysql-test/suite/mariabackup/include/have_rocksdb.inc b/mysql-test/suite/mariabackup/include/have_rocksdb.inc deleted file mode 100644 index d59f76f6cf3..00000000000 --- a/mysql-test/suite/mariabackup/include/have_rocksdb.inc +++ /dev/null @@ -1,4 +0,0 @@ -if (`SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.PLUGINS WHERE PLUGIN_NAME = 'rocksdb'`) -{ - --skip Requires rocksdb -} \ No newline at end of file diff --git a/mysql-test/suite/rpl/r/rpl_semi_sync_fail_over.result b/mysql-test/suite/rpl/r/rpl_semi_sync_fail_over.result new file mode 100644 index 00000000000..233f4acbcc0 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_semi_sync_fail_over.result @@ -0,0 +1,129 @@ +include/master-slave.inc +[connection master] +connection server_2; +include/stop_slave.inc +connection server_1; +RESET MASTER; +SET @@global.max_binlog_size= 4096; +connection server_2; +RESET MASTER; +SET @@global.max_binlog_size= 4096; +set @@global.rpl_semi_sync_slave_enabled = 1; +set @@global.gtid_slave_pos = ""; +CHANGE MASTER TO master_use_gtid= slave_pos; +include/start_slave.inc +connection server_1; +ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB; +set @@global.rpl_semi_sync_master_enabled = 1; +set @@global.rpl_semi_sync_master_wait_point=AFTER_SYNC; +call mtr.add_suppression("Can.t init tc log"); +call mtr.add_suppression("Aborting"); +call mtr.add_suppression("1 client is using or hasn.t closed the table properly"); +call mtr.add_suppression("Table './mtr/test_suppressions' is marked as crashed and should be repaired"); +CREATE TABLE t1 (a INT PRIMARY KEY, b MEDIUMTEXT) ENGINE=Innodb; +INSERT INTO t1 VALUES (1, 'dummy1'); +connect conn_client,127.0.0.1,root,,test,$SERVER_MYPORT_1,; +SET DEBUG_SYNC= "commit_after_release_LOCK_after_binlog_sync SIGNAL con1_ready WAIT_FOR con1_go"; +INSERT INTO t1 VALUES (2, REPEAT("x", 4100)); +connection server_1; +SET DEBUG_SYNC= "now WAIT_FOR con1_ready"; +# Kill the server +connection server_2; +include/stop_slave.inc +SELECT @@GLOBAL.gtid_current_pos; +@@GLOBAL.gtid_current_pos +0-1-8 +# restart: --rpl-semi-sync-slave-enabled=1 +connection server_1; +FOUND 1 /truncated binlog file:.*master.*000001/ in mysqld.1.err +disconnect conn_client; +connection server_2; +set global rpl_semi_sync_master_enabled = 1; +set global rpl_semi_sync_master_wait_point=AFTER_SYNC; +connection server_1; +CHANGE MASTER TO master_host='127.0.0.1', master_port=$new_master_port, master_user='root', master_use_gtid=SLAVE_POS; +set global rpl_semi_sync_slave_enabled = 1; +set @@global.gtid_slave_pos=@@global.gtid_binlog_pos; +include/start_slave.inc +connection server_2; +INSERT INTO t1 VALUES (3, 'dummy3'); +# The gtid state on current master must be equal to ... +SHOW VARIABLES LIKE 'gtid_binlog_pos'; +Variable_name Value +gtid_binlog_pos 0-2-9 +connection server_1; +SELECT COUNT(*) = 3 as 'true' FROM t1; +true +1 +# ... the gtid states on the slave: +SHOW VARIABLES LIKE 'gtid_slave_pos'; +Variable_name Value +gtid_slave_pos 0-2-9 +SHOW VARIABLES LIKE 'gtid_binlog_pos'; +Variable_name Value +gtid_binlog_pos 0-2-9 +connection server_2; +connect conn_client,127.0.0.1,root,,test,$SERVER_MYPORT_2,; +SET DEBUG_SYNC= "commit_after_release_LOCK_after_binlog_sync SIGNAL con1_ready WAIT_FOR con1_go"; +INSERT INTO t1 VALUES (4, REPEAT("x", 4100)); +connect conn_client_2,127.0.0.1,root,,test,$SERVER_MYPORT_2,; +SET DEBUG_SYNC= "now WAIT_FOR con1_ready"; +SET DEBUG_SYNC= "commit_after_release_LOCK_log SIGNAL con1_ready WAIT_FOR con2_go"; +INSERT INTO t1 VALUES (5, REPEAT("x", 4100)); +connection server_2; +SET DEBUG_SYNC= "now WAIT_FOR con1_ready"; +# Kill the server +connection server_1; +include/stop_slave.inc +SELECT @@GLOBAL.gtid_current_pos; +@@GLOBAL.gtid_current_pos +0-2-11 +# restart: --rpl-semi-sync-slave-enabled=1 +connection server_2; +NOT FOUND /truncated binlog file:.*slave.*000001/ in mysqld.2.err +disconnect conn_client; +connection server_1; +set global rpl_semi_sync_master_enabled = 1; +set global rpl_semi_sync_master_wait_point=AFTER_SYNC; +connection server_2; +CHANGE MASTER TO master_host='127.0.0.1', master_port=$new_master_port, master_user='root', master_use_gtid=SLAVE_POS; +set global rpl_semi_sync_slave_enabled = 1; +set @@global.gtid_slave_pos=@@global.gtid_binlog_pos; +include/start_slave.inc +connection server_1; +INSERT INTO t1 VALUES (6, 'Done'); +# The gtid state on current master must be equal to ... +SHOW VARIABLES LIKE 'gtid_binlog_pos'; +Variable_name Value +gtid_binlog_pos 0-1-12 +connection server_2; +SELECT COUNT(*) = 6 as 'true' FROM t1; +true +1 +# ... the gtid states on the slave: +SHOW VARIABLES LIKE 'gtid_slave_pos'; +Variable_name Value +gtid_slave_pos 0-1-12 +SHOW VARIABLES LIKE 'gtid_binlog_pos'; +Variable_name Value +gtid_binlog_pos 0-1-12 +include/diff_tables.inc [server_1:t1, server_2:t1] +# Cleanup +connection server_1; +DROP TABLE t1; +connection server_2; +include/stop_slave.inc +connection server_1; +set @@global.rpl_semi_sync_master_enabled = 0; +set @@global.rpl_semi_sync_slave_enabled = 0; +set @@global.rpl_semi_sync_master_wait_point=default; +RESET SLAVE; +RESET MASTER; +connection server_2; +set @@global.rpl_semi_sync_master_enabled = 0; +set @@global.rpl_semi_sync_slave_enabled = 0; +set @@global.rpl_semi_sync_master_wait_point=default; +CHANGE MASTER TO master_host='127.0.0.1', master_port=$SERVER_MYPORT_1, master_user='root', master_use_gtid=no; +include/start_slave.inc +connection default; +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_semi_sync_crash.inc b/mysql-test/suite/rpl/t/rpl_semi_sync_crash.inc new file mode 100644 index 00000000000..1f24c42f680 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_semi_sync_crash.inc @@ -0,0 +1,77 @@ +if ($failover_to_slave) +{ + --let $server_to_crash=1 + --let $server_to_promote=2 + --let $new_master_port=$SERVER_MYPORT_2 + --let $client_port=$SERVER_MYPORT_1 + + --connect (conn_client,127.0.0.1,root,,test,$SERVER_MYPORT_1,) +} +if (!$failover_to_slave) +{ + --let $server_to_crash=2 + --let $server_to_promote=1 + --let $new_master_port=$SERVER_MYPORT_1 + --let $client_port=$SERVER_MYPORT_2 + + --connect (conn_client,127.0.0.1,root,,test,$SERVER_MYPORT_2,) +} + + +# Hold insert after write to binlog and before "run_commit_ordered" in engine + +SET DEBUG_SYNC= "commit_after_release_LOCK_after_binlog_sync SIGNAL con1_ready WAIT_FOR con1_go"; +--send_eval $query_to_crash + +# complicate recovery with an extra binlog file +if (!$failover_to_slave) +{ + --connect (conn_client_2,127.0.0.1,root,,test,$SERVER_MYPORT_2,) + # use the same signal with $query_to_crash + SET DEBUG_SYNC= "now WAIT_FOR con1_ready"; + SET DEBUG_SYNC= "commit_after_release_LOCK_log SIGNAL con1_ready WAIT_FOR con2_go"; + --send_eval $query2_to_crash +} + +--connection server_$server_to_crash +SET DEBUG_SYNC= "now WAIT_FOR con1_ready"; +--source include/kill_mysqld.inc + +--connection server_$server_to_promote +--error 2003 +--source include/stop_slave.inc +SELECT @@GLOBAL.gtid_current_pos; + +--let $restart_parameters=--rpl-semi-sync-slave-enabled=1 +--let $allow_rpl_inited=1 +--source include/start_mysqld.inc + +--connection server_$server_to_crash +--enable_reconnect +--source include/wait_until_connected_again.inc + +# Check error log for correct messages. +let $log_error_ = $MYSQLTEST_VARDIR/log/mysqld.$server_to_crash.err; +--let SEARCH_FILE=$log_error_ +--let SEARCH_PATTERN=$log_search_pattern +--source include/search_pattern_in_file.inc + +--disconnect conn_client + +# +# FAIL OVER now to new master +# +--connection server_$server_to_promote +set global rpl_semi_sync_master_enabled = 1; +set global rpl_semi_sync_master_wait_point=AFTER_SYNC; + +--connection server_$server_to_crash +--let $master_port=$SERVER_MYPORT_2 +if (`select $server_to_crash = 2`) +{ + --let $master_port=$SERVER_MYPORT_1 +} +evalp CHANGE MASTER TO master_host='127.0.0.1', master_port=$new_master_port, master_user='root', master_use_gtid=SLAVE_POS; +set global rpl_semi_sync_slave_enabled = 1; +set @@global.gtid_slave_pos=@@global.gtid_binlog_pos; +--source include/start_slave.inc diff --git a/mysql-test/suite/rpl/t/rpl_semi_sync_fail_over.cnf b/mysql-test/suite/rpl/t/rpl_semi_sync_fail_over.cnf new file mode 100644 index 00000000000..f8312bdc5b8 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_semi_sync_fail_over.cnf @@ -0,0 +1,11 @@ +!include suite/rpl/rpl_1slave_base.cnf +!include include/default_client.cnf + + +[mysqld.1] +log-slave-updates +gtid-strict-mode=1 + +[mysqld.2] +log-slave-updates +gtid-strict-mode=1 diff --git a/mysql-test/suite/rpl/t/rpl_semi_sync_fail_over.test b/mysql-test/suite/rpl/t/rpl_semi_sync_fail_over.test new file mode 100644 index 00000000000..2c38cf4da54 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_semi_sync_fail_over.test @@ -0,0 +1,144 @@ +# ==== Purpose ==== +# +# Test verifies replication failover scenario. +# +# ==== Implementation ==== +# +# Steps: +# 0 - Having two servers 1 and 2 enable semi-sync replication with +# with the master wait 'after_sync'. +# 1 - Insert a row. While inserting second row simulate +# a server crash at once the transaction is written to binlog, flushed +# and synced but the binlog position is not updated. +# 2 - Post crash-recovery on the old master execute there CHANGE MASTER +# TO command to connect to server id 2. +# 3 - The old master new slave server 1 must connect to the new +# master server 2. +# 4 - repeat the above to crash the new master and restore in role the old one +# +# ==== References ==== +# +# MDEV-21117: recovery for --rpl-semi-sync-slave-enabled server + + +--source include/have_innodb.inc +--source include/have_debug_sync.inc +--source include/have_binlog_format_row.inc +--source include/master-slave.inc + +# Initial slave +--connection server_2 +--source include/stop_slave.inc + +# Initial master +--connection server_1 +RESET MASTER; +SET @@global.max_binlog_size= 4096; + +--connection server_2 +RESET MASTER; +SET @@global.max_binlog_size= 4096; +set @@global.rpl_semi_sync_slave_enabled = 1; +set @@global.gtid_slave_pos = ""; +CHANGE MASTER TO master_use_gtid= slave_pos; +--source include/start_slave.inc + + +--connection server_1 +ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB; +set @@global.rpl_semi_sync_master_enabled = 1; +set @@global.rpl_semi_sync_master_wait_point=AFTER_SYNC; + +call mtr.add_suppression("Can.t init tc log"); +call mtr.add_suppression("Aborting"); +call mtr.add_suppression("1 client is using or hasn.t closed the table properly"); +call mtr.add_suppression("Table './mtr/test_suppressions' is marked as crashed and should be repaired"); + +CREATE TABLE t1 (a INT PRIMARY KEY, b MEDIUMTEXT) ENGINE=Innodb; +INSERT INTO t1 VALUES (1, 'dummy1'); + +# +# CRASH the original master, and FAILOVER to the new +# + +# value 1 for server id 1 -> 2 failover +--let $failover_to_slave=1 +--let $query_to_crash= INSERT INTO t1 VALUES (2, REPEAT("x", 4100)) +--let $log_search_pattern=truncated binlog file:.*master.*000001 +--source rpl_semi_sync_crash.inc + +--connection server_2 +--let $rows_so_far=3 +--eval INSERT INTO t1 VALUES ($rows_so_far, 'dummy3') +--save_master_pos +--echo # The gtid state on current master must be equal to ... +SHOW VARIABLES LIKE 'gtid_binlog_pos'; + +--connection server_1 +--sync_with_master +--eval SELECT COUNT(*) = $rows_so_far as 'true' FROM t1 +--echo # ... the gtid states on the slave: +SHOW VARIABLES LIKE 'gtid_slave_pos'; +SHOW VARIABLES LIKE 'gtid_binlog_pos'; + +--connection server_2 +# +# CRASH the new master and FAILOVER back to the original +# + +# value 0 for the reverse server id 2 -> 1 failover +--let $failover_to_slave=0 +--let $query_to_crash = INSERT INTO t1 VALUES (4, REPEAT("x", 4100)) +--let $query2_to_crash= INSERT INTO t1 VALUES (5, REPEAT("x", 4100)) +--let $log_search_pattern=truncated binlog file:.*slave.*000001 +--source rpl_semi_sync_crash.inc + +--connection server_1 +--let $rows_so_far=6 +--eval INSERT INTO t1 VALUES ($rows_so_far, 'Done') +--save_master_pos +--echo # The gtid state on current master must be equal to ... +SHOW VARIABLES LIKE 'gtid_binlog_pos'; + +--connection server_2 +--sync_with_master +--eval SELECT COUNT(*) = $rows_so_far as 'true' FROM t1 +--echo # ... the gtid states on the slave: +SHOW VARIABLES LIKE 'gtid_slave_pos'; +SHOW VARIABLES LIKE 'gtid_binlog_pos'; + + +--let $diff_tables=server_1:t1, server_2:t1 +--source include/diff_tables.inc + +# +--echo # Cleanup +# +--connection server_1 +DROP TABLE t1; +--save_master_pos + +--connection server_2 +--sync_with_master +--source include/stop_slave.inc + +--connection server_1 +set @@global.rpl_semi_sync_master_enabled = 0; +set @@global.rpl_semi_sync_slave_enabled = 0; +set @@global.rpl_semi_sync_master_wait_point=default; +RESET SLAVE; +RESET MASTER; + +--connection server_2 +set @@global.rpl_semi_sync_master_enabled = 0; +set @@global.rpl_semi_sync_slave_enabled = 0; +set @@global.rpl_semi_sync_master_wait_point=default; + +evalp CHANGE MASTER TO master_host='127.0.0.1', master_port=$SERVER_MYPORT_1, master_user='root', master_use_gtid=no; +--source include/start_slave.inc + +connection default; +--enable_reconnect +--source include/wait_until_connected_again.inc + +--source include/rpl_end.inc diff --git a/sql/handler.cc b/sql/handler.cc index fc2c46395c3..78ee18a4542 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -1508,6 +1508,24 @@ uint ha_count_rw_all(THD *thd, Ha_trx_info **ptr_ha_info) return rw_ha_count; } +/* + Returns counted number of + read-write recoverable transaction participants. +*/ +uint ha_count_rw_2pc(THD *thd, bool all) +{ + unsigned rw_ha_count= 0; + THD_TRANS *trans=all ? &thd->transaction->all : &thd->transaction->stmt; + + for (Ha_trx_info * ha_info= trans->ha_list; ha_info; + ha_info= ha_info->next()) + { + if (ha_info->is_trx_read_write() && ha_info->ht()->recover) + ++rw_ha_count; + } + return rw_ha_count; +} + /** Check if we can skip the two-phase commit. @@ -1527,7 +1545,6 @@ uint ha_count_rw_all(THD *thd, Ha_trx_info **ptr_ha_info) engines with read-write changes. */ -static uint ha_check_and_coalesce_trx_read_only(THD *thd, Ha_trx_info *ha_list, bool all) @@ -1978,6 +1995,24 @@ int ha_commit_one_phase(THD *thd, bool all) DBUG_RETURN(res); } +static bool is_ro_1pc_trans(THD *thd, Ha_trx_info *ha_info, bool all, + bool is_real_trans) +{ + uint rw_ha_count= ha_check_and_coalesce_trx_read_only(thd, ha_info, all); + bool rw_trans= is_real_trans && + (rw_ha_count > (thd->is_current_stmt_binlog_disabled()?0U:1U)); + + return !rw_trans; +} + +static bool has_binlog_hton(Ha_trx_info *ha_info) +{ + bool rc; + for (rc= false; ha_info && !rc; ha_info= ha_info->next()) + rc= ha_info->ht() == binlog_hton; + + return rc; +} static int commit_one_phase_2(THD *thd, bool all, THD_TRANS *trans, bool is_real_trans) @@ -1991,9 +2026,17 @@ commit_one_phase_2(THD *thd, bool all, THD_TRANS *trans, bool is_real_trans) if (ha_info) { + int err; + + if (has_binlog_hton(ha_info) && + (err= binlog_commit(thd, all, + is_ro_1pc_trans(thd, ha_info, all, is_real_trans)))) + { + my_error(ER_ERROR_DURING_COMMIT, MYF(0), err); + error= 1; + } for (; ha_info; ha_info= ha_info_next) { - int err; handlerton *ht= ha_info->ht(); if ((err= ht->commit(ht, thd, all))) { @@ -2219,6 +2262,15 @@ int ha_commit_or_rollback_by_xid(XID *xid, bool commit) xaop.xid= xid; xaop.result= 1; + /* + When the binlogging service is enabled complete the transaction + by it first. + */ + if (commit) + binlog_commit_by_xid(binlog_hton, xid); + else + binlog_rollback_by_xid(binlog_hton, xid); + plugin_foreach(NULL, commit ? xacommit_handlerton : xarollback_handlerton, MYSQL_STORAGE_ENGINE_PLUGIN, &xaop); @@ -2314,7 +2366,7 @@ static my_xid wsrep_order_and_check_continuity(XID *list, int len) recover() step of xa. @note - there are three modes of operation: + there are four modes of operation: - automatic recover after a crash in this case commit_list != 0, tc_heuristic_recover==0 all xids from commit_list are committed, others are rolled back @@ -2325,6 +2377,9 @@ static my_xid wsrep_order_and_check_continuity(XID *list, int len) - no recovery (MySQL did not detect a crash) in this case commit_list==0, tc_heuristic_recover == 0 there should be no prepared transactions in this case. + - automatic recovery for the semisync slave server: uncommitted + transactions are rolled back and when they are in binlog it gets + truncated to the first uncommitted transaction start offset. */ struct xarecover_st { @@ -2332,8 +2387,181 @@ struct xarecover_st XID *list; HASH *commit_list; bool dry_run; + MEM_ROOT *mem_root; + bool error; }; +/** + Inserts a new hash member. + + returns a successfully created and inserted @c xid_recovery_member + into hash @c hash_arg, + or NULL. +*/ +static xid_recovery_member* +xid_member_insert(HASH *hash_arg, my_xid xid_arg, MEM_ROOT *ptr_mem_root) +{ + xid_recovery_member *member= (xid_recovery_member*) + alloc_root(ptr_mem_root, sizeof(xid_recovery_member)); + if (!member) + return NULL; + + member->xid= xid_arg; + member->in_engine_prepare= 1; + member->decided_to_commit= false; + + return my_hash_insert(hash_arg, (uchar*) member) ? NULL : member; +} + +/* + Inserts a new or updates an existing hash member to increment + the member's prepare counter. + + returns false on success, + true otherwise. +*/ +static bool xid_member_replace(HASH *hash_arg, my_xid xid_arg, + MEM_ROOT *ptr_mem_root) +{ + xid_recovery_member* member; + if ((member= (xid_recovery_member *) + my_hash_search(hash_arg, (uchar *)& xid_arg, sizeof(xid_arg)))) + member->in_engine_prepare++; + else + member= xid_member_insert(hash_arg, xid_arg, ptr_mem_root); + + return member == NULL; +} + +/* + A "transport" type for recovery completion with ha_recover_complete() +*/ +struct xarecover_complete_arg +{ + xid_recovery_member* member; + Binlog_offset *binlog_coord; + uint count; +}; + +/* + Flagged to commit member confirms to get committed. + Otherwise when + A. ptr_commit_max is NULL (implies the normal recovery), or + B. it's not NULL (can only be so in the semisync slave case) + and the value referenced is not greater than the member's coordinate + the decision is to rollback. + When both A,B do not hold - which is the semisync slave recovery + case - the decision is to commit. + + Returns true as commmit decision + false as rollback one +*/ +static bool xarecover_decide_to_commit(xid_recovery_member* member, + Binlog_offset *ptr_commit_max) +{ + return + member->decided_to_commit ? true : + !ptr_commit_max ? false : + (member->binlog_coord < *ptr_commit_max ? // semisync slave recovery + true : false); +} + +/* + Helper function for xarecover_do_commit_or_rollback_handlerton. + For a given hton decides what to do with a xid passed in the 2nd arg + and carries out the decision. +*/ +static void xarecover_do_commit_or_rollback(handlerton *hton, + xarecover_complete_arg *arg) +{ + xid_t x; + my_bool rc; + xid_recovery_member *member= arg->member; + Binlog_offset *ptr_commit_max= arg->binlog_coord; + + x.set(member->xid); + + rc= xarecover_decide_to_commit(member, ptr_commit_max) ? + hton->commit_by_xid(hton, &x) : hton->rollback_by_xid(hton, &x); + + /* + It's fine to have non-zero rc which would be from transaction + non-participant hton:s. + */ + DBUG_ASSERT(rc || member->in_engine_prepare > 0); + + if (!rc) + { + /* + This block relies on Engine to report XAER_NOTA at + "complete"_by_xid for unknown xid. + */ + member->in_engine_prepare--; + if (global_system_variables.log_warnings > 2) + sql_print_information("%s transaction with xid %llu", + member->decided_to_commit ? "Committed" : + "Rolled back", (ulonglong) member->xid); + } +} + +/* + Per hton recovery decider function. +*/ +static my_bool xarecover_do_commit_or_rollback_handlerton(THD *unused, + plugin_ref plugin, + void *arg) +{ + handlerton *hton= plugin_hton(plugin); + + if (hton->recover) + { + xarecover_do_commit_or_rollback(hton, (xarecover_complete_arg *) arg); + } + + return FALSE; +} + +/* + Completes binlog recovery for an input xid in the passed + member_arg to invoke decider functions for each handlerton. + + Returns always FALSE. +*/ +static my_bool xarecover_complete_and_count(void *member_arg, + void *param_arg) +{ + xid_recovery_member *member= (xid_recovery_member*) member_arg; + xarecover_complete_arg *complete_params= + (xarecover_complete_arg*) param_arg; + complete_params->member= member; + + (void) plugin_foreach(NULL, xarecover_do_commit_or_rollback_handlerton, + MYSQL_STORAGE_ENGINE_PLUGIN, complete_params); + + if (member->in_engine_prepare) + { + complete_params->count++; + if (global_system_variables.log_warnings > 2) + sql_print_warning("Found prepared transaction with xid %llu", + (ulonglong) member->xid); + } + + return false; +} + +/* + Completes binlog recovery to invoke decider functions for + each xid. + Returns the number of transactions remained doubtful. +*/ +uint ha_recover_complete(HASH *commit_list, Binlog_offset *coord) +{ + xarecover_complete_arg complete= { NULL, coord, 0 }; + (void) my_hash_iterate(commit_list, xarecover_complete_and_count, &complete); + + return complete.count; +} + static my_bool xarecover_handlerton(THD *unused, plugin_ref plugin, void *arg) { @@ -2395,7 +2623,20 @@ static my_bool xarecover_handlerton(THD *unused, plugin_ref plugin, info->found_my_xids++; continue; } - // recovery mode + + /* + Regular and semisync slave server recovery only collects + xids to make decisions on them later by the caller. + */ + if (info->mem_root) + { + if (xid_member_replace(info->commit_list, x, info->mem_root)) + { + info->error= true; + sql_print_error("Error in memory allocation at xarecover_handlerton"); + break; + } + } else if (IF_WSREP((wsrep_emulate_bin_log && wsrep_is_wsrep_xid(info->list + i) && x <= wsrep_limit), false) || @@ -2431,7 +2672,7 @@ static my_bool xarecover_handlerton(THD *unused, plugin_ref plugin, return FALSE; } -int ha_recover(HASH *commit_list) +int ha_recover(HASH *commit_list, MEM_ROOT *arg_mem_root) { struct xarecover_st info; DBUG_ENTER("ha_recover"); @@ -2439,6 +2680,8 @@ int ha_recover(HASH *commit_list) info.commit_list= commit_list; info.dry_run= (info.commit_list==0 && tc_heuristic_recover==0); info.list= NULL; + info.mem_root= arg_mem_root; + info.error= false; /* commit_list and tc_heuristic_recover cannot be set both */ DBUG_ASSERT(info.commit_list==0 || tc_heuristic_recover==0); @@ -2483,6 +2726,9 @@ int ha_recover(HASH *commit_list) info.found_my_xids, opt_tc_log_file); DBUG_RETURN(1); } + if (info.error) + DBUG_RETURN(1); + if (info.commit_list) sql_print_information("Crash table recovery finished."); DBUG_RETURN(0); diff --git a/sql/handler.h b/sql/handler.h index a7c455ae7c9..d2bb514f5cf 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -44,6 +44,7 @@ #include #include "sql_sequence.h" #include "mem_root_array.h" +#include // pair class Alter_info; class Virtual_column_info; @@ -931,6 +932,32 @@ struct xid_t { }; typedef struct xid_t XID; +/* + Enumerates a sequence in the order of + their creation that is in the top-down order of the index file. + Ranges from zero through MAX_binlog_id. + Not confuse the value with the binlog file numerical suffix, + neither with the binlog file line in the binlog index file. +*/ +typedef uint Binlog_file_id; +const Binlog_file_id MAX_binlog_id= UINT_MAX; +/* + Compound binlog-id and byte offset of transaction's first event + in a sequence (e.g the recovery sequence) of binlog files. + Binlog_offset(0,0) is the minimum value to mean + the first byte of the first binlog file. +*/ +typedef std::pair Binlog_offset; + +/* binlog-based recovery transaction descriptor */ +struct xid_recovery_member +{ + my_xid xid; + uint in_engine_prepare; // number of engines that have xid prepared + bool decided_to_commit; + Binlog_offset binlog_coord; // semisync recovery binlog offset +}; + /* for recover() handlerton call */ #define MIN_XID_LIST_SIZE 128 #define MAX_XID_LIST_SIZE (1024*128) @@ -5320,7 +5347,8 @@ int ha_commit_one_phase(THD *thd, bool all); int ha_commit_trans(THD *thd, bool all); int ha_rollback_trans(THD *thd, bool all); int ha_prepare(THD *thd); -int ha_recover(HASH *commit_list); +int ha_recover(HASH *commit_list, MEM_ROOT *mem_root= NULL); +uint ha_recover_complete(HASH *commit_list, Binlog_offset *coord= NULL); /* transactions: these functions never call handlerton functions directly */ int ha_enable_transaction(THD *thd, bool on); @@ -5448,4 +5476,8 @@ int del_global_index_stat(THD *thd, TABLE* table, KEY* key_info); int del_global_table_stat(THD *thd, const LEX_CSTRING *db, const LEX_CSTRING *table); uint ha_count_rw_all(THD *thd, Ha_trx_info **ptr_ha_info); bool non_existing_table_error(int error); +uint ha_count_rw_2pc(THD *thd, bool all); +uint ha_check_and_coalesce_trx_read_only(THD *thd, Ha_trx_info *ha_list, + bool all); + #endif /* HANDLER_INCLUDED */ diff --git a/sql/log.cc b/sql/log.cc index f1fef44e05f..047d644e5da 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -63,6 +63,12 @@ #include "wsrep_trans_observer.h" #endif /* WITH_WSREP */ +#ifdef HAVE_REPLICATION +#include "semisync_master.h" +#include "semisync_slave.h" +#include // pair +#endif + /* max size of the log message */ #define MAX_LOG_BUFFER_SIZE 1024 #define MAX_TIME_SIZE 32 @@ -88,16 +94,12 @@ static int binlog_savepoint_set(handlerton *hton, THD *thd, void *sv); static int binlog_savepoint_rollback(handlerton *hton, THD *thd, void *sv); static bool binlog_savepoint_rollback_can_release_mdl(handlerton *hton, THD *thd); -static int binlog_commit(handlerton *hton, THD *thd, bool all); static int binlog_rollback(handlerton *hton, THD *thd, bool all); static int binlog_prepare(handlerton *hton, THD *thd, bool all); -static int binlog_xa_recover_dummy(handlerton *hton, XID *xid_list, uint len); -static int binlog_commit_by_xid(handlerton *hton, XID *xid); -static int binlog_rollback_by_xid(handlerton *hton, XID *xid); static int binlog_start_consistent_snapshot(handlerton *hton, THD *thd); static int binlog_flush_cache(THD *thd, binlog_cache_mngr *cache_mngr, Log_event *end_ev, bool all, bool using_stmt, - bool using_trx); + bool using_trx, bool is_ro_1pc); static const LEX_CSTRING write_error_msg= { STRING_WITH_LEN("error writing to the binary log") }; @@ -1693,17 +1695,13 @@ int binlog_init(void *p) binlog_hton->savepoint_rollback= binlog_savepoint_rollback; binlog_hton->savepoint_rollback_can_release_mdl= binlog_savepoint_rollback_can_release_mdl; - binlog_hton->commit= binlog_commit; + binlog_hton->commit= [](handlerton *, THD *thd, bool all) { return 0; }; binlog_hton->rollback= binlog_rollback; binlog_hton->drop_table= [](handlerton *, const char*) { return -1; }; if (WSREP_ON || opt_bin_log) { binlog_hton->prepare= binlog_prepare; binlog_hton->start_consistent_snapshot= binlog_start_consistent_snapshot; - binlog_hton->commit_by_xid= binlog_commit_by_xid; - binlog_hton->rollback_by_xid= binlog_rollback_by_xid; - // recover needs to be set to make xa{commit,rollback}_handlerton effective - binlog_hton->recover= binlog_xa_recover_dummy; } binlog_hton->flags= HTON_NOT_USER_SELECTABLE | HTON_HIDDEN | HTON_NO_ROLLBACK; return 0; @@ -1770,7 +1768,7 @@ static int binlog_close_connection(handlerton *hton, THD *thd) static int binlog_flush_cache(THD *thd, binlog_cache_mngr *cache_mngr, Log_event *end_ev, bool all, bool using_stmt, - bool using_trx) + bool using_trx, bool is_ro_1pc= false) { int error= 0; DBUG_ENTER("binlog_flush_cache"); @@ -1797,7 +1795,8 @@ binlog_flush_cache(THD *thd, binlog_cache_mngr *cache_mngr, */ error= mysql_bin_log.write_transaction_to_binlog(thd, cache_mngr, end_ev, all, - using_stmt, using_trx); + using_stmt, using_trx, + is_ro_1pc); } else { @@ -1871,7 +1870,8 @@ inline size_t serialize_with_xid(XID *xid, char *buf, nonzero if an error pops up when flushing the cache. */ static inline int -binlog_commit_flush_trx_cache(THD *thd, bool all, binlog_cache_mngr *cache_mngr) +binlog_commit_flush_trx_cache(THD *thd, bool all, binlog_cache_mngr *cache_mngr, + bool ro_1pc) { DBUG_ENTER("binlog_commit_flush_trx_cache"); @@ -1892,7 +1892,7 @@ binlog_commit_flush_trx_cache(THD *thd, bool all, binlog_cache_mngr *cache_mngr) } Query_log_event end_evt(thd, buf, buflen, TRUE, TRUE, TRUE, 0); - DBUG_RETURN(binlog_flush_cache(thd, cache_mngr, &end_evt, all, FALSE, TRUE)); + DBUG_RETURN(binlog_flush_cache(thd, cache_mngr, &end_evt, all, FALSE, TRUE, ro_1pc)); } @@ -2011,35 +2011,30 @@ inline bool is_preparing_xa(THD *thd) static int binlog_prepare(handlerton *hton, THD *thd, bool all) { /* Do nothing unless the transaction is a user XA. */ - return is_preparing_xa(thd) ? binlog_commit(NULL, thd, all) : 0; + return is_preparing_xa(thd) ? binlog_commit(thd, all, FALSE) : 0; } -static int binlog_xa_recover_dummy(handlerton *hton __attribute__((unused)), - XID *xid_list __attribute__((unused)), - uint len __attribute__((unused))) -{ - /* Does nothing. */ - return 0; -} - - -static int binlog_commit_by_xid(handlerton *hton, XID *xid) +int binlog_commit_by_xid(handlerton *hton, XID *xid) { THD *thd= current_thd; + if (thd->is_current_stmt_binlog_disabled()) + return 0; (void) thd->binlog_setup_trx_data(); DBUG_ASSERT(thd->lex->sql_command == SQLCOM_XA_COMMIT); - return binlog_commit(hton, thd, TRUE); + return binlog_commit(thd, TRUE, FALSE); } -static int binlog_rollback_by_xid(handlerton *hton, XID *xid) +int binlog_rollback_by_xid(handlerton *hton, XID *xid) { THD *thd= current_thd; + if (thd->is_current_stmt_binlog_disabled()) + return 0; (void) thd->binlog_setup_trx_data(); DBUG_ASSERT(thd->lex->sql_command == SQLCOM_XA_ROLLBACK || @@ -2123,20 +2118,17 @@ static int binlog_commit_flush_xa_prepare(THD *thd, bool all, return (binlog_flush_cache(thd, cache_mngr, &end_evt, all, TRUE, TRUE)); } - /** This function is called once after each statement. It has the responsibility to flush the caches to the binary log on commits. - @param hton The binlog handlerton. @param thd The client thread that executes the transaction. @param all This is @c true if this is a real transaction commit, and @false otherwise. - - @see handlerton::commit + @param ro_1pc read-only one-phase commit transaction */ -static int binlog_commit(handlerton *hton, THD *thd, bool all) +int binlog_commit(THD *thd, bool all, bool ro_1pc) { int error= 0; PSI_stage_info org_stage; @@ -2168,7 +2160,6 @@ static int binlog_commit(handlerton *hton, THD *thd, bool all) YESNO(thd->transaction->all.modified_non_trans_table), YESNO(thd->transaction->stmt.modified_non_trans_table))); - thd->backup_stage(&org_stage); THD_STAGE_INFO(thd, stage_binlog_write); if (!cache_mngr->stmt_cache.empty()) @@ -2197,8 +2188,9 @@ static int binlog_commit(handlerton *hton, THD *thd, bool all) { error= is_preparing_xa(thd) ? binlog_commit_flush_xa_prepare(thd, all, cache_mngr) : - binlog_commit_flush_trx_cache (thd, all, cache_mngr); + binlog_commit_flush_trx_cache (thd, all, cache_mngr, ro_1pc); } + /* This is part of the stmt rollback. */ @@ -6228,7 +6220,8 @@ MYSQL_BIN_LOG::flush_and_set_pending_rows_event(THD *thd, bool MYSQL_BIN_LOG::write_gtid_event(THD *thd, bool standalone, - bool is_transactional, uint64 commit_id) + bool is_transactional, uint64 commit_id, + bool has_xid, bool is_ro_1pc) { rpl_gtid gtid; uint32 domain_id; @@ -6281,7 +6274,7 @@ MYSQL_BIN_LOG::write_gtid_event(THD *thd, bool standalone, Gtid_log_event gtid_event(thd, seq_no, domain_id, standalone, LOG_EVENT_SUPPRESS_USE_F, is_transactional, - commit_id); + commit_id, has_xid, is_ro_1pc); /* Write the event to the binary log. */ DBUG_ASSERT(this == &mysql_bin_log); @@ -7610,7 +7603,8 @@ MYSQL_BIN_LOG::write_transaction_to_binlog(THD *thd, binlog_cache_mngr *cache_mngr, Log_event *end_ev, bool all, bool using_stmt_cache, - bool using_trx_cache) + bool using_trx_cache, + bool is_ro_1pc) { group_commit_entry entry; Ha_trx_info *ha_info; @@ -7639,6 +7633,7 @@ MYSQL_BIN_LOG::write_transaction_to_binlog(THD *thd, entry.using_trx_cache= using_trx_cache; entry.need_unlog= is_preparing_xa(thd); ha_info= all ? thd->transaction->all.ha_list : thd->transaction->stmt.ha_list; + entry.ro_1pc= is_ro_1pc; for (; !entry.need_unlog && ha_info; ha_info= ha_info->next()) { @@ -8513,10 +8508,13 @@ MYSQL_BIN_LOG::write_transaction_or_stmt(group_commit_entry *entry, uint64 commit_id) { binlog_cache_mngr *mngr= entry->cache_mngr; + bool has_xid= entry->end_event->get_type_code() == XID_EVENT; + DBUG_ENTER("MYSQL_BIN_LOG::write_transaction_or_stmt"); if (write_gtid_event(entry->thd, is_prepared_xa(entry->thd), - entry->using_trx_cache, commit_id)) + entry->using_trx_cache, commit_id, + has_xid, entry->ro_1pc)) DBUG_RETURN(ER_ERROR_ON_WRITE); if (entry->using_stmt_cache && !mngr->stmt_cache.empty() && @@ -9247,6 +9245,11 @@ TC_LOG::run_commit_ordered(THD *thd, bool all) if (!ht->commit_ordered) continue; ht->commit_ordered(ht, thd, all); + DBUG_EXECUTE_IF("enable_log_write_upto_crash", + { + DBUG_SET_INITIAL("+d,crash_after_log_write_upto"); + sleep(1000); + }); DEBUG_SYNC(thd, "commit_after_run_commit_ordered"); } } @@ -9979,6 +9982,151 @@ int TC_LOG::using_heuristic_recover() /****** transaction coordinator log for 2pc - binlog() based solution ******/ #define TC_LOG_BINLOG MYSQL_BIN_LOG +/** + Truncates the current binlog to specified position. Removes the rest of binlogs + which are present after this binlog file. + + @param truncate_file Holds the binlog name to be truncated + @param truncate_pos Position within binlog from where it needs to + truncated. + + @retval true ok + @retval false error + +*/ +bool MYSQL_BIN_LOG::truncate_and_remove_binlogs(const char *file_name, + my_off_t pos, + rpl_gtid *ptr_gtid) +{ + int error= 0; +#ifdef HAVE_REPLICATION + LOG_INFO log_info; + THD *thd= current_thd; + my_off_t index_file_offset= 0; + File file= -1; + MY_STAT s; + my_off_t old_size; + + if ((error= find_log_pos(&log_info, file_name, 1))) + { + sql_print_error("Failed to locate binary log file:%s." + "Error:%d", file_name, error); + goto end; + } + + while (!(error= find_next_log(&log_info, 1))) + { + if (!index_file_offset) + { + index_file_offset= log_info.index_file_start_offset; + if ((error= open_purge_index_file(TRUE))) + { + sql_print_error("Failed to open purge index " + "file:%s. Error:%d", purge_index_file_name, error); + goto end; + } + } + if ((error= register_purge_index_entry(log_info.log_file_name))) + { + sql_print_error("Failed to copy %s to purge index" + " file. Error:%d", log_info.log_file_name, error); + goto end; + } + } + + if (error != LOG_INFO_EOF) + { + sql_print_error("Failed to find the next binlog to " + "add to purge index register. Error:%d", error); + goto end; + } + + if (is_inited_purge_index_file()) + { + if (!index_file_offset) + index_file_offset= log_info.index_file_start_offset; + + if ((error= sync_purge_index_file())) + { + sql_print_error("Failed to flush purge index " + "file. Error:%d", error); + goto end; + } + + // Trim index file + error= mysql_file_chsize(index_file.file, index_file_offset, '\n', + MYF(MY_WME)); + if (!error) + error= mysql_file_sync(index_file.file, MYF(MY_WME|MY_SYNC_FILESIZE)); + if (error) + { + sql_print_error("Failed to truncate binlog index " + "file:%s to offset:%llu. Error:%d", index_file_name, + index_file_offset, error); + goto end; + } + + /* Reset data in old index cache */ + if ((error= reinit_io_cache(&index_file, READ_CACHE, (my_off_t) 0, 0, 1))) + { + sql_print_error("Failed to reinit binlog index " + "file. Error:%d", error); + goto end; + } + + /* Read each entry from purge_index_file and delete the file. */ + if ((error= purge_index_entry(thd, NULL, TRUE))) + { + sql_print_error("Failed to process registered " + "files that would be purged."); + goto end; + } + } + + DBUG_ASSERT(pos); + + if ((file= mysql_file_open(key_file_binlog, file_name, + O_RDWR | O_BINARY, MYF(MY_WME))) < 0) + { + error= 1; + sql_print_error("Failed to open binlog file:%s for " + "truncation.", file_name); + goto end; + } + my_stat(file_name, &s, MYF(0)); + old_size= s.st_size; + clear_inuse_flag_when_closing(file); + /* Change binlog file size to truncate_pos */ + error= mysql_file_chsize(file, pos, 0, MYF(MY_WME)); + if (!error) + error= mysql_file_sync(file, MYF(MY_WME|MY_SYNC_FILESIZE)); + if (error) + { + sql_print_error("Failed to truncate the " + "binlog file:%s to size:%llu. Error:%d", + file_name, pos, error); + goto end; + } + else + { + char buf[21]; + longlong10_to_str(ptr_gtid->seq_no, buf, 10); + sql_print_information("Successfully truncated binlog file:%s " + "from previous file size %llu " + "to pos:%llu to remove transactions starting from " + "GTID %u-%u-%s", + file_name, old_size, pos, + ptr_gtid->domain_id, ptr_gtid->server_id, buf); + } + +end: + if (file >= 0) + mysql_file_close(file, MYF(MY_WME)); + + error= error || close_purge_index_file(); +#endif + return error > 0; +} int TC_LOG_BINLOG::open(const char *opt_name) { int error= 1; @@ -10454,7 +10602,520 @@ start_binlog_background_thread() return 0; } +#ifdef HAVE_REPLICATION +class Recovery_context +{ +public: + my_off_t prev_event_pos; + rpl_gtid last_gtid; + bool last_gtid_standalone; + bool last_gtid_valid; + bool last_gtid_no2pc; // true when the group does not end with Xid event + uint last_gtid_engines; + Binlog_offset last_gtid_coord; // + /* + When true, it's semisync slave recovery mode + rolls back transactions in doubt and wipes them off from binlog. + The rest of declarations deal with this type of recovery. + */ + bool do_truncate; + /* + transaction-in-doubt's gtid:s. `truncate_gtid` is the ultimate value, + if it's non-zero truncation is taking place to start from it. + Its value gets refined throughout binlog scanning conducted with at most + 2 rounds. + When an estimate is done in the 1st round of 2-round recovery its value + gets memorized for possible adoption as the ultimate `truncate_gtid`. + */ + rpl_gtid truncate_gtid, truncate_gtid_1st_round; + /* + the last non-transactional group that is located in binlog + behind truncate_gtid. + */ + rpl_gtid binlog_unsafe_gtid; + char binlog_truncate_file_name[FN_REFLEN] ; + char binlog_unsafe_file_name[FN_REFLEN] ; + /* + When do_truncate is true, the truncate position may not be + found in one round when recovered transactions are multi-engine + or just on different engines. + In the single recoverable engine case `truncate_reset_done` and + therefore `truncate_validated` remains `false` when the last + binlog is the binlog-checkpoint one. + The meaning of `truncate_reset_done` is according to the following example: + Let round = 1, Binlog contains the sequence of replication event groups: + [g1, G2, g3] + where `G` (in capital) stands for committed, `g` for prepared. + g1 is first set as truncation candidate, then G2 reset it to indicate + the actual truncation is behind (to the right of) it. + `truncate_validated` is set to true when `binlog_truncate_pos` (as of `g3`) + won't change. + Observe last_gtid_valid is affected, so in the above example `g1` that + was initially ignored for the gtid binlog state now seeing `G2` + would have to be added to it. See gtid_maybe_to_truncate. + */ + bool truncate_validated; // trued when the truncate position settled + bool truncate_reset_done; // trued when the position is to reevaluate + /* Flags the fact of truncate position estimation is done the 1st round */ + bool truncate_set_in_1st; + /* + Monotonically indexes binlog files in the recovery list. + When the list is "likely" singleton the value is UINT_MAX. + Otherwise enumeration starts with zero for the first file, increments + by one for any next file except for the last file in the list, which + is also the initial binlog file for recovery, + that is enumberated with UINT_MAX. + */ + Binlog_file_id id_binlog; + enum_binlog_checksum_alg checksum_alg; + Binlog_offset binlog_truncate_coord, + binlog_truncate_coord_1st_round; // pair is similar to truncate_gtid + Binlog_offset binlog_unsafe_coord; + /* + Populated at decide_or_assess() with gtid-in-doubt whose + binlog offset greater of equal by that of the current gtid truncate + candidate. + Gets empited by reset_truncate_coord into gtid binlog state. + */ + Dynamic_array *gtid_maybe_to_truncate; + Recovery_context(); + ~Recovery_context() { delete gtid_maybe_to_truncate; } + /* + Completes the recovery procedure. + In the normal case prepared xids gets committed when they also found + in binlog, otherwise they are rolled back. + In the semisync slave case the xids that are located in binlog in + a truncated tail get rolled back, otherwise they are committed. + Both decisions are contingent on safety to truncate. + */ + bool complete(MYSQL_BIN_LOG *log, HASH &xids); + /* + decides on commit of xid passed through member argument. + In the semisync slave case it assigns binlog coordinate to + any xid that remains in-doubt. Decision on them will be + done after binlog scan rounds. + */ + bool decide_or_assess(xid_recovery_member *member, int round, + Format_description_log_event *fdle, + LOG_INFO *linfo, my_off_t pos); + + /* + Assigns last_gtid and assesses the maximum (in the binlog offset term) + unsafe gtid (group of events). + */ + void process_gtid(int round, Gtid_log_event *gev, LOG_INFO *linfo); + + /* + Compute next action at the end of processing of the current binlog file. + It may increment the round. + When the round turns in the semisync-slave recovery + binlog_id, truncate_validated, truncate_reset_done + gets reset/set for the next round. + Within the 2nd round id_binlog keeps incrementing. + + Passed arguments: + round the current round that *may* be increment here + last_log_name the recovery starting binlog file + binlog_checkpoint_name + binlog checkpoint file + linfo binlog file list struct for next file + log pointer to mysql_bin_log instance + + Returns: 0 when rounds continue, maybe the current one remains + 1 when all rounds are done + */ + int next_binlog_or_round(int& round, + const char *last_log_name, + const char *binlog_checkpoint_name, + LOG_INFO *linfo, MYSQL_BIN_LOG *log); + /* + Relates to the semisync recovery. + Returns true when truncated tail does not contain non-transactional + group of events. + Otherwise returns false. + */ + bool is_safe_to_truncate() + { + return !do_truncate ? true : + (truncate_gtid.seq_no == 0 || // no truncate + binlog_unsafe_coord < binlog_truncate_coord); // or unsafe is earlier + } + + /* + Relates to the semisync recovery. + Is invoked when a standalone or non-2pc group is detected. + Both are unsafe to truncate in the semisync-slave recovery so + the maximum unsafe coordinate may be updated. + In the non-2pc group case though, *exeptionally*, + the no-engine group is considered safe, to be invalidated + to not contribute to binlog state. + */ + void update_binlog_unsafe_coord_if_needed(LOG_INFO *linfo); + + /* + Relates to the semisync recovery. + Is called when a committed or decided to-commit transaction is detected. + Actions: + truncate_gtid then is set to "nil" as indicated by rpl_gtid::seq_no := 0. + truncate_reset_done takes a note of that fact. + binlog_truncate_coord gets reset to the current gtid offset merely to + "suggest" any potential future truncate gtid must have a greater offset. + gtid_maybe_to_truncate gets emptied into gtid binlog state. + + Returns: + false on success, otherwise + true when OOM at rpl_global_gtid_binlog_state insert + */ + bool reset_truncate_coord(my_off_t pos); + + /* + Sets binlog_truncate_pos to the value of the current transaction's gtid. + In multi-engine case that might be just an assessment to be refined + in the current round and confirmed in a next one. + gtid_maybe_to_truncate receives the current gtid as a new element. + Returns + false on success, otherwise + true when OOM at gtid_maybe_to_truncate append + + */ + bool set_truncate_coord(LOG_INFO *linfo, int round, + enum_binlog_checksum_alg fd_checksum_alg); +}; + +bool Recovery_context::complete(MYSQL_BIN_LOG *log, HASH &xids) +{ + if (!do_truncate || is_safe_to_truncate()) + { + uint count_in_prepare= + ha_recover_complete(&xids, + !do_truncate ? NULL : + (truncate_gtid.seq_no > 0 ? + &binlog_truncate_coord : &last_gtid_coord)); + + if (count_in_prepare > 0 && global_system_variables.log_warnings > 2) + { + sql_print_warning("Could not complete %u number of transactions.", + count_in_prepare); + return false; // there's later dry run ha_recover() to error out + } + } + + /* Truncation is not done when there's no transaction to roll back */ + if (do_truncate && truncate_gtid.seq_no > 0) + { + if (is_safe_to_truncate()) + { + if (log->truncate_and_remove_binlogs(binlog_truncate_file_name, + binlog_truncate_coord.second, + &truncate_gtid)) + { + sql_print_error("Failed to truncate the binary log to " + "file:%s pos:%llu.", binlog_truncate_file_name, + binlog_truncate_coord.second); + return true; + } + } + else + { + sql_print_error("Cannot truncate the binary log to file:%s " + "pos:%llu as unsafe statement " + "is found at file:%s pos:%llu which is " + "beyond the truncation position;" + "all transactions in doubt are left intact. ", + binlog_truncate_file_name, binlog_truncate_coord.second, + binlog_unsafe_file_name, binlog_unsafe_coord.second); + return true; + } + } + + return false; +} + +Recovery_context::Recovery_context() : + prev_event_pos(0), + last_gtid_standalone(false), last_gtid_valid(false), last_gtid_no2pc(false), + last_gtid_engines(0), + do_truncate(rpl_semi_sync_slave_enabled), + truncate_validated(false), truncate_reset_done(false), + truncate_set_in_1st(false), id_binlog(MAX_binlog_id), + checksum_alg(BINLOG_CHECKSUM_ALG_UNDEF), gtid_maybe_to_truncate(NULL) +{ + last_gtid_coord= Binlog_offset(0,0); + binlog_truncate_coord= binlog_truncate_coord_1st_round= Binlog_offset(0,0); + binlog_unsafe_coord= Binlog_offset(0,0); + binlog_truncate_file_name[0]= 0; + binlog_unsafe_file_name [0]= 0; + binlog_unsafe_gtid= truncate_gtid= truncate_gtid_1st_round= rpl_gtid(); + if (do_truncate) + gtid_maybe_to_truncate= new Dynamic_array(16, 16); +} + +bool Recovery_context::reset_truncate_coord(my_off_t pos) +{ + DBUG_ASSERT(binlog_truncate_coord.second == 0 || + last_gtid_coord >= binlog_truncate_coord || + truncate_set_in_1st); + // save as backup to restore at next_binlog_or_round when necessary + if (truncate_set_in_1st && truncate_gtid_1st_round.seq_no == 0) + { + truncate_gtid_1st_round= truncate_gtid; + binlog_truncate_coord_1st_round= binlog_truncate_coord; + } + binlog_truncate_coord= Binlog_offset(id_binlog, pos); + truncate_gtid= rpl_gtid(); + truncate_reset_done= true; + for (uint i= 0; i < gtid_maybe_to_truncate->elements(); i++) + { + rpl_gtid gtid= gtid_maybe_to_truncate->at(i); + if (rpl_global_gtid_binlog_state.update_nolock(>id, false)) + return true; + } + gtid_maybe_to_truncate->clear(); + + return false; +} + +bool Recovery_context::set_truncate_coord(LOG_INFO *linfo, int round, + enum_binlog_checksum_alg fd_checksum) +{ + binlog_truncate_coord= last_gtid_coord; + strmake_buf(binlog_truncate_file_name, linfo->log_file_name); + + truncate_gtid= last_gtid; + checksum_alg= fd_checksum; + truncate_set_in_1st= (round == 1); + + return gtid_maybe_to_truncate->append(last_gtid); +} + +bool Recovery_context::decide_or_assess(xid_recovery_member *member, int round, + Format_description_log_event *fdle, + LOG_INFO *linfo, my_off_t pos) +{ + if (member) + { + /* + xid in doubt are resolved as follows: + in_engine_prepare is compared agaist binlogged info to + yield the commit-or-rollback decision in the normal case. + In the semisync-slave recovery the decision is done later + after the binlog scanning has determined the truncation offset. + */ + if (member->in_engine_prepare > last_gtid_engines) + { + char buf[21]; + longlong10_to_str(last_gtid.seq_no, buf, 10); + sql_print_error("Error to recovery multi-engine transaction: " + "the number of engines prepared %u exceeds the " + "respective number %u in its GTID %u-%u-%s " + "located at file:%s pos:%llu", + member->in_engine_prepare, last_gtid_engines, + last_gtid.domain_id, last_gtid.server_id, buf, + linfo->log_file_name, last_gtid_coord.second); + return true; + } + else if (member->in_engine_prepare < last_gtid_engines) + { + DBUG_ASSERT(member->in_engine_prepare > 0); + /* + This is an "unlikely" branch of two or more engines in transaction + that is partially committed, so to complete. + */ + member->decided_to_commit= true; + if (do_truncate) + { + /* Validated truncate at this point can be only in the 2nd round. */ + DBUG_ASSERT(!truncate_validated || + (round == 2 && truncate_set_in_1st && + last_gtid_coord < binlog_truncate_coord)); + /* + Estimated truncate must not be greater than the current one's + offset, unless the turn of the rounds. + */ + DBUG_ASSERT(truncate_validated || + (last_gtid_coord >= binlog_truncate_coord || + (round == 2 && truncate_set_in_1st))); + + if (!truncate_validated && reset_truncate_coord(pos)) + return true; + } + } + else // member->in_engine_prepare == last_gtid_engines + { + if (!do_truncate) // "normal" recovery + { + member->decided_to_commit= true; + } + else + { + member->binlog_coord= last_gtid_coord; + last_gtid_valid= false; + /* + First time truncate position estimate before its validation. + An estimate may change to involve reset_truncate_coord call. + */ + if (!truncate_validated) + { + if (truncate_gtid.seq_no == 0 /* was reset or never set */ || + (truncate_set_in_1st && round == 2 /* reevaluted at round turn */)) + { + if (set_truncate_coord(linfo, round, fdle->checksum_alg)) + return true; + } + else + { + /* Truncate estimate was done ago, this gtid can't improve it. */ + DBUG_ASSERT(last_gtid_coord >= binlog_truncate_coord); + + gtid_maybe_to_truncate->append(last_gtid); + } + + DBUG_ASSERT(member->decided_to_commit == false); // may redecided + } + else + { + /* + binlog truncate was determined, possibly to none, otherwise + its offset greater than that of the current gtid. + */ + DBUG_ASSERT(truncate_gtid.seq_no == 0 || + last_gtid_coord < binlog_truncate_coord); + member->decided_to_commit= true; + } + } + } + } + else if (do_truncate) // "0" < last_gtid_engines + { + /* + Similar to the partial commit branch above. + */ + DBUG_ASSERT(!truncate_validated || last_gtid_coord < binlog_truncate_coord); + DBUG_ASSERT(truncate_validated || + (last_gtid_coord >= binlog_truncate_coord || + (round == 2 && truncate_set_in_1st))); + + if (!truncate_validated && reset_truncate_coord(pos)) + return true; + } + + return false; +} + +void Recovery_context::update_binlog_unsafe_coord_if_needed(LOG_INFO *linfo) +{ + if (!do_truncate) + return; + + if (truncate_gtid.seq_no > 0 && // g1,U2, *not* G1,U2 + last_gtid_coord > binlog_truncate_coord) + { + DBUG_ASSERT(binlog_truncate_coord.second > 0); + /* + Potentially unsafe when the truncate coordinate is not determined, + just detected as unsafe when behind the latter. + */ + if (last_gtid_engines == 0) + { + last_gtid_valid= false; + } + else + { + binlog_unsafe_gtid= last_gtid; + binlog_unsafe_coord= last_gtid_coord; + strmake_buf(binlog_unsafe_file_name, linfo->log_file_name); + } + } +} + +void Recovery_context::process_gtid(int round, Gtid_log_event *gev, + LOG_INFO *linfo) +{ + last_gtid.domain_id= gev->domain_id; + last_gtid.server_id= gev->server_id; + last_gtid.seq_no= gev->seq_no; + last_gtid_engines= gev->extra_engines != UCHAR_MAX ? + gev->extra_engines + 1 : 0; + last_gtid_coord= Binlog_offset(id_binlog, prev_event_pos); + + DBUG_ASSERT(!last_gtid_valid); + DBUG_ASSERT(!last_gtid.seq_no == 0); + + if (round == 1 || (do_truncate && !truncate_validated)) + { + DBUG_ASSERT(!last_gtid_valid); + + last_gtid_no2pc= false; + last_gtid_standalone= + (gev->flags2 & Gtid_log_event::FL_STANDALONE) ? true : false; + if (do_truncate && last_gtid_standalone) + update_binlog_unsafe_coord_if_needed(linfo); + /* Update the binlog state with any 'valid' GTID logged after Gtid_list. */ + last_gtid_valid= true; // may flip at Xid when falls to truncate + } +} + +int Recovery_context::next_binlog_or_round(int& round, + const char *last_log_name, + const char *binlog_checkpoint_name, + LOG_INFO *linfo, + MYSQL_BIN_LOG *log) +{ + if (!strcmp(linfo->log_file_name, last_log_name)) + { + /* Exit the loop now at the end of the current round. */ + DBUG_ASSERT(round <= 2); + + if (do_truncate) + { + truncate_validated= truncate_reset_done; + truncate_reset_done= false; + /* + Restore the 1st round saved estimate if it was not refined in the 2nd. + That can only occur in multiple log files context when the inital file + has a truncation candidate (a `g`) and does not have any commited `G`, + *and* other files (binlog-checkpoint one and so on) do not have any + transaction-in-doubt. + */ + if (truncate_gtid.seq_no == 0 && truncate_set_in_1st) + { + DBUG_ASSERT(truncate_gtid_1st_round.seq_no > 0); + + truncate_gtid= truncate_gtid_1st_round; + binlog_truncate_coord= binlog_truncate_coord_1st_round; + } + } + return 1; + } + else if (round == 1) + { + if (do_truncate) + { + truncate_validated= truncate_reset_done; + if (!truncate_validated) + { + rpl_global_gtid_binlog_state.reset_nolock(); + gtid_maybe_to_truncate->clear(); + } + truncate_reset_done= false; + id_binlog= 0; + } + round++; + } + else if (do_truncate) // binlog looping within round 2 + { + id_binlog++; + + DBUG_ASSERT(id_binlog <= MAX_binlog_id); // the assert is "practical" + } + + DBUG_ASSERT(!do_truncate || id_binlog != MAX_binlog_id || + !strcmp(linfo->log_file_name, binlog_checkpoint_name)); + + return 0; +} +#endif /* Execute recovery of the binary log @@ -10476,16 +11137,25 @@ int TC_LOG_BINLOG::recover(LOG_INFO *linfo, const char *last_log_name, MEM_ROOT mem_root; char binlog_checkpoint_name[FN_REFLEN]; bool binlog_checkpoint_found; - bool first_round; IO_CACHE log; File file= -1; const char *errmsg; #ifdef HAVE_REPLICATION - rpl_gtid last_gtid; - bool last_gtid_standalone= false; - bool last_gtid_valid= false; + Recovery_context ctx; #endif DBUG_ENTER("TC_LOG_BINLOG::recover"); + /* + The for-loop variable is updated by the following rule set: + Initially set to 1. + After the initial binlog file is processed to identify + the Binlog-checkpoint file it is incremented when the latter file + is different from the initial one. Otherwise the only log has been + fully parsed so the for loop exits. + The 2nd round parses all earlier in binlog index order files + starting from the Binlog-checkpoint file. It ends when the initial + binlog file is reached. + */ + int round; if (! fdle->is_valid() || (my_hash_init(key_memory_binlog_recover_exec, &xids, @@ -10501,6 +11171,10 @@ int TC_LOG_BINLOG::recover(LOG_INFO *linfo, const char *last_log_name, fdle->flags&= ~LOG_EVENT_BINLOG_IN_USE_F; // abort on the first error + /* finds xids when root is not NULL */ + if (do_xa && ha_recover(&xids, &mem_root)) + goto err1; + /* Scan the binlog for XIDs that need to be committed if still in the prepared stage. @@ -10510,10 +11184,9 @@ int TC_LOG_BINLOG::recover(LOG_INFO *linfo, const char *last_log_name, */ binlog_checkpoint_found= false; - first_round= true; - for (;;) + for (round= 1;;) { - while ((ev= Log_event::read_log_event(first_round ? first_log : &log, + while ((ev= Log_event::read_log_event(round == 1 ? first_log : &log, fdle, opt_master_verify_checksum)) && ev->is_valid()) { @@ -10521,17 +11194,23 @@ int TC_LOG_BINLOG::recover(LOG_INFO *linfo, const char *last_log_name, switch (typ) { case XID_EVENT: + if (do_xa) { - if (do_xa) + xid_recovery_member *member= + (xid_recovery_member*) + my_hash_search(&xids, (uchar*) &static_cast(ev)->xid, + sizeof(my_xid)); +#ifndef HAVE_REPLICATION { - Xid_log_event *xev=(Xid_log_event *)ev; - uchar *x= (uchar *) memdup_root(&mem_root, (uchar*) &xev->xid, - sizeof(xev->xid)); - if (!x || my_hash_insert(&xids, x)) - goto err2; + if (member) + member->decided_to_commit= true; } - break; +#else + if (ctx.decide_or_assess(member, round, fdle, linfo, ev->log_pos)) + goto err2; +#endif } + break; case QUERY_EVENT: { Query_log_event *query_ev= (Query_log_event*) ev; @@ -10545,10 +11224,18 @@ int TC_LOG_BINLOG::recover(LOG_INFO *linfo, const char *last_log_name, if (!x || my_hash_insert(&ddl_log_ids, x)) goto err2; } +#ifdef HAVE_REPLICATION + if (((Query_log_event *)ev)->is_commit() || + ((Query_log_event *)ev)->is_rollback()) + { + ctx.last_gtid_no2pc= true; + ctx.update_binlog_unsafe_coord_if_needed(linfo); + } +#endif break; } case BINLOG_CHECKPOINT_EVENT: - if (first_round && do_xa) + if (round == 1 && do_xa) { size_t dir_len; Binlog_checkpoint_log_event *cev= (Binlog_checkpoint_log_event *)ev; @@ -10568,8 +11255,9 @@ int TC_LOG_BINLOG::recover(LOG_INFO *linfo, const char *last_log_name, } } break; +#ifdef HAVE_REPLICATION case GTID_LIST_EVENT: - if (first_round) + if (round == 1 || (ctx.do_truncate && ctx.id_binlog == 0)) { Gtid_list_log_event *glev= (Gtid_list_log_event *)ev; @@ -10579,20 +11267,13 @@ int TC_LOG_BINLOG::recover(LOG_INFO *linfo, const char *last_log_name, } break; -#ifdef HAVE_REPLICATION case GTID_EVENT: - if (first_round) - { - Gtid_log_event *gev= (Gtid_log_event *)ev; + ctx.process_gtid(round, (Gtid_log_event *)ev, linfo); + break; - /* Update the binlog state with any GTID logged after Gtid_list. */ - last_gtid.domain_id= gev->domain_id; - last_gtid.server_id= gev->server_id; - last_gtid.seq_no= gev->seq_no; - last_gtid_standalone= - ((gev->flags2 & Gtid_log_event::FL_STANDALONE) ? true : false); - last_gtid_valid= true; - } + case XA_PREPARE_LOG_EVENT: + ctx.last_gtid_no2pc= true; // TODO: complete MDEV-21469 that removes this block + ctx.update_binlog_unsafe_coord_if_needed(linfo); break; #endif @@ -10606,27 +11287,31 @@ int TC_LOG_BINLOG::recover(LOG_INFO *linfo, const char *last_log_name, default: /* Nothing. */ break; - } + } // end of switch #ifdef HAVE_REPLICATION - if (last_gtid_valid && - ((last_gtid_standalone && !ev->is_part_of_group(typ)) || - (!last_gtid_standalone && - (typ == XID_EVENT || - typ == XA_PREPARE_LOG_EVENT || - (LOG_EVENT_IS_QUERY(typ) && - (((Query_log_event *)ev)->is_commit() || - ((Query_log_event *)ev)->is_rollback())))))) + if (ctx.last_gtid_valid && + ((ctx.last_gtid_standalone && !ev->is_part_of_group(typ)) || + (!ctx.last_gtid_standalone && + (typ == XID_EVENT || ctx.last_gtid_no2pc)))) { - if (rpl_global_gtid_binlog_state.update_nolock(&last_gtid, false)) - goto err2; - last_gtid_valid= false; - } -#endif + DBUG_ASSERT(round == 1 || (ctx.do_truncate && !ctx.truncate_validated)); + DBUG_ASSERT(!ctx.last_gtid_no2pc || + (ctx.last_gtid_standalone || + typ == XA_PREPARE_LOG_EVENT || + (LOG_EVENT_IS_QUERY(typ) && + (((Query_log_event *)ev)->is_commit() || + ((Query_log_event *)ev)->is_rollback())))); + if (rpl_global_gtid_binlog_state.update_nolock(&ctx.last_gtid, false)) + goto err2; + ctx.last_gtid_valid= false; + } + ctx.prev_event_pos= ev->log_pos; +#endif delete ev; ev= NULL; - } + } // end of while /* If the last binlog checkpoint event points to an older log, we have to @@ -10636,11 +11321,10 @@ int TC_LOG_BINLOG::recover(LOG_INFO *linfo, const char *last_log_name, written by an older version of MariaDB (or MySQL) - these always have an (implicit) binlog checkpoint event at the start of the last binlog file. */ - if (first_round) + if (round == 1) { if (!binlog_checkpoint_found) break; - first_round= false; DBUG_EXECUTE_IF("xa_recover_expect_master_bin_000004", if (0 != strcmp("./master-bin.000004", binlog_checkpoint_name) && 0 != strcmp(".\\master-bin.000004", binlog_checkpoint_name)) @@ -10658,33 +11342,50 @@ int TC_LOG_BINLOG::recover(LOG_INFO *linfo, const char *last_log_name, end_io_cache(&log); mysql_file_close(file, MYF(MY_WME)); file= -1; + /* + NOTE: reading other binlog's FD is necessary for finding out + the checksum status of the respective binlog file. + */ + if (find_next_log(linfo, 1)) + { + sql_print_error("Error reading binlog files during recovery. " + "Aborting."); + goto err2; + } } +#ifdef HAVE_REPLICATION + int rc= ctx.next_binlog_or_round(round, last_log_name, + binlog_checkpoint_name, linfo, this); + if (rc == -1) + goto err2; + else if (rc == 1) + break; // all rounds done +#else if (!strcmp(linfo->log_file_name, last_log_name)) break; // No more files to do + round++; +#endif + if ((file= open_binlog(&log, linfo->log_file_name, &errmsg)) < 0) { sql_print_error("%s", errmsg); goto err2; } - /* - We do not need to read the Format_description_log_event of other binlog - files. It is not possible for a binlog checkpoint to span multiple - binlog files written by different versions of the server. So we can use - the first one read for reading from all binlog files. - */ - if (find_next_log(linfo, 1)) - { - sql_print_error("Error reading binlog files during recovery. Aborting."); - goto err2; - } fdle->reset_crypto(); - } + } // end of for if (do_xa) { - if (ha_recover(&xids)) - goto err2; + if (binlog_checkpoint_found) + { +#ifndef HAVE_REPLICATION + if (ha_recover_complete(&xids)) +#else + if (ctx.complete(this, xids)) +#endif + goto err2; + } } if (ddl_log_close_binlogged_events(&ddl_log_ids)) goto err2; @@ -10713,6 +11414,7 @@ err1: } + int MYSQL_BIN_LOG::do_binlog_recovery(const char *opt_name, bool do_xa_recovery) { diff --git a/sql/log.h b/sql/log.h index eaf7cde1c07..d61e4660330 100644 --- a/sql/log.h +++ b/sql/log.h @@ -477,6 +477,7 @@ class MYSQL_BIN_LOG: public TC_LOG, private MYSQL_LOG /* Flag used to optimise around wait_for_prior_commit. */ bool queued_by_other; ulong binlog_id; + bool ro_1pc; // passes the binlog_cache_mngr::ro_1pc value to Gtid ctor }; /* @@ -810,7 +811,8 @@ public: my_bool *with_annotate= 0); // binary log write bool write_transaction_to_binlog(THD *thd, binlog_cache_mngr *cache_mngr, Log_event *end_ev, bool all, - bool using_stmt_cache, bool using_trx_cache); + bool using_stmt_cache, bool using_trx_cache, + bool is_ro_1pc); bool write_incident_already_locked(THD *thd); bool write_incident(THD *thd); @@ -860,6 +862,9 @@ public: int purge_first_log(Relay_log_info* rli, bool included); int set_purge_index_file_name(const char *base_file_name); int open_purge_index_file(bool destroy); + bool truncate_and_remove_binlogs(const char *truncate_file, + my_off_t truncate_pos, + rpl_gtid *gtid); bool is_inited_purge_index_file(); int close_purge_index_file(); int clean_purge_index_file(); @@ -896,7 +901,8 @@ public: void set_status_variables(THD *thd); bool is_xidlist_idle(); bool write_gtid_event(THD *thd, bool standalone, bool is_transactional, - uint64 commit_id); + uint64 commit_id, + bool has_xid= false, bool ro_1pc= false); int read_state_from_file(); int write_state_to_file(); int get_most_recent_gtid_list(rpl_gtid **list, uint32 *size); @@ -1237,4 +1243,8 @@ class Gtid_list_log_event; const char * get_gtid_list_event(IO_CACHE *cache, Gtid_list_log_event **out_gtid_list); +int binlog_commit(THD *thd, bool all, bool is_ro_1pc); +int binlog_commit_by_xid(handlerton *hton, XID *xid); +int binlog_rollback_by_xid(handlerton *hton, XID *xid); + #endif /* LOG_H */ diff --git a/sql/log_event.cc b/sql/log_event.cc index 9c7c56b1c34..c77059ee8f5 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -53,6 +53,7 @@ #include "sql_digest.h" #include "zlib.h" #include "myisampack.h" +#include #define my_b_write_string(A, B) my_b_write((A), (uchar*)(B), (uint) (sizeof(B) - 1)) @@ -2560,10 +2561,12 @@ Binlog_checkpoint_log_event::Binlog_checkpoint_log_event( Gtid_log_event::Gtid_log_event(const uchar *buf, uint event_len, const Format_description_log_event *description_event) - : Log_event(buf, description_event), seq_no(0), commit_id(0) + : Log_event(buf, description_event), seq_no(0), commit_id(0), + flags_extra(0), extra_engines(0) { uint8 header_size= description_event->common_header_len; uint8 post_header_len= description_event->post_header_len[GTID_EVENT-1]; + const uchar *buf_0= buf; if (event_len < (uint) header_size + (uint) post_header_len || post_header_len < GTID_HEADER_LEN) return; @@ -2597,6 +2600,32 @@ Gtid_log_event::Gtid_log_event(const uchar *buf, uint event_len, memcpy(xid.data, buf, data_length); buf+= data_length; } + + /* the extra flags check and actions */ + if (static_cast(buf - buf_0) < event_len) + { + flags_extra= *buf++; + /* + extra engines flags presence is identifed by non-zero byte value + at this point + */ + if (flags_extra & FL_EXTRA_MULTI_ENGINE) + { + DBUG_ASSERT(static_cast(buf - buf_0) < event_len); + + extra_engines= *buf++; + + DBUG_ASSERT(extra_engines > 0); + } + } + /* + the strict '<' part of the assert corresponds to extra zero-padded + trailing bytes, + */ + DBUG_ASSERT(static_cast(buf - buf_0) <= event_len); + /* and the last of them is tested. */ + DBUG_ASSERT(static_cast(buf - buf_0) == event_len || + buf_0[event_len - 1] == 0); } diff --git a/sql/log_event.h b/sql/log_event.h index 990d95e1dc0..3adc7a26d93 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -489,6 +489,16 @@ class String; */ #define LOG_EVENT_IGNORABLE_F 0x80 +/** + @def LOG_EVENT_ACCEPT_OWN_F + + Flag sets by the semisync slave for accepting + the same server_id ("own") events which the slave must not have + in its state. Typically such events were never committed by + their originator (this server) and discared at its semisync-slave recovery. +*/ +#define LOG_EVENT_ACCEPT_OWN_F 0x4000 + /** @def LOG_EVENT_SKIP_REPLICATION_F @@ -3602,6 +3612,13 @@ public: event_mysql_xid_t xid; #endif uchar flags2; + uint flags_extra; // more flags area placed after the regular flags2's one + /* + Number of engine participants in transaction minus 1. + When zero the event does not contain that information. + */ + uint8 extra_engines; + /* Flags2. */ /* FL_STANDALONE is set when there is no terminating COMMIT event. */ @@ -3633,9 +3650,19 @@ public: /* FL_"COMMITTED or ROLLED-BACK"_XA is set for XA transaction. */ static const uchar FL_COMPLETED_XA= 128; + /* Flags_extra. */ + + /* + FL_EXTRA_MULTI_ENGINE is set for event group comprising a transaction + involving multiple storage engines. No flag and extra data are added + to the event when the transaction involves only one engine. + */ + static const uchar FL_EXTRA_MULTI_ENGINE= 1; + #ifdef MYSQL_SERVER Gtid_log_event(THD *thd_arg, uint64 seq_no, uint32 domain_id, bool standalone, - uint16 flags, bool is_transactional, uint64 commit_id); + uint16 flags, bool is_transactional, uint64 commit_id, + bool has_xid= false, bool is_ro_1pc= false); #ifdef HAVE_REPLICATION void pack_info(Protocol *protocol); virtual int do_apply_event(rpl_group_info *rgi); diff --git a/sql/log_event_server.cc b/sql/log_event_server.cc index e216724ca7a..d97e87fc4e9 100644 --- a/sql/log_event_server.cc +++ b/sql/log_event_server.cc @@ -644,7 +644,7 @@ Log_event::do_shall_skip(rpl_group_info *rgi) rli->replicate_same_server_id, rli->slave_skip_counter)); if ((server_id == global_system_variables.server_id && - !rli->replicate_same_server_id) || + !(rli->replicate_same_server_id || (flags & LOG_EVENT_ACCEPT_OWN_F))) || (rli->slave_skip_counter == 1 && rli->is_in_group()) || (flags & LOG_EVENT_SKIP_REPLICATION_F && opt_replicate_events_marked_for_skip != RPL_SKIP_REPLICATE)) @@ -3261,10 +3261,13 @@ bool Binlog_checkpoint_log_event::write() Gtid_log_event::Gtid_log_event(THD *thd_arg, uint64 seq_no_arg, uint32 domain_id_arg, bool standalone, uint16 flags_arg, bool is_transactional, - uint64 commit_id_arg) + uint64 commit_id_arg, bool has_xid, + bool ro_1pc) : Log_event(thd_arg, flags_arg, is_transactional), seq_no(seq_no_arg), commit_id(commit_id_arg), domain_id(domain_id_arg), - flags2((standalone ? FL_STANDALONE : 0) | (commit_id_arg ? FL_GROUP_COMMIT_ID : 0)) + flags2((standalone ? FL_STANDALONE : 0) | + (commit_id_arg ? FL_GROUP_COMMIT_ID : 0)), + flags_extra(0), extra_engines(0) { cache_type= Log_event::EVENT_NO_CACHE; bool is_tmp_table= thd_arg->lex->stmt_accessed_temp_table(); @@ -3287,15 +3290,40 @@ Gtid_log_event::Gtid_log_event(THD *thd_arg, uint64 seq_no_arg, flags2|= (thd_arg->rgi_slave->gtid_ev_flags2 & (FL_DDL|FL_WAITED)); XID_STATE &xid_state= thd->transaction->xid_state; - if (is_transactional && xid_state.is_explicit_XA() && - (thd->lex->sql_command == SQLCOM_XA_PREPARE || - xid_state.get_state_code() == XA_PREPARED)) + if (is_transactional) { - DBUG_ASSERT(thd->lex->xa_opt != XA_ONE_PHASE); + if (xid_state.is_explicit_XA() && + (thd->lex->sql_command == SQLCOM_XA_PREPARE || + xid_state.get_state_code() == XA_PREPARED)) + { + DBUG_ASSERT(thd->lex->xa_opt != XA_ONE_PHASE); - flags2|= thd->lex->sql_command == SQLCOM_XA_PREPARE ? - FL_PREPARED_XA : FL_COMPLETED_XA; - xid.set(xid_state.get_xid()); + flags2|= thd->lex->sql_command == SQLCOM_XA_PREPARE ? + FL_PREPARED_XA : FL_COMPLETED_XA; + xid.set(xid_state.get_xid()); + } + /* count non-zero extra recoverable engines; total = extra + 1 */ + if (has_xid) + { + DBUG_ASSERT(ha_count_rw_2pc(thd_arg, + thd_arg->in_multi_stmt_transaction_mode())); + + extra_engines= + ha_count_rw_2pc(thd_arg, thd_arg->in_multi_stmt_transaction_mode()) - 1; + } + else if (ro_1pc) + { + extra_engines= UCHAR_MAX; + } + else if (thd->lex->sql_command == SQLCOM_XA_PREPARE) + { + DBUG_ASSERT(thd_arg->in_multi_stmt_transaction_mode()); + + uint8 count= ha_count_rw_2pc(thd_arg, true); + extra_engines= count > 1 ? 0 : UCHAR_MAX; + } + if (extra_engines > 0) + flags_extra|= FL_EXTRA_MULTI_ENGINE; } } @@ -3339,19 +3367,19 @@ Gtid_log_event::peek(const uchar *event_start, size_t event_len, bool Gtid_log_event::write() { - uchar buf[GTID_HEADER_LEN+2+sizeof(XID)]; - size_t write_len; + uchar buf[GTID_HEADER_LEN+2+sizeof(XID) + /* flags_extra: */ 1+4]; + size_t write_len= 13; int8store(buf, seq_no); int4store(buf+8, domain_id); buf[12]= flags2; if (flags2 & FL_GROUP_COMMIT_ID) { - int8store(buf+13, commit_id); + DBUG_ASSERT(write_len + 8 == GTID_HEADER_LEN + 2); + + int8store(buf+write_len, commit_id); write_len= GTID_HEADER_LEN + 2; } - else - write_len= 13; if (flags2 & (FL_PREPARED_XA | FL_COMPLETED_XA)) { @@ -3363,6 +3391,16 @@ Gtid_log_event::write() memcpy(buf+write_len, xid.data, data_length); write_len+= data_length; } + if (flags_extra > 0) + { + buf[write_len]= flags_extra; + write_len++; + } + if (flags_extra & FL_EXTRA_MULTI_ENGINE) + { + buf[write_len]= extra_engines; + write_len++; + } if (write_len < GTID_HEADER_LEN) { diff --git a/sql/slave.cc b/sql/slave.cc index 17c2d59c9d7..e7aa0d4a510 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -6173,6 +6173,15 @@ static int queue_event(Master_info* mi, const uchar *buf, ulong event_len) uchar new_buf_arr[4096]; bool is_malloc = false; bool is_rows_event= false; + /* + The flag has replicate_same_server_id semantics and is raised to accept + a same-server-id event on the semisync slave, for both the gtid and legacy + connection modes. + Such events can appear as result of this server recovery so the event + was created there and replicated elsewhere right before the crash. At recovery + it could be evicted from the server's binlog. + */ + bool do_accept_own_server_id= false; /* FD_q must have been prepared for the first R_a event inside get_master_version_and_clock() @@ -6234,6 +6243,7 @@ static int queue_event(Master_info* mi, const uchar *buf, ulong event_len) unlock_data_lock= FALSE; goto err; } + DBUG_ASSERT(((uchar) buf[FLAGS_OFFSET] & LOG_EVENT_ACCEPT_OWN_F) == 0); if (mi->rli.relay_log.description_event_for_queue->binlog_version<4 && buf[EVENT_TYPE_OFFSET] != FORMAT_DESCRIPTION_EVENT /* a way to escape */) @@ -6933,7 +6943,8 @@ static int queue_event(Master_info* mi, const uchar *buf, ulong event_len) } else if ((s_id == global_system_variables.server_id && - !mi->rli.replicate_same_server_id) || + !(mi->rli.replicate_same_server_id || + (do_accept_own_server_id= rpl_semi_sync_slave_enabled))) || event_that_should_be_ignored(buf) || /* the following conjunction deals with IGNORE_SERVER_IDS, if set @@ -6993,6 +7004,19 @@ static int queue_event(Master_info* mi, const uchar *buf, ulong event_len) } else { + if (do_accept_own_server_id) + { + int2store(const_cast(buf + FLAGS_OFFSET), + uint2korr(buf + FLAGS_OFFSET) | LOG_EVENT_ACCEPT_OWN_F); + if (checksum_alg != BINLOG_CHECKSUM_ALG_OFF) + { + ha_checksum crc= 0; + + crc= my_checksum(crc, (const uchar *) buf, + event_len - BINLOG_CHECKSUM_LEN); + int4store(&buf[event_len - BINLOG_CHECKSUM_LEN], crc); + } + } if (likely(!rli->relay_log.write_event_buffer((uchar*)buf, event_len))) { mi->master_log_pos+= inc_pos; diff --git a/storage/innobase/log/log0log.cc b/storage/innobase/log/log0log.cc index 125abe334fc..5e64007ef84 100644 --- a/storage/innobase/log/log0log.cc +++ b/storage/innobase/log/log0log.cc @@ -831,6 +831,7 @@ void log_write_up_to(lsn_t lsn, bool flush_to_disk, bool rotate_key, flush_lock.release(flush_lsn); log_flush_notify(flush_lsn); + DBUG_EXECUTE_IF("crash_after_log_write_upto", DBUG_SUICIDE();); } /** write to the log file up to the last log entry. From 887f46a618ac2351dbf9f391f13aca9ba6fa9c54 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sat, 12 Jun 2021 12:23:07 +0200 Subject: [PATCH 061/251] fix mysqltest crash report output * read_command_buf is a pointer now, sizeof() no longer reflects its length, read_command_buflen is. * my_safe_print_str() prints multiple screens of '\0' bytes after the query end and up to read_command_buflen. Use fprintf() instead. * when setting connection->name to "-closed_connection-" update connection->name_len to match. --- client/mysqltest.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 2a9560e8903..1587d7513b3 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -90,6 +90,8 @@ static my_bool non_blocking_api_enabled= 0; #define QUERY_PRINT_ORIGINAL_FLAG 4 +#define CLOSED_CONNECTION "-closed_connection-" + #ifndef HAVE_SETENV static int setenv(const char *name, const char *value, int overwrite); #endif @@ -5569,11 +5571,12 @@ void do_close_connection(struct st_command *command) my_free(con->name); /* - When the connection is closed set name to "-closed_connection-" + When the connection is closed set name to CLOSED_CONNECTION to make it possible to reuse the connection name. */ - if (!(con->name = my_strdup("-closed_connection-", MYF(MY_WME)))) + if (!(con->name = my_strdup(CLOSED_CONNECTION, MYF(MY_WME)))) die("Out of memory"); + con->name_len= sizeof(CLOSED_CONNECTION)-1; if (con == cur_con) { @@ -5957,7 +5960,7 @@ void do_connect(struct st_command *command) con_slot= next_con; else { - if (!(con_slot= find_connection_by_name("-closed_connection-"))) + if (!(con_slot= find_connection_by_name(CLOSED_CONNECTION))) die("Connection limit exhausted, you can have max %d connections", opt_max_connections); my_free(con_slot->name); @@ -8980,7 +8983,7 @@ static void dump_backtrace(void) struct st_connection *conn= cur_con; fprintf(stderr, "read_command_buf (%p): ", read_command_buf); - my_safe_print_str(read_command_buf, sizeof(read_command_buf)); + fprintf(stderr, "%.*s\n", (int)read_command_buflen, read_command_buf); fputc('\n', stderr); if (conn) From c9f9e38bb52cea32ffef7585dfa089a407908a30 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sat, 12 Jun 2021 12:38:45 +0200 Subject: [PATCH 062/251] fix mysqlest crash on ./mtr --sp innodb_fts.innodb-fts-stopword --- client/mysqltest.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 1587d7513b3..6d5b6ff31b6 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -8574,7 +8574,7 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags) log_file.flush(); dynstr_set(&ds_res, 0); - if (view_protocol_enabled && + if (view_protocol_enabled && mysql && complete_query && match_re(&view_re, query)) { @@ -8620,7 +8620,7 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags) dynstr_free(&query_str); } - if (sp_protocol_enabled && + if (sp_protocol_enabled && mysql && complete_query && match_re(&sp_re, query)) { From 4a184f52b09ed469b19aaa697d5c491169398186 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 14 Jun 2021 12:33:23 +0300 Subject: [PATCH 063/251] MDEV-21117 fixup: Fix the test parts.backup_log_rocksdb --- mysql-test/suite/parts/t/backup_log_rocksdb.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/suite/parts/t/backup_log_rocksdb.test b/mysql-test/suite/parts/t/backup_log_rocksdb.test index c260d26acc1..c5acfa76b11 100644 --- a/mysql-test/suite/parts/t/backup_log_rocksdb.test +++ b/mysql-test/suite/parts/t/backup_log_rocksdb.test @@ -1,5 +1,5 @@ --source include/have_partition.inc ---source suite/mariabackup/include/have_rocksdb.inc +--source include/have_rocksdb.inc --source include/not_embedded.inc # From 74a0a9877bd936d60f24810e34773d742caab0bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 14 Jun 2021 12:09:12 +0300 Subject: [PATCH 064/251] MDEV-24731 fixup: Another bogus assertion In commit de407e7cb4d12574806bf4f7830e73908d5ca9e2 a debug assertion was added that would not always hold: We could have TRX_STATE_PREPARED here. But, in that case, the transaction should not have been chosen as a deadlock victim. --- storage/innobase/lock/lock0lock.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc index 95cb27aba10..5c5d43f7c76 100644 --- a/storage/innobase/lock/lock0lock.cc +++ b/storage/innobase/lock/lock0lock.cc @@ -1850,11 +1850,15 @@ static void lock_wait_end(trx_t *trx) { mysql_mutex_assert_owner(&lock_sys.wait_mutex); ut_ad(trx->mutex_is_owner()); - ut_ad(trx->state == TRX_STATE_ACTIVE); + ut_d(const auto state= trx->state); + ut_ad(state == TRX_STATE_ACTIVE || state == TRX_STATE_PREPARED); ut_ad(trx->lock.wait_thr); if (trx->lock.was_chosen_as_deadlock_victim.fetch_and(byte(~1))) + { + ut_ad(state == TRX_STATE_ACTIVE); trx->error_state= DB_DEADLOCK; + } trx->lock.wait_thr= nullptr; pthread_cond_signal(&trx->lock.cond); From 28e362eaca169ad49a2212a1ba6d5eca263e42c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 14 Jun 2021 08:57:04 +0300 Subject: [PATCH 065/251] MDEV-25760: Resubmit IO job on -EAGAIN from io_uring The server still may abort if there is no enough free space in the ring buffer to resubmit the IO job, but the behavior is equal to the failure of os_aio() -> submit_io(). --- tpool/aio_liburing.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tpool/aio_liburing.cc b/tpool/aio_liburing.cc index bdc3601ae35..430c01c91a0 100644 --- a/tpool/aio_liburing.cc +++ b/tpool/aio_liburing.cc @@ -162,6 +162,13 @@ private: io_uring_cqe_seen(&aio->uring_, cqe); + if (res == -EAGAIN) { + // If we need to resubmit the IO operation, but the ring is full, + // then just go the same path as for any other error codes. + if (!aio->submit_io(iocb)) + continue; + } + iocb->m_internal_task.m_func= iocb->m_callback; iocb->m_internal_task.m_arg= iocb; iocb->m_internal_task.m_group= iocb->m_group; From 6ba938af6219db3489aca7c8daa80a30009716bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 14 Jun 2021 09:15:20 +0300 Subject: [PATCH 066/251] MDEV-25905: Assertion table2==NULL in dict_sys_t::add() In commit 49e2c8f0a6fefdeac50925f758090d6bd099768d (MDEV-25743) we made dict_sys_t::find() incompatible with the rest of the table name hash table operations in case the table name contains non-ASCII octets (using a compatibility mode that facilitates the upgrade into the MySQL 5.0 filename-safe encoding) and the target platform implements signed char. ut_fold_string(): Remove; replace with my_crc32c(). This also makes table name hash value calculations independent on whether char is unsigned or signed. --- extra/mariabackup/xtrabackup.cc | 41 +++++++++++++------------ mysql-test/suite/innodb/r/dropdb.result | 3 ++ mysql-test/suite/innodb/t/dropdb.test | 4 +++ storage/innobase/dict/dict0dict.cc | 20 +++++++----- storage/innobase/include/dict0dict.h | 6 ++-- storage/innobase/include/ut0rnd.h | 11 +------ storage/innobase/include/ut0rnd.ic | 24 +-------------- tpool/aio_liburing.cc | 10 +++--- 8 files changed, 50 insertions(+), 69 deletions(-) diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index 04ca6fa11d6..37337e8d990 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -2414,7 +2414,8 @@ find_filter_in_hashtable( ) { xb_filter_entry_t* found = NULL; - HASH_SEARCH(name_hash, table, ut_fold_string(name), + const ulint fold = my_crc32c(0, name, strlen(name)); + HASH_SEARCH(name_hash, table, fold, xb_filter_entry_t*, found, (void) 0, !strcmp(found->name, name)); @@ -3874,22 +3875,16 @@ new hash table */ static xb_filter_entry_t* xb_add_filter( -/*========================*/ const char* name, /*!< in: name of table/database */ hash_table_t* hash) /*!< in/out: hash to insert into */ { - xb_filter_entry_t* entry; - - entry = xb_new_filter_entry(name); + xb_filter_entry_t* entry = xb_new_filter_entry(name); if (UNIV_UNLIKELY(!hash->array)) { hash->create(1000); } - HASH_INSERT(xb_filter_entry_t, - name_hash, hash, - ut_fold_string(entry->name), - entry); - + const ulint fold = my_crc32c(0, entry->name, strlen(entry->name)); + HASH_INSERT(xb_filter_entry_t, name_hash, hash, fold, entry); return entry; } @@ -3943,8 +3938,9 @@ xb_register_filter_entry( dbname[p - name] = 0; if (databases_hash && databases_hash->array) { + const ulint fold = my_crc32c(0, dbname, p - name); HASH_SEARCH(name_hash, databases_hash, - ut_fold_string(dbname), + fold, xb_filter_entry_t*, db_entry, (void) 0, !strcmp(db_entry->name, dbname)); @@ -4153,9 +4149,10 @@ xb_filter_hash_free(hash_table_t* hash) table = static_cast (HASH_GET_NEXT(name_hash, prev_table)); - + const ulint fold = my_crc32c(0, prev_table->name, + strlen(prev_table->name)); HASH_DELETE(xb_filter_entry_t, name_hash, hash, - ut_fold_string(prev_table->name), prev_table); + fold, prev_table); free(prev_table); } } @@ -5049,15 +5046,17 @@ exit: return file; } + const size_t len = strlen(dest_space_name); /* remember space name for further reference */ table = static_cast (malloc(sizeof(xb_filter_entry_t) + - strlen(dest_space_name) + 1)); + len + 1)); table->name = ((char*)table) + sizeof(xb_filter_entry_t); - strcpy(table->name, dest_space_name); + memcpy(table->name, dest_space_name, len + 1); + const ulint fold = my_crc32c(0, dest_space_name, len); HASH_INSERT(xb_filter_entry_t, name_hash, &inc_dir_tables_hash, - ut_fold_string(table->name), table); + fold, table); mysql_mutex_lock(&fil_system.mutex); fil_space = fil_space_get_by_name(dest_space_name); @@ -5458,8 +5457,10 @@ static ibool prepare_handle_new_files(const char *data_home_dir, (malloc(sizeof(xb_filter_entry_t) + table_name.size() + 1)); table->name = ((char*)table) + sizeof(xb_filter_entry_t); strcpy(table->name, table_name.c_str()); + const ulint fold = my_crc32c(0, table->name, + table_name.size()); HASH_INSERT(xb_filter_entry_t, name_hash, &inc_dir_tables_hash, - ut_fold_string(table->name), table); + fold, table); } return TRUE; @@ -5482,9 +5483,11 @@ rm_if_not_found( snprintf(name, FN_REFLEN, "%s/%s", db_name, file_name); /* Truncate ".ibd" */ - name[strlen(name) - 4] = '\0'; + const size_t len = strlen(name) - 4; + name[len] = '\0'; + const ulint fold = my_crc32c(0, name, len); - HASH_SEARCH(name_hash, &inc_dir_tables_hash, ut_fold_string(name), + HASH_SEARCH(name_hash, &inc_dir_tables_hash, fold, xb_filter_entry_t*, table, (void) 0, !strcmp(table->name, name)); diff --git a/mysql-test/suite/innodb/r/dropdb.result b/mysql-test/suite/innodb/r/dropdb.result index 6b11b5e5205..e612b02b4c8 100644 --- a/mysql-test/suite/innodb/r/dropdb.result +++ b/mysql-test/suite/innodb/r/dropdb.result @@ -1,3 +1,5 @@ +SET NAMES utf8; +call mtr.add_suppression("Invalid .old.. table or database name"); # # Bug #19929435 DROP DATABASE HANGS WITH MALFORMED TABLE # @@ -6,4 +8,5 @@ create database `b`; use `b`; create table `#mysql50#q.q` select 1; ERROR 42000: Incorrect table name '#mysql50#q.q' +create table `#mysql50#q·q` select 1; drop database `b`; diff --git a/mysql-test/suite/innodb/t/dropdb.test b/mysql-test/suite/innodb/t/dropdb.test index 7f5ac809d7c..5e45e8608c2 100644 --- a/mysql-test/suite/innodb/t/dropdb.test +++ b/mysql-test/suite/innodb/t/dropdb.test @@ -1,5 +1,8 @@ --source include/have_innodb.inc +SET NAMES utf8; +call mtr.add_suppression("Invalid .old.. table or database name"); + --echo # --echo # Bug #19929435 DROP DATABASE HANGS WITH MALFORMED TABLE --echo # @@ -9,4 +12,5 @@ create database `b`; use `b`; --error ER_WRONG_TABLE_NAME create table `#mysql50#q.q` select 1; +create table `#mysql50#q·q` select 1; drop database `b`; diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc index 3997989233b..98bcc764b52 100644 --- a/storage/innobase/dict/dict0dict.cc +++ b/storage/innobase/dict/dict0dict.cc @@ -1201,7 +1201,8 @@ inline void dict_sys_t::add(dict_table_t* table) { ut_ad(!find(table)); - ulint fold = ut_fold_string(table->name.m_name); + ulint fold = my_crc32c(0, table->name.m_name, + strlen(table->name.m_name)); table->autoinc_mutex.init(); table->lock_mutex_init(); @@ -1545,10 +1546,11 @@ dict_table_rename_in_cache( dict_sys.assert_locked(); /* store the old/current name to an automatic variable */ - ut_a(strlen(table->name.m_name) < sizeof old_name); + const size_t old_name_len = strlen(table->name.m_name); + ut_a(old_name_len < sizeof old_name); strcpy(old_name, table->name.m_name); - fold = ut_fold_string(new_name); + fold = my_crc32c(0, new_name, strlen(new_name)); /* Look for a table with the same name: error if such exists */ dict_table_t* table2; @@ -1560,7 +1562,7 @@ dict_table_rename_in_cache( table2 = (dict_table_t*) -1; } ); if (table2) { - ib::error() << "Cannot rename table '" << old_name + ib::error() << "Cannot rename table '" << table->name << "' to '" << new_name << "' since the" " dictionary cache already contains '" << new_name << "'."; return(DB_ERROR); @@ -1574,7 +1576,7 @@ dict_table_rename_in_cache( /* Remove table from the hash tables of tables */ HASH_DELETE(dict_table_t, name_hash, &dict_sys.table_hash, - ut_fold_string(old_name), table); + my_crc32c(0, table->name.m_name, old_name_len), table); const bool keep_mdl_name = dict_table_t::is_temporary_name(new_name) && !table->name.is_temporary(); @@ -1922,7 +1924,9 @@ void dict_sys_t::remove(dict_table_t* table, bool lru, bool keep) /* Remove table from the hash tables of tables */ HASH_DELETE(dict_table_t, name_hash, &table_hash, - ut_fold_string(table->name.m_name), table); + my_crc32c(0, table->name.m_name, + strlen(table->name.m_name)), + table); hash_table_t* id_hash = table->is_temporary() ? &temp_id_hash : &table_id_hash; @@ -4663,7 +4667,7 @@ void dict_sys_t::resize() table= UT_LIST_GET_NEXT(table_LRU, table)) { ut_ad(!table->is_temporary()); - ulint fold= ut_fold_string(table->name.m_name); + ulint fold= my_crc32c(0, table->name.m_name, strlen(table->name.m_name)); ulint id_fold= ut_fold_ull(table->id); HASH_INSERT(dict_table_t, name_hash, &table_hash, fold, table); @@ -4673,7 +4677,7 @@ void dict_sys_t::resize() for (dict_table_t *table = UT_LIST_GET_FIRST(table_non_LRU); table; table= UT_LIST_GET_NEXT(table_LRU, table)) { - ulint fold= ut_fold_string(table->name.m_name); + ulint fold= my_crc32c(0, table->name.m_name, strlen(table->name.m_name)); ulint id_fold= ut_fold_ull(table->id); HASH_INSERT(dict_table_t, name_hash, &table_hash, fold, table); diff --git a/storage/innobase/include/dict0dict.h b/storage/innobase/include/dict0dict.h index 73008b7560a..3c0e93edc8f 100644 --- a/storage/innobase/include/dict0dict.h +++ b/storage/innobase/include/dict0dict.h @@ -32,6 +32,7 @@ Created 1/8/1996 Heikki Tuuri #include "dict0mem.h" #include "fsp0fsp.h" #include "srw_lock.h" +#include #include class MDL_ticket; @@ -1478,7 +1479,7 @@ public: { mysql_mutex_assert_owner(&mutex); dict_table_t *table; - ulint fold = ut_fold_ull(id); + ulint fold= ut_fold_ull(id); HASH_SEARCH(id_hash, &table_id_hash, fold, dict_table_t*, table, ut_ad(table->cached), table->id == id); DBUG_ASSERT(!table || !table->is_temporary()); @@ -1617,8 +1618,7 @@ public: assert_locked(); for (dict_table_t *table= static_cast (HASH_GET_FIRST(&table_hash, table_hash.calc_hash - (ut_fold_binary(reinterpret_cast - (name.data()), name.size())))); + (my_crc32c(0, name.data(), name.size())))); table; table= table->name_hash) if (strlen(table->name.m_name) == name.size() && !memcmp(table->name.m_name, name.data(), name.size())) diff --git a/storage/innobase/include/ut0rnd.h b/storage/innobase/include/ut0rnd.h index 5b1ae5bc0da..bcf47fa9c41 100644 --- a/storage/innobase/include/ut0rnd.h +++ b/storage/innobase/include/ut0rnd.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2019, 2020, MariaDB Corporation. +Copyright (c) 2019, 2021, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -90,15 +90,6 @@ ut_fold_ull( /*========*/ ib_uint64_t d) /*!< in: 64-bit integer */ MY_ATTRIBUTE((const)); -/*************************************************************//** -Folds a character string ending in the null character. -@return folded value */ -UNIV_INLINE -ulint -ut_fold_string( -/*===========*/ - const char* str) /*!< in: null-terminated string */ - MY_ATTRIBUTE((warn_unused_result)); /***********************************************************//** Looks for a prime number slightly greater than the given argument. The prime is chosen so that it is not near any power of 2. diff --git a/storage/innobase/include/ut0rnd.ic b/storage/innobase/include/ut0rnd.ic index c0105160a42..37da323f8f3 100644 --- a/storage/innobase/include/ut0rnd.ic +++ b/storage/innobase/include/ut0rnd.ic @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2019, MariaDB Corporation. +Copyright (c) 2017, 2021, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -59,28 +59,6 @@ ut_fold_ull( return(ut_fold_ulint_pair((ulint) d & ULINT32_MASK, (ulint) (d >> 32))); } - -/*************************************************************//** -Folds a character string ending in the null character. -@return folded value */ -UNIV_INLINE -ulint -ut_fold_string( -/*===========*/ - const char* str) /*!< in: null-terminated string */ -{ - ulint fold = 0; - - ut_ad(str); - - while (*str != '\0') { - fold = ut_fold_ulint_pair(fold, (ulint)(*str)); - str++; - } - - return(fold); -} - #endif /* !UNIV_INNOCHECKSUM */ /*************************************************************//** diff --git a/tpool/aio_liburing.cc b/tpool/aio_liburing.cc index 430c01c91a0..cca95bb6d37 100644 --- a/tpool/aio_liburing.cc +++ b/tpool/aio_liburing.cc @@ -162,12 +162,10 @@ private: io_uring_cqe_seen(&aio->uring_, cqe); - if (res == -EAGAIN) { - // If we need to resubmit the IO operation, but the ring is full, - // then just go the same path as for any other error codes. - if (!aio->submit_io(iocb)) - continue; - } + // If we need to resubmit the IO operation, but the ring is full, + // we will follow the same path as for any other error codes. + if (res == -EAGAIN && !aio->submit_io(iocb)) + continue; iocb->m_internal_task.m_func= iocb->m_callback; iocb->m_internal_task.m_arg= iocb; From cb0cad8156f5c7de3777e465a6b8f64bc440b278 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 14 Jun 2021 10:06:27 +0300 Subject: [PATCH 067/251] MDEV-25907: Assertion failed in dict_table_schema_check() dict_table_schema_check(): Simply remove the debug assertion. We will still return a failure. --- .../innodb/r/innodb_stats_create_on_corrupted.result | 9 +++++++++ .../innodb/t/innodb_stats_create_on_corrupted.test | 11 +++++++++++ storage/innobase/dict/dict0stats.cc | 1 - 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/innodb/r/innodb_stats_create_on_corrupted.result b/mysql-test/suite/innodb/r/innodb_stats_create_on_corrupted.result index 66ef5ed2696..3c3996e0bba 100644 --- a/mysql-test/suite/innodb/r/innodb_stats_create_on_corrupted.result +++ b/mysql-test/suite/innodb/r/innodb_stats_create_on_corrupted.result @@ -1,5 +1,7 @@ call mtr.add_suppression("InnoDB: Table .*innodb_index_stats.* not found"); call mtr.add_suppression("InnoDB: Fetch of persistent statistics requested for table .*"); +call mtr.add_suppression("InnoDB: Table mysql\\.innodb_index_stats has length mismatch in the column name stat_description\\. Please run mariadb-upgrade"); +call mtr.add_suppression("InnoDB: Column stat_description in table mysql\\.innodb_index_stats is VARCHAR"); ALTER TABLE mysql.innodb_index_stats RENAME TO mysql.innodb_index_stats_; CREATE TABLE test_ps_create_on_corrupted (a INT, PRIMARY KEY (a)) @@ -17,6 +19,13 @@ avg_row_length 0 max_data_length 0 index_length 0 ALTER TABLE mysql.innodb_index_stats_ RENAME TO mysql.innodb_index_stats; +SET old_mode=''; +ALTER TABLE mysql.innodb_index_stats +MODIFY stat_description VARCHAR(1024) COLLATE utf8_bin; +CREATE TABLE t (a INT) ENGINE=InnoDB STATS_PERSISTENT=1; +ALTER TABLE mysql.innodb_index_stats +MODIFY stat_description VARCHAR(1024) COLLATE utf8mb3_bin NOT NULL; +DROP TABLE t; # restart SELECT seq_in_index, column_name, cardinality FROM information_schema.statistics WHERE table_name = 'test_ps_create_on_corrupted' diff --git a/mysql-test/suite/innodb/t/innodb_stats_create_on_corrupted.test b/mysql-test/suite/innodb/t/innodb_stats_create_on_corrupted.test index 5d36cfdcbb9..2ca5ee9fe31 100644 --- a/mysql-test/suite/innodb/t/innodb_stats_create_on_corrupted.test +++ b/mysql-test/suite/innodb/t/innodb_stats_create_on_corrupted.test @@ -12,6 +12,8 @@ call mtr.add_suppression("InnoDB: Table .*innodb_index_stats.* not found"); call mtr.add_suppression("InnoDB: Fetch of persistent statistics requested for table .*"); +call mtr.add_suppression("InnoDB: Table mysql\\.innodb_index_stats has length mismatch in the column name stat_description\\. Please run mariadb-upgrade"); +call mtr.add_suppression("InnoDB: Column stat_description in table mysql\\.innodb_index_stats is VARCHAR"); -- vertical_results @@ -34,6 +36,15 @@ FROM information_schema.tables WHERE table_name = 'test_ps_create_on_corrupted'; # restore the persistent storage ALTER TABLE mysql.innodb_index_stats_ RENAME TO mysql.innodb_index_stats; +SET old_mode=''; +ALTER TABLE mysql.innodb_index_stats +MODIFY stat_description VARCHAR(1024) COLLATE utf8_bin; +CREATE TABLE t (a INT) ENGINE=InnoDB STATS_PERSISTENT=1; +ALTER TABLE mysql.innodb_index_stats +MODIFY stat_description VARCHAR(1024) COLLATE utf8mb3_bin NOT NULL; + +DROP TABLE t; + --source include/restart_mysqld.inc -- vertical_results diff --git a/storage/innobase/dict/dict0stats.cc b/storage/innobase/dict/dict0stats.cc index 3bc9ed79318..d8ae7106cdc 100644 --- a/storage/innobase/dict/dict0stats.cc +++ b/storage/innobase/dict/dict0stats.cc @@ -405,7 +405,6 @@ dict_table_schema_check( /* check length for exact match */ if (req_schema->columns[i].len != table->cols[j].len) { - ut_ad(table->cols[j].len < req_schema->columns[i].len); sql_print_warning("InnoDB: Table %s has" " length mismatch in the" " column name %s." From 193bfdd831bbbf65e74acd12baf691d4305e3c11 Mon Sep 17 00:00:00 2001 From: Rucha Deodhar Date: Mon, 8 Feb 2021 14:52:04 +0530 Subject: [PATCH 068/251] MDEV-22010: use executables MariaDB named in scripts As a part of this MDEV following changes were made: 1) Mariadb named executables used instead of mysql named executables in scripts 2) renamed mysql-test-run and mysql-stress-test to mariadb-test-run and mariadb-stress-test and created a symlink. --- .gitignore | 3 + debian/mariadb-test.install | 4 +- debian/mariadb-test.links | 6 +- mysql-test/CMakeLists.txt | 64 +++++++++++++++---- mysql-test/lib/mtr_stress.pl | 2 +- mysql-test/lib/v1/mtr_stress.pl | 2 +- ...-stress-test.pl => mariadb-stress-test.pl} | 0 ...{mysql-test-run.pl => mariadb-test-run.pl} | 8 +-- mysql-test/mtr.out-of-source | 2 +- mysql-test/suite/stress/t/wrapper.test | 2 +- scripts/CMakeLists.txt | 8 +-- scripts/mysql_install_db.sh | 20 +++--- scripts/mysql_secure_installation.sh | 8 +-- scripts/mysqlaccess.sh | 6 +- scripts/mysqld_multi.sh | 32 +++++----- scripts/mysqld_safe.sh | 3 +- scripts/wsrep_sst_common.sh | 12 ++-- 17 files changed, 113 insertions(+), 69 deletions(-) rename mysql-test/{mysql-stress-test.pl => mariadb-stress-test.pl} (100%) rename mysql-test/{mysql-test-run.pl => mariadb-test-run.pl} (99%) diff --git a/.gitignore b/.gitignore index 4de9edac44b..79f64810812 100644 --- a/.gitignore +++ b/.gitignore @@ -90,6 +90,9 @@ mysql-test/lib/My/SafeProcess/my_safe_process mysql-test/lib/My/SafeProcess/wsrep_check_version mysql-test/mtr mysql-test/mysql-test-run +mysql-test/mariadb-test-run +mysql-test/mysql-stress-test.pl +mysql-test/mysql-test-run.pl mysql-test/var* mysql-test-gcov.err mysql-test-gcov.msg diff --git a/debian/mariadb-test.install b/debian/mariadb-test.install index bbcc200c368..97384bd7ef1 100644 --- a/debian/mariadb-test.install +++ b/debian/mariadb-test.install @@ -25,7 +25,6 @@ usr/share/man/man1/mariadb-client-test-embedded.1 usr/share/man/man1/mariadb-client-test.1 usr/share/man/man1/mariadb-test-embedded.1 usr/share/man/man1/mariadb-test.1 -usr/share/man/man1/mysql-stress-test.pl.1 usr/share/man/man1/mysql-test-run.pl.1 usr/share/man/man1/mysql_client_test.1 usr/share/man/man1/mysql_client_test_embedded.1 @@ -36,8 +35,9 @@ usr/share/mysql/mysql-test/README-gcov usr/share/mysql/mysql-test/README.stress usr/share/mysql/mysql-test/dgcov.pl usr/share/mysql/mysql-test/lib -usr/share/mysql/mysql-test/mysql-stress-test.pl +usr/share/mysql/mysql-test/mariadb-stress-test.pl usr/share/mysql/mysql-test/mysql-test-run.pl +usr/share/mysql/mysql-test/mariadb-test-run.pl usr/share/mysql/mysql-test/purify.supp usr/share/mysql/mysql-test/suite.pm usr/share/mysql/mysql-test/valgrind.supp diff --git a/debian/mariadb-test.links b/debian/mariadb-test.links index 718a5355474..3c45bb955c4 100644 --- a/debian/mariadb-test.links +++ b/debian/mariadb-test.links @@ -2,5 +2,7 @@ usr/bin/mariadb-client-test usr/bin/mysql_client_test usr/bin/mariadb-client-test-embedded usr/bin/mysql_client_test_embedded usr/bin/mariadb-test usr/bin/mysqltest usr/bin/mariadb-test-embedded usr/bin/mysqltest_embedded -usr/share/mysql/mysql-test/mysql-test-run.pl usr/share/mysql/mysql-test/mtr -usr/share/mysql/mysql-test/mysql-test-run.pl usr/share/mysql/mysql-test/mysql-test-run +usr/share/mysql/mysql-test/mariadb-test-run.pl usr/share/mysql/mysql-test/mysql-test-run.pl +usr/share/mysql/mysql-test/mariadb-test-run.pl usr/share/mysql/mysql-test/mysql-test-run +usr/share/mysql/mysql-test/mariadb-test-run.pl usr/share/mysql/mysql-test/mtr +usr/share/mysql/mysql-test/mariadb-test-run.pl usr/share/mysql/mysql-test/mariadb-test-run diff --git a/mysql-test/CMakeLists.txt b/mysql-test/CMakeLists.txt index 7487e301df5..2c040fc0e32 100644 --- a/mysql-test/CMakeLists.txt +++ b/mysql-test/CMakeLists.txt @@ -19,24 +19,63 @@ INSTALL_MYSQL_TEST("." ".") IF(NOT ${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) # Enable running mtr from build directory CONFIGURE_FILE( - ${CMAKE_CURRENT_SOURCE_DIR}/mtr.out-of-source - ${CMAKE_CURRENT_BINARY_DIR}/mysql-test-run.pl + ${CMAKE_CURRENT_SOURCE_DIR}/mtr.out-of-source + ${CMAKE_CURRENT_BINARY_DIR}/mariadb-test-run.pl @ONLY ) + CONFIGURE_FILE( + ${CMAKE_CURRENT_SOURCE_DIR}/mariadb-stress-test.pl + ${CMAKE_CURRENT_BINARY_DIR}/mariadb-stress-test.pl + @ONLY + ) + IF(WIN32) + CONFIGURE_FILE( + ${CMAKE_CURRENT_SOURCE_DIR}/mtr.out-of-source + ${CMAKE_CURRENT_BINARY_DIR}/mysql-test-run.pl + @ONLY) + ENDIF() SET(out_of_source_build TRUE) +ELSEIF(WIN32) + CONFIGURE_FILE( + ${CMAKE_CURRENT_SOURCE_DIR}/mariadb-test-run.pl + ${CMAKE_CURRENT_BINARY_DIR}/mysql-test-run.pl + COPYONLY) + CONFIGURE_FILE( + ${CMAKE_CURRENT_SOURCE_DIR}/mariadb-stress-test.pl + ${CMAKE_CURRENT_BINARY_DIR}/mysql-stress-test.pl + COPYONLY) ENDIF() + IF(UNIX) EXECUTE_PROCESS( - COMMAND chmod +x mysql-test-run.pl - COMMAND ${CMAKE_COMMAND} -E create_symlink - ./mysql-test-run.pl mtr - COMMAND ${CMAKE_COMMAND} -E create_symlink - ./mysql-test-run.pl mysql-test-run - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - ) - IF(INSTALL_MYSQLTESTDIR AND out_of_source_build) - INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/mtr - ${CMAKE_CURRENT_BINARY_DIR}/mysql-test-run + COMMAND chmod +x mariadb-test-run.pl + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + FOREACH (lnk mysql-test-run mtr mysql-test-run.pl mariadb-test-run) + EXECUTE_PROCESS( + COMMAND ${CMAKE_COMMAND} -E create_symlink + ./mariadb-test-run.pl ${lnk} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + + IF(INSTALL_MYSQLTESTDIR) + INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${lnk} + DESTINATION ${INSTALL_MYSQLTESTDIR} + COMPONENT Test) + ENDIF() + ENDFOREACH() + EXECUTE_PROCESS( + COMMAND chmod +x mariadb-stress-test.pl + COMMAND ${CMAKE_COMMAND} -E create_symlink + ./mariadb-stress-test.pl mysql-stress-test.pl + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + ) +ELSE() + IF(INSTALL_MYSQLTESTDIR) + INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/mariadb-test-run.pl + RENAME mysql-test-run.pl + DESTINATION ${INSTALL_MYSQLTESTDIR} + COMPONENT Test) + INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/mariadb-stress-test.pl + RENAME mysql-stress-test.pl DESTINATION ${INSTALL_MYSQLTESTDIR} COMPONENT Test) ENDIF() @@ -156,4 +195,3 @@ IF (MAX_INDEXES) MESSAGE(STATUS "mysql-test/include/max_indexes.inc adjusted") ENDIF() ENDIF() - diff --git a/mysql-test/lib/mtr_stress.pl b/mysql-test/lib/mtr_stress.pl index 09c30d0988a..cf7064cb68f 100644 --- a/mysql-test/lib/mtr_stress.pl +++ b/mysql-test/lib/mtr_stress.pl @@ -136,7 +136,7 @@ sub run_stress_test () } mtr_init_args(\$args); - mtr_add_args($args, "$::glob_mysql_test_dir/mysql-stress-test.pl"); + mtr_add_args($args, "$::glob_mysql_test_dir/mariadb-stress-test.pl"); mtr_add_arg($args, "--server-socket=%s", $::master->[0]->{'path_sock'}); mtr_add_arg($args, "--server-user=%s", $::opt_user); mtr_add_arg($args, "--server-database=%s", "test"); diff --git a/mysql-test/lib/v1/mtr_stress.pl b/mysql-test/lib/v1/mtr_stress.pl index c19eb86ec9b..c96469a5d94 100644 --- a/mysql-test/lib/v1/mtr_stress.pl +++ b/mysql-test/lib/v1/mtr_stress.pl @@ -182,7 +182,7 @@ sub run_stress_test () } #Run stress test - mtr_run("$::glob_mysql_test_dir/mysql-stress-test.pl", $args, "", "", "", ""); + mtr_run("$::glob_mysql_test_dir/mariadb-stress-test.pl", $args, "", "", "", ""); if ( ! $::glob_use_embedded_server ) { stop_all_servers(); diff --git a/mysql-test/mysql-stress-test.pl b/mysql-test/mariadb-stress-test.pl similarity index 100% rename from mysql-test/mysql-stress-test.pl rename to mysql-test/mariadb-stress-test.pl diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mariadb-test-run.pl similarity index 99% rename from mysql-test/mysql-test-run.pl rename to mysql-test/mariadb-test-run.pl index 13369982daf..b0fd08abec2 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mariadb-test-run.pl @@ -35,7 +35,7 @@ use warnings; BEGIN { # Check that mysql-test-run.pl is started from mysql-test/ - unless ( -f "mysql-test-run.pl" ) + unless ( -f "mariadb-test-run.pl" ) { print "**** ERROR **** ", "You must start mysql-test-run from the mysql-test/ directory\n"; @@ -57,10 +57,10 @@ BEGIN { if ( $version == 1 ) { print "=======================================================\n"; - print " WARNING: Using mysql-test-run.pl version 1! \n"; + print " WARNING: Using mariadb-test-run.pl version 1! \n"; print "=======================================================\n"; # Should use exec() here on *nix but this appears not to work on Windows - exit(system($^X, "lib/v1/mysql-test-run.pl", @ARGV) >> 8); + exit(system($^X, "lib/v1/mariadb-test-run.pl", @ARGV) >> 8); } elsif ( $version == 2 ) { @@ -69,7 +69,7 @@ BEGIN { } else { - print "ERROR: Version $version of mysql-test-run does not exist!\n"; + print "ERROR: Version $version of mariadb-test-run does not exist!\n"; exit(1); } } diff --git a/mysql-test/mtr.out-of-source b/mysql-test/mtr.out-of-source index 30e2e65c569..abab0be90df 100644 --- a/mysql-test/mtr.out-of-source +++ b/mysql-test/mtr.out-of-source @@ -2,4 +2,4 @@ # Call mtr in out-of-source build $ENV{MTR_BINDIR} = '@CMAKE_BINARY_DIR@'; chdir('@CMAKE_SOURCE_DIR@/mysql-test'); -exit(system($^X, '@CMAKE_SOURCE_DIR@/mysql-test/mysql-test-run.pl', @ARGV) >> 8); +exit(system($^X, '@CMAKE_SOURCE_DIR@/mysql-test/mariadb-test-run.pl', @ARGV) >> 8); diff --git a/mysql-test/suite/stress/t/wrapper.test b/mysql-test/suite/stress/t/wrapper.test index 4d2dd808a4c..7a468985570 100644 --- a/mysql-test/suite/stress/t/wrapper.test +++ b/mysql-test/suite/stress/t/wrapper.test @@ -20,7 +20,7 @@ EOF --source $MYSQL_TMP_DIR/mtest.inc --remove_file $MYSQL_TMP_DIR/mtest.inc -exec perl mysql-stress-test.pl --mysqltest=$MYSQLTEST_BIN +exec perl mariadb-stress-test.pl --mysqltest=$MYSQLTEST_BIN --server-port=$MASTER_MYPORT --server-socket=$MASTER_MYSOCK --server-user=root --cleanup --server-logs-dir=$MYSQLTEST_VARDIR/log diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index 7d1f10e5ba2..02595e8bc04 100644 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -146,11 +146,11 @@ IF(UNIX) # FIND_PROC and CHECK_PID are used by mysqld_safe IF(CMAKE_SYSTEM_NAME MATCHES "Linux") SET (FIND_PROC - "ps wwwp $PID | grep -v mysqld_safe | grep -- $MYSQLD > /dev/null") + "ps wwwp $PID | grep -vE mariadbd-safe -vE mysqld_safe | grep -- $MYSQLD > /dev/null") ENDIF() IF(NOT FIND_PROC AND CMAKE_SYSTEM_NAME MATCHES "SunOS") SET (FIND_PROC - "ps -p $PID | grep -v mysqld_safe | grep -- $MYSQLD > /dev/null") + "ps -p $PID | grep -v mariadbd-safe | grep -- $MYSQLD > /dev/null") ENDIF() IF(NOT FIND_PROC) @@ -158,7 +158,7 @@ IF(NOT FIND_PROC) EXECUTE_PROCESS(COMMAND ps -uaxww OUTPUT_QUIET ERROR_QUIET RESULT_VARIABLE result) IF(result MATCHES 0) SET( FIND_PROC - "ps -uaxww | grep -v mysqld_safe | grep -- $MYSQLD | grep $PID > /dev/null") + "ps -uaxww | grep -v mariadbd-safe | grep -- $MYSQLD | grep $PID > /dev/null") ENDIF() ENDIF() @@ -166,7 +166,7 @@ IF(NOT FIND_PROC) # SysV style EXECUTE_PROCESS(COMMAND ps -ef OUTPUT_QUIET ERROR_QUIET RESULT_VARIABLE result) IF(result MATCHES 0) - SET( FIND_PROC "ps -ef | grep -v mysqld_safe | grep -- $MYSQLD | grep $PID > /dev/null") + SET( FIND_PROC "ps -ef | grep -v mariadbd-safe | grep -- $MYSQLD | grep $PID > /dev/null") ENDIF() ENDIF() diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh index 6b0c78ef702..f8e69e9a755 100644 --- a/scripts/mysql_install_db.sh +++ b/scripts/mysql_install_db.sh @@ -315,7 +315,7 @@ parse_arguments `"$print_defaults" $defaults $defaults_group_suffix --mysqld mys parse_arguments PICK-ARGS-FROM-ARGV "$@" -rel_mysqld="$dirname0/@INSTALL_SBINDIR@/mysqld" +rel_mysqld="$dirname0/@INSTALL_SBINDIR@/mariadbd" # Configure paths to support files if test -n "$srcdir" @@ -338,11 +338,11 @@ then cannot_find_file resolveip @resolveip_locations@ exit 1 fi - mysqld=`find_in_dirs mysqld @mysqld_locations@` + mysqld=`find_in_dirs mariadbd @mysqld_locations@` if test -z "$mysqld" then - cannot_find_file mysqld @mysqld_locations@ - exit 1 + cannot_find_file mariadbd @mysqld_locations@ + exit 1 fi langdir=`find_in_dirs --dir errmsg.sys @errmsg_locations@` if test -z "$langdir" @@ -360,7 +360,7 @@ then plugindir=`find_in_dirs --dir auth_pam.so $basedir/lib*/plugin $basedir/lib*/mysql/plugin $basedir/lib/*/mariadb19/plugin` pamtooldir=$plugindir # relative from where the script was run for a relocatable install -elif test -n "$dirname0" -a -x "$rel_mysqld" -a ! "$rel_mysqld" -ef "@sbindir@/mysqld" +elif test -n "$dirname0" -a -x "$rel_mysqld" -a ! "$rel_mysqld" -ef "@sbindir@/mariadbd" then basedir="$dirname0" bindir="$basedir/@INSTALL_BINDIR@" @@ -374,7 +374,7 @@ else basedir="@prefix@" bindir="@bindir@" resolveip="$bindir/resolveip" - mysqld="@sbindir@/mysqld" + mysqld="@sbindir@/mariadbd" srcpkgdatadir="@pkgdatadir@" buildpkgdatadir="@pkgdatadir@" plugindir="@pkgplugindir@" @@ -580,7 +580,7 @@ else echo echo " shell> $mysqld --skip-grant-tables --general-log &" echo - echo "and use the command line tool $bindir/mysql" + echo "and use the command line tool $bindir/mariadb" echo "to connect to the mysql database and look at the grant tables:" echo echo " shell> $bindir/mysql -u root mysql" @@ -614,11 +614,11 @@ then echo "PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !" echo "To do so, start the server, then issue the following commands:" echo - echo "'$bindir/mysqladmin' -u root password 'new-password'" - echo "'$bindir/mysqladmin' -u root -h $hostname password 'new-password'" + echo "'$bindir/mariadb-admin' -u root password 'new-password'" + echo "'$bindir/mariadb-admin' -u root -h $hostname password 'new-password'" echo echo "Alternatively you can run:" - echo "'$bindir/mysql_secure_installation'" + echo "'$bindir/mariadb-secure-installation'" echo echo "which will also give you the option of removing the test" echo "databases and anonymous user created by default. This is" diff --git a/scripts/mysql_secure_installation.sh b/scripts/mysql_secure_installation.sh index b2a9edf4953..40d8e5d330e 100644 --- a/scripts/mysql_secure_installation.sh +++ b/scripts/mysql_secure_installation.sh @@ -159,15 +159,15 @@ then cannot_find_file my_print_defaults $basedir/bin $basedir/extra exit 1 fi - mysql_command=`find_in_basedir mysql bin` + mysql_command=`find_in_basedir mariadb bin` if test -z "$mysql_command" then - cannot_find_file mysql $basedir/bin - exit 1 + cannot_find_file mariadb $basedir/bin + exit 1 fi else print_defaults="@bindir@/my_print_defaults" - mysql_command="@bindir@/mysql" + mysql_command="@bindir@/mariadb" fi if test ! -x "$print_defaults" diff --git a/scripts/mysqlaccess.sh b/scripts/mysqlaccess.sh index aaf711b0fb9..f6dbee75b87 100644 --- a/scripts/mysqlaccess.sh +++ b/scripts/mysqlaccess.sh @@ -35,7 +35,7 @@ BEGIN { # **************************** # information on MariaDB - $MYSQL = '@bindir@/mysql'; # path to mysql executable + $MYSQL = '@bindir@/mariadb'; # path to mariadb executable $SERVER = '3.21'; $MYSQL_OPT = ' --batch --unbuffered'; $ACCESS_DB = 'mysql'; # name of DB with grant-tables @@ -50,8 +50,8 @@ BEGIN { $ACCESS_U_BCK = 'user_backup'; $ACCESS_D_BCK = 'db_backup'; $DIFF = '/usr/bin/diff'; - $MYSQLDUMP = '@bindir@/mysqldump'; - #path to mysqldump executable + $MYSQLDUMP = '@bindir@/mariadb-dump'; + #path to mariadb-dump executable $MYSQLADMIN= 'http://foobar.com/MySQLadmin'; #URL of CGI for manipulating diff --git a/scripts/mysqld_multi.sh b/scripts/mysqld_multi.sh index 77ed36218d3..51cb052bde0 100644 --- a/scripts/mysqld_multi.sh +++ b/scripts/mysqld_multi.sh @@ -29,8 +29,8 @@ my @defaults_options; # Leading --no-defaults, --defaults-file, etc. $opt_example = 0; $opt_help = 0; $opt_log = undef(); -$opt_mysqladmin = "@bindir@/mysqladmin"; -$opt_mysqld = "@sbindir@/mysqld"; +$opt_mysqladmin = "@bindir@/mariadb-admin"; +$opt_mysqld = "@sbindir@/mariadbd"; $opt_no_log = 0; $opt_password = undef(); $opt_tcp_ip = 0; @@ -360,9 +360,9 @@ sub start_mysqlds() $tmp.= " $options[$j]"; } } - if ($opt_verbose && $com =~ m/\/(safe_mysqld|mysqld_safe)$/ && !$info_sent) + if ($opt_verbose && $com =~ m/\/(mariadbd-safe)$/ && !$info_sent) { - print "WARNING: $1 is being used to start mysqld. In this case you "; + print "WARNING: $1 is being used to start mariadbd. In this case you "; print "may need to pass\n\"ledir=...\" under groups [mysqldN] to "; print "$1 in order to find the actual mysqld binary.\n"; print "ledir (library executable directory) should be the path to the "; @@ -680,14 +680,14 @@ sub example # # 2.PID-FILE # -# If you are using mysqld_safe to start mysqld, make sure that every -# MariaDB server has a separate pid-file. In order to use mysqld_safe +# If you are using mariadbd-safe to start mariadbd, make sure that every +# MariaDB server has a separate pid-file. In order to use mariadbd-safe # via $my_progname, you need to use two options: # -# mysqld=/path/to/mysqld_safe -# ledir=/path/to/mysqld-binary/ +# mysqld=/path/to/mariadbd-safe +# ledir=/path/to/mariadbd-binary/ # -# ledir (library executable directory), is an option that only mysqld_safe +# ledir (library executable directory), is an option that only mariadbd-safe # accepts, so you will get an error if you try to pass it to mysqld directly. # For this reason you might want to use the above options within [mysqld#] # group directly. @@ -740,8 +740,8 @@ sub example # [mysqld_multi] -mysqld = @bindir@/mysqld_safe -mysqladmin = @bindir@/mysqladmin +mysqld = @bindir@/mariadbd-safe +mysqladmin = @bindir@/mariadb-admin user = multi_admin password = my_password @@ -754,9 +754,9 @@ language = @datadir@/mysql/english user = unix_user1 [mysqld3] -mysqld = /path/to/mysqld_safe -ledir = /path/to/mysqld-binary/ -mysqladmin = /path/to/mysqladmin +mysqld = /path/to/mariadbd-safe +ledir = /path/to/mariadbd-binary/ +mysqladmin = /path/to/mariadb-admin socket = /tmp/mysql.sock3 port = 3308 pid-file = @localstatedir@3/hostname.pid3 @@ -841,9 +841,9 @@ Using: @{[join ' ', @defaults_options]} --mysqladmin=... mysqladmin binary to be used for a server shutdown. Since version 2.10 this can be given within groups [mysqld#] Using: $mysqladmin ---mysqld=... mysqld binary to be used. Note that you can give mysqld_safe +--mysqld=... mariadbd binary to be used. Note that you can give mariadbd-safe to this option also. The options are passed to mysqld. Just - make sure you have mysqld in your PATH or fix mysqld_safe. + make sure you have mariadbd in your PATH or fix mariadbd-safe. Using: $mysqld Please note: Since mysqld_multi version 2.3 you can also give this option inside groups [mysqld#] in ~/.my.cnf, diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh index 126eb924814..d1819e0b115 100644 --- a/scripts/mysqld_safe.sh +++ b/scripts/mysqld_safe.sh @@ -531,7 +531,8 @@ else ledir='@libexecdir@' fi -helper=`find_in_bin mysqld_safe_helper` +helper=`find_in_bin mariadbd-safe-helper` + print_defaults=`find_in_bin my_print_defaults` # Check if helper exists command -v $helper --help >/dev/null 2>&1 diff --git a/scripts/wsrep_sst_common.sh b/scripts/wsrep_sst_common.sh index 05944ef6035..da5153b6e8e 100644 --- a/scripts/wsrep_sst_common.sh +++ b/scripts/wsrep_sst_common.sh @@ -603,16 +603,16 @@ SCRIPTS_DIR=$(cd "$script_binary"; pwd -P) EXTRA_DIR="$SCRIPTS_DIR/../extra" CLIENT_DIR="$SCRIPTS_DIR/../client" -if [ -x "$CLIENT_DIR/mysql" ]; then - MYSQL_CLIENT="$CLIENT_DIR/mysql" +if [ -x "$CLIENT_DIR/mariadb" ]; then + MYSQL_CLIENT="$CLIENT_DIR/mariadb" else - MYSQL_CLIENT="$(command -v mysql)" + MYSQL_CLIENT="$(command -v mariadb)" fi -if [ -x "$CLIENT_DIR/mysqldump" ]; then - MYSQLDUMP="$CLIENT_DIR/mysqldump" +if [ -x "$CLIENT_DIR/mariadb-dump" ]; then + MYSQLDUMP="$CLIENT_DIR/mariadb-dump" else - MYSQLDUMP="$(command -v mysqldump)" + MYSQLDUMP="$(command -v mariadb-dump)" fi wsrep_log() From 9c778285ea0f099f968382d6c71dd2e9d522e7c7 Mon Sep 17 00:00:00 2001 From: Monty Date: Wed, 9 Jun 2021 14:44:13 +0300 Subject: [PATCH 069/251] Added comments to some BUILD scripts --- BUILD/compile-pentium64-asan-max | 7 ++++++- BUILD/compile-pentium64-ubsan | 8 ++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/BUILD/compile-pentium64-asan-max b/BUILD/compile-pentium64-asan-max index 37acc9f74f3..cedf5254e59 100755 --- a/BUILD/compile-pentium64-asan-max +++ b/BUILD/compile-pentium64-asan-max @@ -17,7 +17,12 @@ path=`dirname $0` . "$path/SETUP.sh" -extra_flags="$pentium64_cflags $debug_cflags -lasan -O -g -fsanitize=address -USAFEMALLOC -UFORCE_INIT_OF_VARS -Wno-uninitialized -Wno-maybe-uninitialized" +# +# Enable AddressSanitzer, a fast memory error detector. +# Detects "Out of bounds" and "use-after-free" memory errors +# + +extra_flags="$pentium64_cflags $debug_cflags -lasan -O -g -fsanitize=address -USAFEMALLOC -UFORCE_INIT_OF_VARS -Wno-uninitialized -Wno-maybe-uninitialized -DMYSQL_SERVER_SUFFIX=-asan-max" extra_configs="$pentium_configs $debug_configs $valgrind_configs $max_configs $disable_asan_plugins" export LDFLAGS="-ldl" diff --git a/BUILD/compile-pentium64-ubsan b/BUILD/compile-pentium64-ubsan index 1a2b45413b0..538b5e884cf 100755 --- a/BUILD/compile-pentium64-ubsan +++ b/BUILD/compile-pentium64-ubsan @@ -23,6 +23,14 @@ path=`dirname $0` . "$path/SETUP.sh" +# +# Enable UBSAN, UndefinedBehaviorSanitizer. Detects undefined behavior like: +# - Using misaligned or null pointer +# - Signed integer overflow +# - Conversion to, from, or between floating-point types which would overflow +# the destination +# + extra_flags="$pentium64_cflags $debug_cflags -fsanitize=undefined -DWITH_UBSAN -Wno-conversion -Wno-uninitialized" extra_configs="$pentium_configs $debug_configs -DWITH_UBSAN=ON -DMYSQL_MAINTAINER_MODE=NO --without-spider" From 9d261eeca8c42e2f6ef0cad5c4537a9fcd7859ab Mon Sep 17 00:00:00 2001 From: Monty Date: Wed, 9 Jun 2021 14:46:33 +0300 Subject: [PATCH 070/251] Marked some very slow mtr tests with not_valgrind --- mysql-test/suite/archive/archive-big.test | 2 ++ mysql-test/suite/funcs_1/t/myisam_views-big.test | 4 ++-- mysql-test/suite/innodb/t/innodb_defragment.test | 2 ++ mysql-test/suite/parts/t/partition_alter4_innodb.test | 3 +++ 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/mysql-test/suite/archive/archive-big.test b/mysql-test/suite/archive/archive-big.test index 414b689b180..fd59df66b43 100644 --- a/mysql-test/suite/archive/archive-big.test +++ b/mysql-test/suite/archive/archive-big.test @@ -1,4 +1,6 @@ --source include/big_test.inc +# Valgrind is to slow for this test +--source include/not_valgrind.inc --source include/have_archive.inc CREATE TABLE t1(a BLOB) ENGINE=ARCHIVE; --disable_query_log diff --git a/mysql-test/suite/funcs_1/t/myisam_views-big.test b/mysql-test/suite/funcs_1/t/myisam_views-big.test index 21613e78b24..565a3b100b9 100644 --- a/mysql-test/suite/funcs_1/t/myisam_views-big.test +++ b/mysql-test/suite/funcs_1/t/myisam_views-big.test @@ -1,6 +1,6 @@ #### suite/funcs_1/t/myisam_views.test - ---source include/no_valgrind_without_big.inc +# Valgrind is to slow for this test +--source include/not_valgrind.inc # because of a pair of slow Solaris Sparc machines in pb2, # this test is marked as big: --source include/big_test.inc diff --git a/mysql-test/suite/innodb/t/innodb_defragment.test b/mysql-test/suite/innodb/t/innodb_defragment.test index d9f5f56316e..51ef78377cb 100644 --- a/mysql-test/suite/innodb/t/innodb_defragment.test +++ b/mysql-test/suite/innodb/t/innodb_defragment.test @@ -1,6 +1,8 @@ --source include/have_innodb.inc --source include/big_test.inc --source include/not_embedded.inc +# Valgrind is to slow for this test +--source include/not_valgrind.inc set global innodb_defragment_stats_accuracy = 80; diff --git a/mysql-test/suite/parts/t/partition_alter4_innodb.test b/mysql-test/suite/parts/t/partition_alter4_innodb.test index cf4bd610ff1..dcbab787ab7 100644 --- a/mysql-test/suite/parts/t/partition_alter4_innodb.test +++ b/mysql-test/suite/parts/t/partition_alter4_innodb.test @@ -49,6 +49,9 @@ let $more_pk_ui_tests= 0; # This test takes long time, so only run it with the --big mtr-flag. --source include/big_test.inc +# Valgrind is to slow for this test +--source include/not_valgrind.inc + #------------------------------------------------------------------------------# # Engine specific settings and requirements From 6f15a8e4f701e28a6e1f57dd535f70c6ea55d731 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 11 Jun 2021 14:24:03 +0300 Subject: [PATCH 071/251] Don't run test "forever" with mysql-test-run --valgrind Test times when using --valgrind are now 4 hours and server start/shutdown time 180 seconds. The whole test suite time is caped at 1 day instead of 7 days Reviewer: Monty --- mysql-test/lib/My/Debugger.pm | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/mysql-test/lib/My/Debugger.pm b/mysql-test/lib/My/Debugger.pm index 5288f0740fa..2a5c9c63d96 100644 --- a/mysql-test/lib/My/Debugger.pm +++ b/mysql-test/lib/My/Debugger.pm @@ -45,6 +45,7 @@ my %debuggers = ( script => 'set args {args} < {input}', }, ddd => { + interactive => 1, options => '--command {script} {exe}', script => 'set args {args} < {input}', }, @@ -53,9 +54,11 @@ my %debuggers = ( options => '-c "stop in main; run {exe} {args} < {input}"', }, devenv => { + interactive => 1, options => '/debugexe {exe} {args}', }, windbg => { + interactive => 1, options => '{exe} {args}', }, lldb => { @@ -190,11 +193,15 @@ sub fix_options(@) { sub pre_setup() { my $used; + my $interactive; for my $k (keys %debuggers) { for my $opt ($k, "manual-$k", "boot-$k", "client-$k") { if ($opt_vals{$opt}) { $used = 1; + $interactive ||= ($debuggers{$k}->{interactive} || + $debuggers{$k}->{term} || + ($opt =~ /^manual-/)); if ($debuggers{$k}->{pre}) { $debuggers{$k}->{pre}->(); delete $debuggers{$k}->{pre}; @@ -209,10 +216,10 @@ sub pre_setup() { $::opt_retry= 1; $::opt_retry_failure= 1; - $::opt_testcase_timeout= 7 * 24 * 60; # in minutes - $::opt_suite_timeout= 7 * 24 * 60; # in minutes - $::opt_shutdown_timeout= 24 * 60 *60; # in seconds - $::opt_start_timeout= 24 * 60 * 60; # in seconds + $::opt_testcase_timeout= ($interactive ? 24 : 4) * 60; # in minutes + $::opt_suite_timeout= 24 * 60; # in minutes + $::opt_shutdown_timeout= ($interactive ? 24 * 60 : 3) * 60; # in seconds + $::opt_start_timeout= $::opt_shutdown_timeout; # in seconds } } From 15d2a6cfa31f3451abc78edba9df656df1456355 Mon Sep 17 00:00:00 2001 From: Monty Date: Fri, 11 Jun 2021 14:26:50 +0300 Subject: [PATCH 072/251] Fixed mysql-test-run "Waiting ... seconds for pidfile" output Now the output is only written every 60 second (as it used to be before my latest change to sleep_until_file_created()). --- mysql-test/lib/mtr_process.pl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mysql-test/lib/mtr_process.pl b/mysql-test/lib/mtr_process.pl index 7cadc5488a0..4c64a546f65 100644 --- a/mysql-test/lib/mtr_process.pl +++ b/mysql-test/lib/mtr_process.pl @@ -109,6 +109,7 @@ sub sleep_until_file_created ($$$$) { my $warn_seconds = shift; my $sleeptime= 10; # Milliseconds my $loops= ($timeout * 10000) / $sleeptime; + my $message_time= 60; for ( my $loop= 0; $loop <= $loops; $loop++ ) { @@ -130,9 +131,10 @@ sub sleep_until_file_created ($$$$) { mtr_debug("Sleep $sleeptime milliseconds waiting for $pidfile"); # Print extra message every $warn_seconds seconds - if ( $seconds > 1 && ($seconds*10) % ($warn_seconds*10) == 0 && $seconds < $timeout ) + if ( $seconds >= $message_time) { - my $left= $timeout - $seconds; + $message_time= $message_time+60; + my $left= $timeout - int($seconds); mtr_warning("Waited $seconds seconds for $pidfile to be created, " . "still waiting for $left seconds..."); } From 8d37ef29990f26b9de0789ee34f88dbea4dd8ac8 Mon Sep 17 00:00:00 2001 From: Monty Date: Wed, 9 Jun 2021 14:48:28 +0300 Subject: [PATCH 073/251] Aria now marks not used varchar space with MEM_UNDEFINED on read. --- storage/maria/ma_blockrec.c | 6 +++++- storage/maria/ma_dynrec.c | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/storage/maria/ma_blockrec.c b/storage/maria/ma_blockrec.c index ad4ffa349d0..a89ac966a75 100644 --- a/storage/maria/ma_blockrec.c +++ b/storage/maria/ma_blockrec.c @@ -4912,9 +4912,11 @@ int _ma_read_block_record2(MARIA_HA *info, uchar *record, case FIELD_VARCHAR: { ulong length; + uint pack_length __attribute__((unused)); if (column->length <= 256) { length= (uint) (uchar) (*field_pos++= *field_length_data++); + pack_length= 1; } else { @@ -4923,14 +4925,16 @@ int _ma_read_block_record2(MARIA_HA *info, uchar *record, field_pos[1]= field_length_data[1]; field_pos+= 2; field_length_data+= 2; + pack_length= 2; } #ifdef SANITY_CHECKS - if (length > column->length) + if (length > column->length - pack_length) goto err; #endif if (read_long_data(info, field_pos, length, &extent, &data, &end_of_data)) DBUG_RETURN(my_errno); + MEM_UNDEFINED(field_pos + length, column->length - length - pack_length); break; } case FIELD_BLOB: diff --git a/storage/maria/ma_dynrec.c b/storage/maria/ma_dynrec.c index f36e7dd9363..7bd85ae5fd1 100644 --- a/storage/maria/ma_dynrec.c +++ b/storage/maria/ma_dynrec.c @@ -1297,6 +1297,8 @@ size_t _ma_rec_unpack(register MARIA_HA *info, register uchar *to, uchar *from, if (from+length > from_end) goto err; memcpy(to+pack_length, from, length); + MEM_UNDEFINED(to+pack_length + length, + column_length - length - pack_length); from+= length; min_pack_length--; continue; From 4ea1c48abe3087a38a6260c8e21084de5e1a105b Mon Sep 17 00:00:00 2001 From: Monty Date: Wed, 9 Jun 2021 14:49:58 +0300 Subject: [PATCH 074/251] Added a function comment to Field_varstring::mark_unused_memory_as_defined() --- sql/field.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sql/field.cc b/sql/field.cc index 37d16d33212..d7dbc827ce2 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -7867,6 +7867,19 @@ bool Field_varstring::send(Protocol *protocol) #ifdef HAVE_MEM_CHECK + +/* + Mark the unused part of the varstring as defined. + + This function is only used be Unique when calculating statistics. + + The marking is needed as we write the whole tree to disk in case of + overflows. For using or comparing values the undefined value part + is never used. We could also use bzero() here, but it would be + slower in production environments. + This function is tested by main.stat_tables-enospc +*/ + void Field_varstring::mark_unused_memory_as_defined() { uint used_length __attribute__((unused)) = get_length(); From af33202af753da93e48f30b83c959c5a587f2458 Mon Sep 17 00:00:00 2001 From: Monty Date: Fri, 11 Jun 2021 15:34:23 +0300 Subject: [PATCH 075/251] Added DDL_options_st *thd_ddl_options(const MYSQL_THD thd) This is used by InnoDB to detect if CREATE...SELECT is used Other things: - Changed InnoDB to use thd_ddl_options() - Removed lock checking code for create...select (Approved by Marko) --- include/mysql/plugin.h | 2 ++ include/mysql/plugin_audit.h.pp | 2 ++ include/mysql/plugin_auth.h.pp | 2 ++ include/mysql/plugin_data_type.h.pp | 2 ++ include/mysql/plugin_encryption.h.pp | 2 ++ include/mysql/plugin_ftparser.h.pp | 2 ++ include/mysql/plugin_function.h.pp | 2 ++ include/mysql/plugin_password_validation.h.pp | 2 ++ sql/sql_class.cc | 12 +++++++++++ sql/sql_yacc.yy | 3 +++ sql/structs.h | 5 ++++- storage/innobase/handler/ha_innodb.cc | 20 +++++++------------ 12 files changed, 42 insertions(+), 14 deletions(-) diff --git a/include/mysql/plugin.h b/include/mysql/plugin.h index 738ffc6c53f..d3301a36e82 100644 --- a/include/mysql/plugin.h +++ b/include/mysql/plugin.h @@ -660,6 +660,8 @@ int thd_in_lock_tables(const MYSQL_THD thd); int thd_tablespace_op(const MYSQL_THD thd); long long thd_test_options(const MYSQL_THD thd, long long test_options); int thd_sql_command(const MYSQL_THD thd); +struct DDL_options_st; +struct DDL_options_st *thd_ddl_options(const MYSQL_THD thd); void thd_storage_lock_wait(MYSQL_THD thd, long long value); int thd_tx_isolation(const MYSQL_THD thd); int thd_tx_is_read_only(const MYSQL_THD thd); diff --git a/include/mysql/plugin_audit.h.pp b/include/mysql/plugin_audit.h.pp index 07fe16ea92f..2e0cdff4b50 100644 --- a/include/mysql/plugin_audit.h.pp +++ b/include/mysql/plugin_audit.h.pp @@ -608,6 +608,8 @@ int thd_in_lock_tables(const THD* thd); int thd_tablespace_op(const THD* thd); long long thd_test_options(const THD* thd, long long test_options); int thd_sql_command(const THD* thd); +struct DDL_options_st; +struct DDL_options_st *thd_ddl_options(const THD* thd); void thd_storage_lock_wait(THD* thd, long long value); int thd_tx_isolation(const THD* thd); int thd_tx_is_read_only(const THD* thd); diff --git a/include/mysql/plugin_auth.h.pp b/include/mysql/plugin_auth.h.pp index 18eebd5e04a..464c5514acb 100644 --- a/include/mysql/plugin_auth.h.pp +++ b/include/mysql/plugin_auth.h.pp @@ -608,6 +608,8 @@ int thd_in_lock_tables(const THD* thd); int thd_tablespace_op(const THD* thd); long long thd_test_options(const THD* thd, long long test_options); int thd_sql_command(const THD* thd); +struct DDL_options_st; +struct DDL_options_st *thd_ddl_options(const THD* thd); void thd_storage_lock_wait(THD* thd, long long value); int thd_tx_isolation(const THD* thd); int thd_tx_is_read_only(const THD* thd); diff --git a/include/mysql/plugin_data_type.h.pp b/include/mysql/plugin_data_type.h.pp index 3db2fdd0251..cb256e00cd7 100644 --- a/include/mysql/plugin_data_type.h.pp +++ b/include/mysql/plugin_data_type.h.pp @@ -608,6 +608,8 @@ int thd_in_lock_tables(const THD* thd); int thd_tablespace_op(const THD* thd); long long thd_test_options(const THD* thd, long long test_options); int thd_sql_command(const THD* thd); +struct DDL_options_st; +struct DDL_options_st *thd_ddl_options(const THD* thd); void thd_storage_lock_wait(THD* thd, long long value); int thd_tx_isolation(const THD* thd); int thd_tx_is_read_only(const THD* thd); diff --git a/include/mysql/plugin_encryption.h.pp b/include/mysql/plugin_encryption.h.pp index ff436bb24c4..11cd622861c 100644 --- a/include/mysql/plugin_encryption.h.pp +++ b/include/mysql/plugin_encryption.h.pp @@ -608,6 +608,8 @@ int thd_in_lock_tables(const THD* thd); int thd_tablespace_op(const THD* thd); long long thd_test_options(const THD* thd, long long test_options); int thd_sql_command(const THD* thd); +struct DDL_options_st; +struct DDL_options_st *thd_ddl_options(const THD* thd); void thd_storage_lock_wait(THD* thd, long long value); int thd_tx_isolation(const THD* thd); int thd_tx_is_read_only(const THD* thd); diff --git a/include/mysql/plugin_ftparser.h.pp b/include/mysql/plugin_ftparser.h.pp index daefd6b2838..9a798627518 100644 --- a/include/mysql/plugin_ftparser.h.pp +++ b/include/mysql/plugin_ftparser.h.pp @@ -560,6 +560,8 @@ int thd_in_lock_tables(const THD* thd); int thd_tablespace_op(const THD* thd); long long thd_test_options(const THD* thd, long long test_options); int thd_sql_command(const THD* thd); +struct DDL_options_st; +struct DDL_options_st *thd_ddl_options(const THD* thd); void thd_storage_lock_wait(THD* thd, long long value); int thd_tx_isolation(const THD* thd); int thd_tx_is_read_only(const THD* thd); diff --git a/include/mysql/plugin_function.h.pp b/include/mysql/plugin_function.h.pp index 0f915c8413f..4b2a0fc7082 100644 --- a/include/mysql/plugin_function.h.pp +++ b/include/mysql/plugin_function.h.pp @@ -608,6 +608,8 @@ int thd_in_lock_tables(const THD* thd); int thd_tablespace_op(const THD* thd); long long thd_test_options(const THD* thd, long long test_options); int thd_sql_command(const THD* thd); +struct DDL_options_st; +struct DDL_options_st *thd_ddl_options(const THD* thd); void thd_storage_lock_wait(THD* thd, long long value); int thd_tx_isolation(const THD* thd); int thd_tx_is_read_only(const THD* thd); diff --git a/include/mysql/plugin_password_validation.h.pp b/include/mysql/plugin_password_validation.h.pp index fc8c3848f8c..eae776a753b 100644 --- a/include/mysql/plugin_password_validation.h.pp +++ b/include/mysql/plugin_password_validation.h.pp @@ -608,6 +608,8 @@ int thd_in_lock_tables(const THD* thd); int thd_tablespace_op(const THD* thd); long long thd_test_options(const THD* thd, long long test_options); int thd_sql_command(const THD* thd); +struct DDL_options_st; +struct DDL_options_st *thd_ddl_options(const THD* thd); void thd_storage_lock_wait(THD* thd, long long value); int thd_tx_isolation(const THD* thd); int thd_tx_is_read_only(const THD* thd); diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 1d27854dc82..6317e578156 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -499,6 +499,18 @@ int thd_sql_command(const THD *thd) return (int) thd->lex->sql_command; } +/* + Returns options used with DDL's, like IF EXISTS etc... + Will returns 'nonsense' if the command was not a DDL. +*/ + +extern "C" +struct DDL_options_st *thd_ddl_options(const THD *thd) +{ + return &thd->lex->create_info; +} + + extern "C" int thd_tx_isolation(const THD *thd) { diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index b91b657dea3..dc2eb4425f0 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -4675,6 +4675,9 @@ create_like: opt_create_select: /* empty */ {} | opt_duplicate opt_as create_select_query_expression opt_versioning_option + { + Lex->create_info.add(DDL_options_st::OPT_CREATE_SELECT); + } ; create_select_query_expression: diff --git a/sql/structs.h b/sql/structs.h index fa0da6e0dbb..59bab6c6f18 100644 --- a/sql/structs.h +++ b/sql/structs.h @@ -537,7 +537,8 @@ public: OPT_OR_REPLACE= 16, // CREATE OR REPLACE TABLE OPT_OR_REPLACE_SLAVE_GENERATED= 32,// REPLACE was added on slave, it was // not in the original query on master. - OPT_IF_EXISTS= 64 + OPT_IF_EXISTS= 64, + OPT_CREATE_SELECT= 128 // CREATE ... SELECT }; private: @@ -565,6 +566,8 @@ public: { return m_options & OPT_OR_REPLACE_SLAVE_GENERATED; } bool like() const { return m_options & OPT_LIKE; } bool if_exists() const { return m_options & OPT_IF_EXISTS; } + bool is_create_select() const { return m_options & OPT_CREATE_SELECT; } + void add(const DDL_options_st::Options other) { m_options= (Options) ((uint) m_options | (uint) other); diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index bfb587bef6a..2c0a5f8f114 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -13258,21 +13258,15 @@ int ha_innobase::delete_table(const char *name) trx_t *trx= parent_trx; if (!trx->lock.table_locks.empty() && - thd_sql_command(trx->mysql_thd) == SQLCOM_CREATE_TABLE) + thd_ddl_options(trx->mysql_thd)->is_create_select()) { -#if 0 // MDEV-21602 FIXME: this fails for innodb.innodb and some others - for (const lock_t *l : trx->lock.table_locks) - if (l && l->type_mode == (LOCK_IX | LOCK_TABLE) && - l->un_member.tab_lock.table == table) - goto create_select; - sql_print_warning("InnoDB: CREATE...SELECT did not hold expected locks"); -create_select: -#endif /* CREATE TABLE...PRIMARY KEY...SELECT ought to be dropping the - table because a duplicate key was detected. We shall hijack the - existing transaction to drop the table and commit the transaction. - If this is a partitioned table, one partition will use this hijacked - transaction; others will use a separate transaction, one per partition. */ + table because a duplicate key was detected or a timeout occurred. + + We shall hijack the existing transaction to drop the table and + commit the transaction. If this is a partitioned table, one + partition will use this hijacked transaction; others will use a + separate transaction, one per partition. */ ut_ad(!trx->dict_operation_lock_mode); ut_ad(trx->will_lock); ut_ad(trx->state == TRX_STATE_ACTIVE); From c2c10094a81ef64b2db9b9154abe6109133461e6 Mon Sep 17 00:00:00 2001 From: Monty Date: Sun, 13 Jun 2021 19:38:16 +0300 Subject: [PATCH 076/251] Made main.flush more resilient for parallel threads --- mysql-test/main/flush.result | 3 +++ mysql-test/main/flush.test | 3 +++ 2 files changed, 6 insertions(+) diff --git a/mysql-test/main/flush.result b/mysql-test/main/flush.result index 54f104430c8..941dc63e3da 100644 --- a/mysql-test/main/flush.result +++ b/mysql-test/main/flush.result @@ -608,7 +608,10 @@ disconnect con1; # # Test FLUSH THREADS # +set @save_thread_cache_size=@@global.thread_cache_size; +set @@global.thread_cache_size=0; flush threads; show status like "Threads_cached"; Variable_name Value Threads_cached 0 +set @@global.thread_cache_size=@save_thread_cache_size; diff --git a/mysql-test/main/flush.test b/mysql-test/main/flush.test index 38735641bbf..97830238b0e 100644 --- a/mysql-test/main/flush.test +++ b/mysql-test/main/flush.test @@ -727,5 +727,8 @@ disconnect con1; --echo # Test FLUSH THREADS --echo # +set @save_thread_cache_size=@@global.thread_cache_size; +set @@global.thread_cache_size=0; flush threads; show status like "Threads_cached"; +set @@global.thread_cache_size=@save_thread_cache_size; From 7f0024a54f9b107800ddbd21246e375f4660790d Mon Sep 17 00:00:00 2001 From: Monty Date: Mon, 14 Jun 2021 19:51:37 +0300 Subject: [PATCH 077/251] Fixed BUILD scripts to remove all .gcov and .gcno files from submodules Other things: - Do not use ccache when building with gcov --- BUILD/FINISH.sh | 6 ++++++ BUILD/SETUP.sh | 8 +------- BUILD/compile-amd64-gcov | 3 ++- BUILD/compile-pentium64-gcov | 4 +++- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/BUILD/FINISH.sh b/BUILD/FINISH.sh index 015f973d8a8..14347ca8232 100644 --- a/BUILD/FINISH.sh +++ b/BUILD/FINISH.sh @@ -40,16 +40,22 @@ then git clean -fdX cd ./libmariadb git submodule update +git clean -fdX cd ../storage/rocksdb/rocksdb +git clean -fdX git submodule update +git clean -fdX cd ../../maria/libmarias3 git submodule update +git clean -fdX cd ../../.. cd storage/columnstore/columnstore git submodule update +git clean -fdX cd ../../.. cd wsrep-lib git submodule update +git clean -fdX cd .." fi commands="$commands diff --git a/BUILD/SETUP.sh b/BUILD/SETUP.sh index 9cd022f8ad8..e77d86d2462 100755 --- a/BUILD/SETUP.sh +++ b/BUILD/SETUP.sh @@ -274,13 +274,7 @@ fi # As cmake doesn't like CC and CXX with a space, use symlinks from # /usr/lib64/ccache if they exits. -if test "$USING_GCOV" != "1" -then - # Not using gcov; Safe to use ccache - CCACHE_GCOV_VERSION_ENABLED=1 -fi - -if ccache -V > /dev/null 2>&1 && test "$CCACHE_GCOV_VERSION_ENABLED" = "1" && test "$CC" = "gcc" +if ccache -V > /dev/null 2>&1 && test "$CCACHE_DISABLE" != "1" && test "$CC" = "gcc" then if test -x /usr/lib64/ccache/gcc then diff --git a/BUILD/compile-amd64-gcov b/BUILD/compile-amd64-gcov index c9bd3f36dd2..83c6b64d678 100755 --- a/BUILD/compile-amd64-gcov +++ b/BUILD/compile-amd64-gcov @@ -16,12 +16,13 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA path=`dirname $0` -. "$path/SETUP.sh" # Need to disable ccache, or we loose the gcov-needed compiler output files. CCACHE_DISABLE=1 export CCACHE_DISABLE +. "$path/SETUP.sh" + export LDFLAGS="$gcov_link_flags" extra_flags="$amd64_cflags $debug_cflags $max_cflags $gcov_compile_flags" diff --git a/BUILD/compile-pentium64-gcov b/BUILD/compile-pentium64-gcov index 534ee8a6b3e..f66499cbc36 100755 --- a/BUILD/compile-pentium64-gcov +++ b/BUILD/compile-pentium64-gcov @@ -16,13 +16,15 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA +set -x -v path=`dirname $0` -. "$path/SETUP.sh" # Need to disable ccache, or we loose the gcov-needed compiler output files. CCACHE_DISABLE=1 export CCACHE_DISABLE +. "$path/SETUP.sh" + export LDFLAGS="$gcov_link_flags" extra_flags="$pentium64_cflags $max_cflags $gcov_compile_flags" From 6e282e7efc0be5cb3b08c42a653a46a2a4a91edf Mon Sep 17 00:00:00 2001 From: Monty Date: Mon, 14 Jun 2021 18:40:06 +0300 Subject: [PATCH 078/251] MDEV-20787 Script dgcov.pl does not work Author: Anel Husakovic --- mysql-test/dgcov.pl | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mysql-test/dgcov.pl b/mysql-test/dgcov.pl index f04c73969b5..525db191efa 100755 --- a/mysql-test/dgcov.pl +++ b/mysql-test/dgcov.pl @@ -161,8 +161,13 @@ sub gcov_one_file { system($cmd)==0 or die "system($cmd): $? $!"; } - # now, read the generated file - open FH, '<', "$_.gcov" or die "open(<$_.gcov): $!"; + (my $filename = $_)=~ s/\.[^.]+$//; # remove extension + my $gcov_file_path= $File::Find::dir."/$filename.gcov"; + if (! -f $gcov_file_path) + { + return; + } + open FH, '<', "$gcov_file_path" or die "open(<$gcov_file_path): $!"; my $fname; while () { chomp; From 6653206467b746e9743e50c55b8db8ca7462ce4f Mon Sep 17 00:00:00 2001 From: Monty Date: Sun, 13 Jun 2021 19:46:16 +0300 Subject: [PATCH 079/251] Fixed compiler warnings - Replace strncpy() with strmake() to ensure things are \0 terminated - Initialized some variables that caused compiler warnings - Increased buffer that caused warnings from strncpy One warning from InnoDB, others from Connect. --- storage/connect/filamdbf.cpp | 3 ++- storage/connect/jsonudf.cpp | 18 +++++++++--------- storage/connect/tabxml.cpp | 18 ++++++++++-------- storage/innobase/handler/i_s.cc | 2 +- .../vendor/groonga/lib/ts/ts_expr_parser.c | 18 +++++++++--------- .../normalizers/mysql.c | 2 +- 6 files changed, 32 insertions(+), 29 deletions(-) diff --git a/storage/connect/filamdbf.cpp b/storage/connect/filamdbf.cpp index c8571cea559..9654c59f0fe 100644 --- a/storage/connect/filamdbf.cpp +++ b/storage/connect/filamdbf.cpp @@ -55,6 +55,7 @@ #define NO_FUNC #include "plgcnx.h" // For DB types #include "resource.h" +#include "m_string.h" // For strmake /****************************************************************************/ /* Definitions. */ @@ -732,7 +733,7 @@ bool DBFFAM::AllocateBuffer(PGLOBAL g) return true; } // endswitch c - strncpy(descp->Name, cdp->GetName(), 11); + strmake(descp->Name, cdp->GetName(), sizeof(descp->Name)-1); descp->Type = c; descp->Length = (uchar)cdp->GetLong(); } // endif Flags diff --git a/storage/connect/jsonudf.cpp b/storage/connect/jsonudf.cpp index c633993863c..af12f42f1d4 100644 --- a/storage/connect/jsonudf.cpp +++ b/storage/connect/jsonudf.cpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include "jsonudf.h" @@ -1475,16 +1475,16 @@ static PBSON MakeBinResult(PGLOBAL g, UDF_ARGS *args, PJSON top, ulong len, int if ((bsnp->Filename = (char*)args->args[0])) { bsnp->Filename = MakePSZ(g, args, 0); - strncpy(bsnp->Msg, bsnp->Filename, BMX); + strmake(bsnp->Msg, bsnp->Filename, BMX-1); } else - strncpy(bsnp->Msg, "null filename", BMX); + strmake(bsnp->Msg, "null filename", BMX-1); } else if (IsJson(args, 0) == 3) { PBSON bsp = (PBSON)args->args[0]; if (bsp->Filename) { bsnp->Filename = bsp->Filename; - strncpy(bsnp->Msg, bsp->Filename, BMX); + strmake(bsnp->Msg, bsp->Filename, BMX-1); bsnp->Pretty = bsp->Pretty; } else strcpy(bsnp->Msg, "Json Binary item"); @@ -4758,7 +4758,7 @@ char *jbin_array(UDF_INIT *initid, UDF_ARGS *args, char *result, bsp = NULL; if (!bsp && (bsp = JbinAlloc(g, args, initid->max_length, NULL))) - strncpy(bsp->Msg, g->Message, BMX); + strmake(bsp->Msg, g->Message, BMX-1); // Keep result of constant function g->Xchk = (initid->const_item) ? bsp : NULL; @@ -4829,7 +4829,7 @@ char *jbin_array_add_values(UDF_INIT *initid, UDF_ARGS *args, char *result, } else if ((bsp = JbinAlloc(g, args, initid->max_length, NULL))) - strncpy(bsp->Msg, g->Message, BMX); + strmake(bsp->Msg, g->Message, BMX-1); // Keep result of constant function g->Xchk = (initid->const_item) ? bsp : NULL; @@ -5051,7 +5051,7 @@ char *jbin_object(UDF_INIT *initid, UDF_ARGS *args, char *result, } else if ((bsp = JbinAlloc(g, args, initid->max_length, NULL))) - strncpy(bsp->Msg, g->Message, BMX); + strmake(bsp->Msg, g->Message, BMX-1); // Keep result of constant function g->Xchk = (initid->const_item) ? bsp : NULL; @@ -5107,7 +5107,7 @@ char *jbin_object_nonull(UDF_INIT *initid, UDF_ARGS *args, char *result, } else if ((bsp = JbinAlloc(g, args, initid->max_length, NULL))) - strncpy(bsp->Msg, g->Message, BMX); + strmake(bsp->Msg, g->Message, BMX-1); // Keep result of constant function g->Xchk = (initid->const_item) ? bsp : NULL; @@ -5166,7 +5166,7 @@ char *jbin_object_key(UDF_INIT *initid, UDF_ARGS *args, char *result, } else if ((bsp = JbinAlloc(g, args, initid->max_length, NULL))) - strncpy(bsp->Msg, g->Message, BMX); + strmake(bsp->Msg, g->Message, BMX-1); // Keep result of constant function g->Xchk = (initid->const_item) ? bsp : NULL; diff --git a/storage/connect/tabxml.cpp b/storage/connect/tabxml.cpp index dcebe18dd36..9575d917dd4 100644 --- a/storage/connect/tabxml.cpp +++ b/storage/connect/tabxml.cpp @@ -12,9 +12,8 @@ /* Include required compiler header files. */ /***********************************************************************/ #include "my_global.h" -#include +#include #include -#include #if defined(__WIN__) #include #include @@ -252,10 +251,11 @@ PQRYRES XMLColumns(PGLOBAL g, char *db, char *tab, PTOS topt, bool info) more: if (vp->atp) { - size_t z = sizeof(colname) - 1; - strncpy(colname, vp->atp->GetName(g), z); - colname[z] = 0; - strncat(xcol->Name, colname, XLEN(xcol->Name)); + size_t z = sizeof(colname) - 1; + size_t xlen= strlen(xcol->Name); + strmake(colname, vp->atp->GetName(g), z); + strmake(xcol->Name + xlen, colname, + sizeof(xcol->Name) - 1 - xlen); switch (vp->atp->GetText(g, buf, sizeof(buf))) { case RC_INFO: @@ -272,11 +272,13 @@ PQRYRES XMLColumns(PGLOBAL g, char *db, char *tab, PTOS topt, bool info) strncat(fmt, colname, XLEN(fmt)); } else { + size_t xlen; if (tdp->Usedom && node->GetType() != 1) continue; - strncpy(colname, node->GetName(g), sizeof(colname)); - strncat(xcol->Name, colname, XLEN(xcol->Name)); + xlen= strlen(xcol->Name); + strmake(colname, node->GetName(g), sizeof(colname)-1); + strmake(xcol->Name + xlen, colname, sizeof(xcol->Name) - 1 - xlen); if (j) strncat(fmt, colname, XLEN(fmt)); diff --git a/storage/innobase/handler/i_s.cc b/storage/innobase/handler/i_s.cc index 2007e5a1035..b68aff98780 100644 --- a/storage/innobase/handler/i_s.cc +++ b/storage/innobase/handler/i_s.cc @@ -5127,7 +5127,7 @@ i_s_sys_tables_fill_table_stats( while (rec) { const char* err_msg; - dict_table_t* table_rec; + dict_table_t* table_rec= 0; mtr.commit(); /* Fetch the dict_table_t structure corresponding to diff --git a/storage/mroonga/vendor/groonga/lib/ts/ts_expr_parser.c b/storage/mroonga/vendor/groonga/lib/ts/ts_expr_parser.c index 10e6d2fcca7..7786c04659d 100644 --- a/storage/mroonga/vendor/groonga/lib/ts/ts_expr_parser.c +++ b/storage/mroonga/vendor/groonga/lib/ts/ts_expr_parser.c @@ -360,7 +360,7 @@ grn_ts_expr_parser_tokenize_start(grn_ctx *ctx, grn_ts_expr_parser *parser, grn_ts_str str, grn_ts_expr_token **token) { grn_ts_str token_str = { str.ptr, 0 }; - grn_ts_expr_start_token *new_token; + grn_ts_expr_start_token *new_token= 0; grn_rc rc = grn_ts_expr_start_token_open(ctx, token_str, &new_token); if (rc != GRN_SUCCESS) { return rc; @@ -375,7 +375,7 @@ grn_ts_expr_parser_tokenize_end(grn_ctx *ctx, grn_ts_expr_parser *parser, grn_ts_str str, grn_ts_expr_token **token) { grn_ts_str token_str = { str.ptr, 0 }; - grn_ts_expr_end_token *new_token; + grn_ts_expr_end_token *new_token= 0; grn_rc rc = grn_ts_expr_end_token_open(ctx, token_str, &new_token); if (rc != GRN_SUCCESS) { return rc; @@ -393,7 +393,7 @@ grn_ts_expr_parser_tokenize_number(grn_ctx *ctx, grn_ts_expr_parser *parser, grn_rc rc; grn_ts_int int_value; grn_ts_str token_str; - grn_ts_expr_const_token *new_token; + grn_ts_expr_const_token *new_token= 0; int_value = strtol(str.ptr, &end, 0); if ((end != str.ptr) && (*end != '.') && (*end != 'e')) { @@ -442,7 +442,7 @@ grn_ts_expr_parser_tokenize_text(grn_ctx *ctx, grn_ts_expr_parser *parser, size_t i, n_escapes = 0; grn_rc rc; grn_ts_str token_str; - grn_ts_expr_const_token *new_token; + grn_ts_expr_const_token *new_token= 0; for (i = 1; i < str.size; i++) { if (str.ptr[i] == '\\') { i++; @@ -504,7 +504,7 @@ grn_ts_expr_parser_tokenize_name(grn_ctx *ctx, grn_ts_expr_parser *parser, token_str.size = i; if (grn_ts_str_is_bool(token_str)) { - grn_ts_expr_const_token *new_token; + grn_ts_expr_const_token *new_token= 0; grn_rc rc = grn_ts_expr_const_token_open(ctx, token_str, &new_token); if (rc != GRN_SUCCESS) { return rc; @@ -527,7 +527,7 @@ grn_ts_expr_parser_tokenize_bridge(grn_ctx *ctx, grn_ts_expr_parser *parser, grn_ts_str str, grn_ts_expr_token **token) { grn_ts_str token_str = { str.ptr, 1 }; - grn_ts_expr_bridge_token *new_token; + grn_ts_expr_bridge_token *new_token= 0; grn_rc rc = grn_ts_expr_bridge_token_open(ctx, token_str, &new_token); if (rc != GRN_SUCCESS) { return rc; @@ -543,7 +543,7 @@ grn_ts_expr_parser_tokenize_bracket(grn_ctx *ctx, grn_ts_expr_parser *parser, grn_ts_expr_token **token) { grn_ts_str token_str = { str.ptr, 1 }; - grn_ts_expr_bracket_token *new_token; + grn_ts_expr_bracket_token *new_token= 0; grn_rc rc = grn_ts_expr_bracket_token_open(ctx, token_str, &new_token); if (rc != GRN_SUCCESS) { return rc; @@ -567,7 +567,7 @@ grn_ts_expr_parser_tokenize_sign(grn_ctx *ctx, grn_ts_expr_parser *parser, grn_ts_op_type op_type; grn_ts_str token_str = { str.ptr, 1 }; grn_ts_expr_token *prev_token = parser->tokens[parser->n_tokens - 1]; - grn_ts_expr_op_token *new_token; + grn_ts_expr_op_token *new_token= 0; switch (prev_token->type) { case GRN_TS_EXPR_START_TOKEN: case GRN_TS_EXPR_OP_TOKEN: { @@ -626,7 +626,7 @@ grn_ts_expr_parser_tokenize_op(grn_ctx *ctx, grn_ts_expr_parser *parser, grn_rc rc = GRN_SUCCESS; grn_ts_str token_str = str; grn_ts_op_type op_type; - grn_ts_expr_op_token *new_token; + grn_ts_expr_op_token *new_token= 0; switch (str.ptr[0]) { case '+': case '-': { return grn_ts_expr_parser_tokenize_sign(ctx, parser, str, token); diff --git a/storage/mroonga/vendor/groonga/vendor/plugins/groonga-normalizer-mysql/normalizers/mysql.c b/storage/mroonga/vendor/groonga/vendor/plugins/groonga-normalizer-mysql/normalizers/mysql.c index 989d6267940..6096fc22cbc 100644 --- a/storage/mroonga/vendor/groonga/vendor/plugins/groonga-normalizer-mysql/normalizers/mysql.c +++ b/storage/mroonga/vendor/groonga/vendor/plugins/groonga-normalizer-mysql/normalizers/mysql.c @@ -439,7 +439,7 @@ normalize(grn_ctx *ctx, grn_obj *string, normalized[normalized_length_in_bytes] = '\0'; if (rest_length > 0) { - char buffer[SNIPPET_BUFFER_SIZE]; + char buffer[SNIPPET_BUFFER_SIZE+1]; GRN_PLUGIN_LOG(ctx, GRN_LOG_DEBUG, "[normalizer][%s] failed to normalize at %u byte: %s", normalizer_type_label, From 278ab53849264c83d93f586936cfdf9b70f760ca Mon Sep 17 00:00:00 2001 From: Monty Date: Mon, 14 Jun 2021 21:33:42 +0300 Subject: [PATCH 080/251] Updated libmarias3 to latest version --- storage/maria/libmarias3 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/maria/libmarias3 b/storage/maria/libmarias3 index 0d48bf334fd..324efa38ac7 160000 --- a/storage/maria/libmarias3 +++ b/storage/maria/libmarias3 @@ -1 +1 @@ -Subproject commit 0d48bf334fde7d4e0dac22bda560e86037d35d77 +Subproject commit 324efa38ac75cdfd80b65ff1317fed60c8ad36d5 From 2e33f574b37c7544d5b4d1c0e079cf65e29a1346 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Mon, 14 Jun 2021 23:45:31 +0200 Subject: [PATCH 081/251] update libmariadb --- libmariadb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmariadb b/libmariadb index 180c543704d..802ce584a26 160000 --- a/libmariadb +++ b/libmariadb @@ -1 +1 @@ -Subproject commit 180c543704d627a50a52aaf60e24ca14e0ec4686 +Subproject commit 802ce584a26fdc0ba67fcf35e277bf3c7440956a From e41522d6bf15694372f70c40619e44359a6a52f2 Mon Sep 17 00:00:00 2001 From: Monty Date: Tue, 15 Jun 2021 01:34:14 +0300 Subject: [PATCH 082/251] Updated libmarias3 --- storage/maria/libmarias3 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/maria/libmarias3 b/storage/maria/libmarias3 index 324efa38ac7..c71898f8259 160000 --- a/storage/maria/libmarias3 +++ b/storage/maria/libmarias3 @@ -1 +1 @@ -Subproject commit 324efa38ac75cdfd80b65ff1317fed60c8ad36d5 +Subproject commit c71898f8259829bf4b2e01072000491281e5206d From ec4df51414d34aff18c8473386b85c9ea53c44e0 Mon Sep 17 00:00:00 2001 From: Jordy Zomer Date: Tue, 15 Jun 2021 12:34:23 +1000 Subject: [PATCH 083/251] eventscheduler mismatch of my_{malloc,free}, delete Fix malloc/delete mismatch. This causes a double free in the cleanup. closes #1845 --- sql/event_scheduler.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/event_scheduler.cc b/sql/event_scheduler.cc index 2a5399fb94a..423f7e6ea2b 100644 --- a/sql/event_scheduler.cc +++ b/sql/event_scheduler.cc @@ -436,7 +436,7 @@ Event_scheduler::start(int *err_no) scheduler_thd= NULL; deinit_event_thread(new_thd); - delete scheduler_param_value; + my_free(scheduler_param_value); ret= true; } From be243ed9e3e33e3678300c20ab4e5f75c37a8f98 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Tue, 15 Jun 2021 12:40:33 +1000 Subject: [PATCH 084/251] cmake OpenBSD copyright notice correction Brad Smith made this OpenBSD file based of the FreeBSD cmake directives in commit ab589043670145c95ff372021bab19464b6036e2 by the Monty Program Ab. As such the Oracle Copyright header isn't really applicable. --- cmake/os/OpenBSD.cmake | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cmake/os/OpenBSD.cmake b/cmake/os/OpenBSD.cmake index a96cc891f38..c8b91944275 100644 --- a/cmake/os/OpenBSD.cmake +++ b/cmake/os/OpenBSD.cmake @@ -1,5 +1,4 @@ - -# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (C) 2012 Monty Program Ab, 2021 Brad Smith # # 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 From 7d2c338c48a9235c5c5e76293760cabc2ff48723 Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Mon, 14 Jun 2021 19:37:06 +0530 Subject: [PATCH 085/251] MDEV-14180 preparation: Rename key_rotation_list - Rename the rotation list to default_encrypt_tables in fil_system_t. Because rotation list naming could be misleading when it comes to key version rotation - Rename is_in_rotation_list to is_in_default_encrypt in fil_space_t - Rename keyrotate_next function to default_encrypt_next fil_system_t::default_encrypt_next(): Find the next suitable default encrypt table if beginning of default_encrypt_tables list has been scheduled to be deleted --- storage/innobase/fil/fil0crypt.cc | 55 ++++++++++++++++++------------ storage/innobase/fil/fil0fil.cc | 11 +++--- storage/innobase/include/fil0fil.h | 14 ++++---- 3 files changed, 46 insertions(+), 34 deletions(-) diff --git a/storage/innobase/fil/fil0crypt.cc b/storage/innobase/fil/fil0crypt.cc index 68a8a9be261..b167a589695 100644 --- a/storage/innobase/fil/fil0crypt.cc +++ b/storage/innobase/fil/fil0crypt.cc @@ -1380,52 +1380,65 @@ fil_crypt_return_iops( fil_crypt_update_total_stat(state); } -/** Return the next tablespace from rotation_list. +/** Return the next tablespace from default_encrypt_tables. @param space previous tablespace (NULL to start from the start) @param recheck whether the removal condition needs to be rechecked after the encryption parameters were changed @param encrypt expected state of innodb_encrypt_tables @return the next tablespace to process (n_pending_ops incremented) @retval NULL if this was the last */ -inline fil_space_t *fil_system_t::keyrotate_next(fil_space_t *space, - bool recheck, bool encrypt) +inline fil_space_t *fil_system_t::default_encrypt_next( + fil_space_t *space, bool recheck, bool encrypt) { ut_ad(mutex_own(&mutex)); sized_ilist::iterator it= - space && space->is_in_rotation_list ? space : rotation_list.begin(); + space && space->is_in_default_encrypt + ? space + : default_encrypt_tables.begin(); const sized_ilist::iterator end= - rotation_list.end(); + default_encrypt_tables.end(); if (space) { const bool released= !--space->n_pending_ops; - if (space->is_in_rotation_list) + if (space->is_in_default_encrypt) { while (++it != end && (!UT_LIST_GET_LEN(it->chain) || it->is_stopping())); - /* If one of the encryption threads already started the encryption - of the table then don't remove the unencrypted spaces from rotation list + /* If one of the encryption threads already started + the encryption of the table then don't remove the + unencrypted spaces from default encrypt list. - If there is a change in innodb_encrypt_tables variables value then - don't remove the last processed tablespace from the rotation list. */ + If there is a change in innodb_encrypt_tables variables + value then don't remove the last processed tablespace + from the default encrypt list. */ if (released && (!recheck || space->crypt_data) && !encrypt == !srv_encrypt_tables) { - ut_a(!rotation_list.empty()); - rotation_list.remove(*space); - space->is_in_rotation_list= false; + ut_a(!default_encrypt_tables.empty()); + default_encrypt_tables.remove(*space); + space->is_in_default_encrypt= false; } } } + else while (it != end && + (!UT_LIST_GET_LEN(it->chain) || it->is_stopping())) + { + /* Find the next suitable default encrypt table if + beginning of default_encrypt_tables list has been scheduled + to be deleted */ + it++; + } if (it == end) return NULL; space= &*it; space->n_pending_ops++; + ut_ad(!space->is_stopping()); return space; } @@ -1443,7 +1456,7 @@ static fil_space_t *fil_space_next(fil_space_t *space, bool recheck, ut_ad(!space || space->n_pending_ops); if (!srv_fil_crypt_rotate_key_age) - space= fil_system->keyrotate_next(space, recheck, encrypt); + space= fil_system->default_encrypt_next(space, recheck, encrypt); else if (!space) { space= UT_LIST_GET_FIRST(fil_system->space_list); @@ -2335,9 +2348,9 @@ fil_crypt_set_thread_cnt( } } -/** Initialize the tablespace rotation_list +/** Initialize the tablespace default_encrypt_tables if innodb_encryption_rotate_key_age=0. */ -static void fil_crypt_rotation_list_fill() +static void fil_crypt_default_encrypt_tables_fill() { ut_ad(mutex_own(&fil_system->mutex)); @@ -2345,7 +2358,7 @@ static void fil_crypt_rotation_list_fill() space != NULL; space = UT_LIST_GET_NEXT(space_list, space)) { if (space->purpose != FIL_TYPE_TABLESPACE - || space->is_in_rotation_list + || space->is_in_default_encrypt || space->is_stopping() || UT_LIST_GET_LEN(space->chain) == 0) { continue; @@ -2389,8 +2402,8 @@ static void fil_crypt_rotation_list_fill() } } - fil_system->rotation_list.push_back(*space); - space->is_in_rotation_list = true; + fil_system->default_encrypt_tables.push_back(*space); + space->is_in_default_encrypt = true; } } @@ -2405,7 +2418,7 @@ fil_crypt_set_rotate_key_age( mutex_enter(&fil_system->mutex); srv_fil_crypt_rotate_key_age = val; if (val == 0) { - fil_crypt_rotation_list_fill(); + fil_crypt_default_encrypt_tables_fill(); } mutex_exit(&fil_system->mutex); os_event_set(fil_crypt_threads_event); @@ -2436,7 +2449,7 @@ fil_crypt_set_encrypt_tables( srv_encrypt_tables = val; if (srv_fil_crypt_rotate_key_age == 0) { - fil_crypt_rotation_list_fill(); + fil_crypt_default_encrypt_tables_fill(); } mutex_exit(&fil_system->mutex); diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index 2607856bc74..3dc804ea878 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -1244,10 +1244,9 @@ fil_space_detach( space->is_in_unflushed_spaces = false; } - if (space->is_in_rotation_list) { - - fil_system->rotation_list.remove(*space); - space->is_in_rotation_list = false; + if (space->is_in_default_encrypt) { + fil_system->default_encrypt_tables.remove(*space); + space->is_in_default_encrypt = false; } UT_LIST_REMOVE(fil_system->space_list, space); @@ -1473,8 +1472,8 @@ fil_space_create( srv_encrypt_tables)) { /* Key rotation is not enabled, need to inform background encryption threads. */ - fil_system->rotation_list.push_back(*space); - space->is_in_rotation_list = true; + fil_system->default_encrypt_tables.push_back(*space); + space->is_in_default_encrypt = true; mutex_exit(&fil_system->mutex); mutex_enter(&fil_crypt_threads_mutex); os_event_set(fil_crypt_threads_event); diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h index 65457b414ca..7ce89f3be60 100644 --- a/storage/innobase/include/fil0fil.h +++ b/storage/innobase/include/fil0fil.h @@ -177,7 +177,7 @@ struct fil_space_t : ilist_node, bool is_in_unflushed_spaces; /** Checks that this tablespace needs key rotation. */ - bool is_in_rotation_list; + bool is_in_default_encrypt; /** True if the device this filespace is on supports atomic writes */ bool atomic_write_supported; @@ -541,9 +541,9 @@ struct fil_system_t { record has been written since the latest redo log checkpoint. Protected only by log_sys->mutex. */ - ilist rotation_list; - /*!< list of all file spaces needing - key rotation.*/ + + /** List of all file spaces need key rotation */ + ilist default_encrypt_tables; bool space_id_reuse_warned; /* !< TRUE if fil_space_create() @@ -556,15 +556,15 @@ struct fil_system_t { @retval NULL if the tablespace does not exist or cannot be read */ fil_space_t* read_page0(ulint id); - /** Return the next tablespace from rotation_list. + /** Return the next tablespace from default_encrypt_tables list. @param space previous tablespace (NULL to start from the start) @param recheck whether the removal condition needs to be rechecked after the encryption parameters were changed @param encrypt expected state of innodb_encrypt_tables @return the next tablespace to process (n_pending_ops incremented) @retval NULL if this was the last */ - inline fil_space_t* keyrotate_next(fil_space_t *space, bool recheck, - bool encrypt); + inline fil_space_t* default_encrypt_next( + fil_space_t *space, bool recheck, bool encrypt); }; /** The tablespace memory cache. This variable is NULL before the module is From 8c7d8b716c976d28b3373510543fa88f6d12a643 Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Tue, 15 Jun 2021 13:12:15 +0530 Subject: [PATCH 086/251] MDEV-14180 Automatically disable key rotation checks for file_key_managment plugin Problem: ======= - InnoDB iterates the fil_system space list to encrypt the tablespace in case of key rotation. But it is not necessary for any encryption plugin which doesn't do key version rotation. Solution: ========= - Introduce a new variable called srv_encrypt_rotate to indicate whether encryption plugin does key rotation fil_space_crypt_t::key_get_latest_version(): Enable the srv_encrypt_rotate only once if current key version is higher than innodb_encyrption_rotate_key_age fil_crypt_must_default_encrypt(): Default encryption tables should be added to default_encryp_tables list if innodb_encyrption_rotate_key_age is zero and encryption plugin doesn't do key version rotation fil_space_create(): Add the newly created space to default_encrypt_tables list if fil_crypt_must_default_encrypt() returns true Removed the nondeterministic select from innodb-key-rotation-disable test. By default, InnoDB adds the tablespace to the rotation list and background crypt thread does encryption of tablespace. So these select doesn't give reliable results. --- .../r/innodb-key-rotation-disable.result | 4 -- .../encryption/r/key_version_rotation.result | 19 +++++++++ .../t/innodb-key-rotation-disable.test | 3 -- .../encryption/t/key_version_rotation.opt | 2 + .../encryption/t/key_version_rotation.test | 41 +++++++++++++++++++ storage/innobase/fil/fil0crypt.cc | 20 ++++++++- storage/innobase/fil/fil0fil.cc | 18 +++++--- storage/innobase/include/fil0crypt.h | 6 +++ 8 files changed, 98 insertions(+), 15 deletions(-) create mode 100644 mysql-test/suite/encryption/r/key_version_rotation.result create mode 100644 mysql-test/suite/encryption/t/key_version_rotation.opt create mode 100644 mysql-test/suite/encryption/t/key_version_rotation.test diff --git a/mysql-test/suite/encryption/r/innodb-key-rotation-disable.result b/mysql-test/suite/encryption/r/innodb-key-rotation-disable.result index a662f5e6343..7d0267d5057 100644 --- a/mysql-test/suite/encryption/r/innodb-key-rotation-disable.result +++ b/mysql-test/suite/encryption/r/innodb-key-rotation-disable.result @@ -1,7 +1,3 @@ -SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; -NAME -SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; -NAME create database enctests; use enctests; create table t1(a int not null primary key, b char(200)) engine=innodb; diff --git a/mysql-test/suite/encryption/r/key_version_rotation.result b/mysql-test/suite/encryption/r/key_version_rotation.result new file mode 100644 index 00000000000..1a295abfe8d --- /dev/null +++ b/mysql-test/suite/encryption/r/key_version_rotation.result @@ -0,0 +1,19 @@ +create table t1(f1 int not null)engine=innodb; +create table t2(f1 int not null)engine=innodb; +insert into t1 select * from seq_1_to_100; +insert into t2 select * from seq_1_to_100; +# Enable encryption +set global innodb_encrypt_tables=ON; +# Create a new table and it is added to rotation list +create table t3(f1 int not null)engine=innodb; +insert into t3 select * from seq_1_to_100; +# Increase the version and it should set rotation +# variable for the encryption plugin +set global debug_key_management_version=10; +select @@debug_key_management_version; +@@debug_key_management_version +10 +# Decrease the key version and Disable the encryption +set global debug_key_management_version=1; +set global innodb_encrypt_tables=off; +DROP TABLE t1, t2, t3; diff --git a/mysql-test/suite/encryption/t/innodb-key-rotation-disable.test b/mysql-test/suite/encryption/t/innodb-key-rotation-disable.test index 2e5d877f7c0..4541bfa2a0c 100644 --- a/mysql-test/suite/encryption/t/innodb-key-rotation-disable.test +++ b/mysql-test/suite/encryption/t/innodb-key-rotation-disable.test @@ -3,9 +3,6 @@ # not embedded because of restarts -- source include/not_embedded.inc -SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; -SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; - --disable_query_log --disable_warnings let $encryption = `SELECT @@innodb_encrypt_tables`; diff --git a/mysql-test/suite/encryption/t/key_version_rotation.opt b/mysql-test/suite/encryption/t/key_version_rotation.opt new file mode 100644 index 00000000000..d7933f0f943 --- /dev/null +++ b/mysql-test/suite/encryption/t/key_version_rotation.opt @@ -0,0 +1,2 @@ +--innodb-tablespaces-encryption +--plugin-load-add=$DEBUG_KEY_MANAGEMENT_SO diff --git a/mysql-test/suite/encryption/t/key_version_rotation.test b/mysql-test/suite/encryption/t/key_version_rotation.test new file mode 100644 index 00000000000..d36d47251a1 --- /dev/null +++ b/mysql-test/suite/encryption/t/key_version_rotation.test @@ -0,0 +1,41 @@ +--source include/have_innodb.inc +--source include/have_debug.inc +--source include/have_sequence.inc + +create table t1(f1 int not null)engine=innodb; +create table t2(f1 int not null)engine=innodb; +insert into t1 select * from seq_1_to_100; +insert into t2 select * from seq_1_to_100; + +let $restart_parameters=--innodb_encrypt_tables=0 --innodb_encryption_threads=1 --innodb_encryption_rotate_key_age=9; +--source include/restart_mysqld.inc + +--echo # Enable encryption + +set global innodb_encrypt_tables=ON; +--let $tables_count= `select count(*) from information_schema.tables where engine = 'InnoDB'` +--let $wait_timeout= 600 +--let $wait_condition=SELECT COUNT(*) >= $tables_count FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; +--source include/wait_condition.inc +--echo # Create a new table and it is added to rotation list +create table t3(f1 int not null)engine=innodb; +insert into t3 select * from seq_1_to_100; + +--echo # Increase the version and it should set rotation +--echo # variable for the encryption plugin + +set global debug_key_management_version=10; +select @@debug_key_management_version; +--let $tables_count= `select count(*) from information_schema.tables where engine = 'InnoDB'` +--let $wait_timeout= 600 +--let $wait_condition=SELECT COUNT(*) >= $tables_count FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; +--source include/wait_condition.inc + +--echo # Decrease the key version and Disable the encryption +set global debug_key_management_version=1; +set global innodb_encrypt_tables=off; + +--let $wait_timeout= 600 +--let $wait_condition=SELECT COUNT(*) >= $tables_count FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0; +--source include/wait_condition.inc +DROP TABLE t1, t2, t3; diff --git a/storage/innobase/fil/fil0crypt.cc b/storage/innobase/fil/fil0crypt.cc index b167a589695..8195716f722 100644 --- a/storage/innobase/fil/fil0crypt.cc +++ b/storage/innobase/fil/fil0crypt.cc @@ -55,6 +55,9 @@ UNIV_INTERN uint srv_n_fil_crypt_threads_started = 0; /** At this age or older a space/page will be rotated */ UNIV_INTERN uint srv_fil_crypt_rotate_key_age; +/** Whether the encryption plugin does key rotation */ +static bool srv_encrypt_rotate; + /** Event to signal FROM the key rotation threads. */ static os_event_t fil_crypt_event; @@ -136,6 +139,14 @@ fil_space_crypt_t::key_get_latest_version(void) if (is_key_found()) { key_version = encryption_key_get_latest_version(key_id); + /* InnoDB does dirty read of srv_fil_crypt_rotate_key_age. + It doesn't matter because srv_encrypt_rotate + can be set to true only once */ + if (!srv_encrypt_rotate + && key_version > srv_fil_crypt_rotate_key_age) { + srv_encrypt_rotate = true; + } + srv_stats.n_key_requests.inc(); key_found = key_version; } @@ -1380,6 +1391,11 @@ fil_crypt_return_iops( fil_crypt_update_total_stat(state); } +bool fil_crypt_must_default_encrypt() +{ + return !srv_fil_crypt_rotate_key_age || !srv_encrypt_rotate; +} + /** Return the next tablespace from default_encrypt_tables. @param space previous tablespace (NULL to start from the start) @param recheck whether the removal condition needs to be rechecked after @@ -1455,7 +1471,7 @@ static fil_space_t *fil_space_next(fil_space_t *space, bool recheck, mutex_enter(&fil_system->mutex); ut_ad(!space || space->n_pending_ops); - if (!srv_fil_crypt_rotate_key_age) + if (fil_crypt_must_default_encrypt()) space= fil_system->default_encrypt_next(space, recheck, encrypt); else if (!space) { @@ -2448,7 +2464,7 @@ fil_crypt_set_encrypt_tables( srv_encrypt_tables = val; - if (srv_fil_crypt_rotate_key_age == 0) { + if (fil_crypt_must_default_encrypt()) { fil_crypt_default_encrypt_tables_fill(); } diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index 3dc804ea878..a727215b433 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -1464,22 +1464,28 @@ fil_space_create( fil_system->max_assigned_id = id; } + const bool rotate = + (purpose == FIL_TYPE_TABLESPACE + && (mode == FIL_ENCRYPTION_ON + || mode == FIL_ENCRYPTION_OFF || srv_encrypt_tables) + && fil_crypt_must_default_encrypt()); + /* Inform key rotation that there could be something to do */ - if (purpose == FIL_TYPE_TABLESPACE - && !srv_fil_crypt_rotate_key_age && fil_crypt_threads_event && - (mode == FIL_ENCRYPTION_ON || mode == FIL_ENCRYPTION_OFF || - srv_encrypt_tables)) { + if (rotate) { /* Key rotation is not enabled, need to inform background encryption threads. */ fil_system->default_encrypt_tables.push_back(*space); space->is_in_default_encrypt = true; mutex_exit(&fil_system->mutex); + } else { + mutex_exit(&fil_system->mutex); + } + + if (rotate && srv_n_fil_crypt_threads_started) { mutex_enter(&fil_crypt_threads_mutex); os_event_set(fil_crypt_threads_event); mutex_exit(&fil_crypt_threads_mutex); - } else { - mutex_exit(&fil_system->mutex); } return(space); diff --git a/storage/innobase/include/fil0crypt.h b/storage/innobase/include/fil0crypt.h index 3c56315ee9a..af6c930659b 100644 --- a/storage/innobase/include/fil0crypt.h +++ b/storage/innobase/include/fil0crypt.h @@ -499,4 +499,10 @@ bool fil_space_verify_crypt_checksum(const byte* page, const page_size_t& page_size) MY_ATTRIBUTE((warn_unused_result)); +/** Add the tablespace to the rotation list if +innodb_encrypt_rotate_key_age is 0 or encryption plugin does +not do key version rotation +@return whether the tablespace should be added to rotation list */ +bool fil_crypt_must_default_encrypt(); + #endif /* fil0crypt_h */ From 7229107e3e2c59febd10b40b243011e8bba94f99 Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Tue, 15 Jun 2021 13:13:01 +0530 Subject: [PATCH 087/251] MDEV-25872 InnoDB: Assertion failure in row_merge_read_clustered_index upon ALTER on table with indexed virtual columns - InnoDB fails to check DB_COMPUTE_VALUE_FAILED error in row_merge_read_clustered_index() and wrongly asserts that the buffer shouldn't be ran out of memory. Alter table should give warning when the column value is being truncated. --- .../suite/gcol/r/gcol_keys_innodb.result | 2 ++ .../suite/gcol/r/innodb_virtual_index.result | 20 ++++++++++++++ .../suite/gcol/t/innodb_virtual_index.opt | 1 + .../suite/gcol/t/innodb_virtual_index.test | 21 +++++++++++++++ mysql-test/suite/innodb/r/innodb-alter.result | 8 ++++-- sql/sql_table.cc | 8 ++++++ storage/innobase/row/row0merge.cc | 27 +++++++++---------- 7 files changed, 71 insertions(+), 16 deletions(-) create mode 100644 mysql-test/suite/gcol/t/innodb_virtual_index.opt diff --git a/mysql-test/suite/gcol/r/gcol_keys_innodb.result b/mysql-test/suite/gcol/r/gcol_keys_innodb.result index 5a29c64bc20..37b350c0c32 100644 --- a/mysql-test/suite/gcol/r/gcol_keys_innodb.result +++ b/mysql-test/suite/gcol/r/gcol_keys_innodb.result @@ -691,6 +691,8 @@ a b c 1 127 0 SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR ALTER TABLE t ADD UNIQUE INDEX (c(1)); +Warnings: +Warning 1264 Out of range value for column 'b' at row 1 SELECT * FROM t WHERE c = '0'; a b c 1 127 0 diff --git a/mysql-test/suite/gcol/r/innodb_virtual_index.result b/mysql-test/suite/gcol/r/innodb_virtual_index.result index 20311a21136..ff339280e8a 100644 --- a/mysql-test/suite/gcol/r/innodb_virtual_index.result +++ b/mysql-test/suite/gcol/r/innodb_virtual_index.result @@ -266,3 +266,23 @@ CHECK TABLE t1; Table Op Msg_type Msg_text test.t1 check status OK DROP TABLE t1; +# +# MDEV-25872 InnoDB: Assertion failure in row_merge_read_clustered_index +# upon ALTER on table with indexed virtual columns +# +CREATE TABLE t1 ( +id BIGINT AUTO_INCREMENT PRIMARY KEY, +a INT, +va INT ZEROFILL AS (a) VIRTUAL, +b TIMESTAMP, +c CHAR(204), +vc CHAR(8), +KEY(vc,c(64),b,va) +) ENGINE=InnoDB CHARACTER SET utf32; +INSERT INTO t1 (id) SELECT NULL FROM seq_1_to_75; +INSERT IGNORE INTO t1 (id, a) VALUES (NULL, -1); +Warnings: +Warning 1264 Out of range value for column 'va' at row 1 +ALTER TABLE t1 FORCE; +ERROR 22003: Out of range value for column 'va' at row 1 +DROP TABLE t1; diff --git a/mysql-test/suite/gcol/t/innodb_virtual_index.opt b/mysql-test/suite/gcol/t/innodb_virtual_index.opt new file mode 100644 index 00000000000..c3f4a891cca --- /dev/null +++ b/mysql-test/suite/gcol/t/innodb_virtual_index.opt @@ -0,0 +1 @@ +--innodb_sort_buffer_size=64k diff --git a/mysql-test/suite/gcol/t/innodb_virtual_index.test b/mysql-test/suite/gcol/t/innodb_virtual_index.test index 353841840dc..9e765ca104c 100644 --- a/mysql-test/suite/gcol/t/innodb_virtual_index.test +++ b/mysql-test/suite/gcol/t/innodb_virtual_index.test @@ -1,4 +1,5 @@ --source include/have_innodb.inc +--source include/have_sequence.inc # Ensure that the history list length will actually be decremented by purge. SET @saved_frequency = @@GLOBAL.innodb_purge_rseg_truncate_frequency; @@ -281,3 +282,23 @@ ROLLBACK; SELECT * FROM t1; CHECK TABLE t1; DROP TABLE t1; + +--echo # +--echo # MDEV-25872 InnoDB: Assertion failure in row_merge_read_clustered_index +--echo # upon ALTER on table with indexed virtual columns +--echo # + +CREATE TABLE t1 ( + id BIGINT AUTO_INCREMENT PRIMARY KEY, + a INT, + va INT ZEROFILL AS (a) VIRTUAL, + b TIMESTAMP, + c CHAR(204), + vc CHAR(8), + KEY(vc,c(64),b,va) +) ENGINE=InnoDB CHARACTER SET utf32; +INSERT INTO t1 (id) SELECT NULL FROM seq_1_to_75; +INSERT IGNORE INTO t1 (id, a) VALUES (NULL, -1); +--error ER_WARN_DATA_OUT_OF_RANGE +ALTER TABLE t1 FORCE; +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/r/innodb-alter.result b/mysql-test/suite/innodb/r/innodb-alter.result index 80cf14c1725..53e6c95af0f 100644 --- a/mysql-test/suite/innodb/r/innodb-alter.result +++ b/mysql-test/suite/innodb/r/innodb-alter.result @@ -1041,7 +1041,9 @@ CREATE TABLE t1 (a INT NOT NULL DEFAULT 0) ENGINE=InnoDB; iNSERT INTO t1 VALUES (10); ALTER TABLE t1 ADD b DATE NOT NULL DEFAULT if(unix_timestamp()>1,TIMESTAMP'2001-01-01 10:20:30',0); affected rows: 0 -info: Records: 0 Duplicates: 0 Warnings: 0 +info: Records: 0 Duplicates: 0 Warnings: 1 +Warnings: +Note 1265 Data truncated for column 'b' at row 1 SELECT * FROM t1; a b 10 2001-01-01 @@ -1050,7 +1052,9 @@ CREATE TABLE t1 (a INT NOT NULL DEFAULT 0) ENGINE=InnoDB; iNSERT INTO t1 VALUES (10); ALTER TABLE t1 ADD b TIME NOT NULL DEFAULT if(unix_timestamp()>1,TIMESTAMP'2001-01-01 10:20:30',0); affected rows: 0 -info: Records: 0 Duplicates: 0 Warnings: 0 +info: Records: 0 Duplicates: 0 Warnings: 1 +Warnings: +Note 1265 Data truncated for column 'b' at row 1 SELECT * FROM t1; a b 10 10:20:30 diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 3a3a903bc35..9556cb9f136 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -9680,9 +9680,17 @@ do_continue:; if (use_inplace) { table->s->frm_image= &frm; + enum_check_fields save_count_cuted_fields= thd->count_cuted_fields; + /* + Set the truncated column values of thd as warning for alter table. + */ + thd->count_cuted_fields= CHECK_FIELD_WARN; int res= mysql_inplace_alter_table(thd, table_list, table, altered_table, &ha_alter_info, inplace_supported, &target_mdl_request, &alter_ctx); + + thd->count_cuted_fields= save_count_cuted_fields; + my_free(const_cast(frm.str)); if (res) diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc index e3b3f2c2762..93ea4d2d743 100644 --- a/storage/innobase/row/row0merge.cc +++ b/storage/innobase/row/row0merge.cc @@ -524,7 +524,9 @@ row_merge_buf_add( DBUG_ENTER("row_merge_buf_add"); if (buf->n_tuples >= buf->max_tuples) { - DBUG_RETURN(0); +error: + n_row_added = 0; + goto end; } DBUG_EXECUTE_IF( @@ -845,11 +847,6 @@ end: if (vcol_storage.innobase_record) innobase_free_row_for_vcol(&vcol_storage); DBUG_RETURN(n_row_added); - -error: - if (vcol_storage.innobase_record) - innobase_free_row_for_vcol(&vcol_storage); - DBUG_RETURN(0); } /*************************************************************//** @@ -2567,16 +2564,18 @@ write_buffers: new_table, psort_info, row, ext, &doc_id, conv_heap, &err, &v_heap, eval_table, trx)))) { - /* An empty buffer should have enough - room for at least one record. */ - ut_error; + /* An empty buffer should have enough + room for at least one record. */ + ut_ad(err == DB_COMPUTE_VALUE_FAILED + || err == DB_OUT_OF_MEMORY + || err == DB_TOO_BIG_RECORD); + } else if (err == DB_SUCCESS) { + file->n_rec += rows_added; + continue; } - if (err != DB_SUCCESS) { - break; - } - - file->n_rec += rows_added; + trx->error_key_num = i; + break; } } From 7d591cf85090db52478facca4a0c03a2a56aa585 Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Tue, 15 Jun 2021 13:14:39 +0530 Subject: [PATCH 088/251] MDEV-24713 Assertion `dict_table_is_comp(index->table)' failed in row_merge_buf_add() - During online alter conversion from compact to redundant, virtual column field length already set during innobase_get_computed_value(). Skip the char(n) check for virtual column in row_merge_buf_add() --- .../suite/gcol/r/innodb_virtual_index.result | 14 ++++++++++++++ mysql-test/suite/gcol/t/innodb_virtual_index.test | 12 ++++++++++++ storage/innobase/row/row0merge.cc | 5 ++++- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/gcol/r/innodb_virtual_index.result b/mysql-test/suite/gcol/r/innodb_virtual_index.result index ff339280e8a..b8dd161c30e 100644 --- a/mysql-test/suite/gcol/r/innodb_virtual_index.result +++ b/mysql-test/suite/gcol/r/innodb_virtual_index.result @@ -286,3 +286,17 @@ Warning 1264 Out of range value for column 'va' at row 1 ALTER TABLE t1 FORCE; ERROR 22003: Out of range value for column 'va' at row 1 DROP TABLE t1; +# +# MDEV-24713 Assertion `dict_table_is_comp(index->table)' failed +# in row_merge_buf_add() +# +CREATE TABLE t1 (id INT PRIMARY KEY, a CHAR(3), +b CHAR(8) AS (a) VIRTUAL, KEY(b)) +ROW_FORMAT=REDUNDANT ENGINE=InnoDB +CHARACTER SET utf8; +INSERT INTO t1 (id,a) VALUES (1,'foo'); +OPTIMIZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 optimize note Table does not support optimize, doing recreate + analyze instead +test.t1 optimize status OK +DROP TABLE t1; diff --git a/mysql-test/suite/gcol/t/innodb_virtual_index.test b/mysql-test/suite/gcol/t/innodb_virtual_index.test index 9e765ca104c..94c3b7f9204 100644 --- a/mysql-test/suite/gcol/t/innodb_virtual_index.test +++ b/mysql-test/suite/gcol/t/innodb_virtual_index.test @@ -302,3 +302,15 @@ INSERT IGNORE INTO t1 (id, a) VALUES (NULL, -1); --error ER_WARN_DATA_OUT_OF_RANGE ALTER TABLE t1 FORCE; DROP TABLE t1; + +--echo # +--echo # MDEV-24713 Assertion `dict_table_is_comp(index->table)' failed +--echo # in row_merge_buf_add() +--echo # +CREATE TABLE t1 (id INT PRIMARY KEY, a CHAR(3), + b CHAR(8) AS (a) VIRTUAL, KEY(b)) + ROW_FORMAT=REDUNDANT ENGINE=InnoDB + CHARACTER SET utf8; +INSERT INTO t1 (id,a) VALUES (1,'foo'); +OPTIMIZE TABLE t1; +DROP TABLE t1; diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc index 93ea4d2d743..9e6179585b1 100644 --- a/storage/innobase/row/row0merge.cc +++ b/storage/innobase/row/row0merge.cc @@ -691,7 +691,10 @@ error: continue; } - if (field->len != UNIV_SQL_NULL + /* innobase_get_computed_value() sets the + length of the virtual column field. */ + if (v_col == NULL + && field->len != UNIV_SQL_NULL && col->mtype == DATA_MYSQL && col->len != field->len) { if (conv_heap != NULL) { From 1c35a3f6fd92704d7a135a81c7752f5058aaede5 Mon Sep 17 00:00:00 2001 From: Eugene Kosov Date: Tue, 15 Jun 2021 13:09:15 +0300 Subject: [PATCH 089/251] fix clang build a new warning -Wunused-but-set-variable was introduced recently to clang --- mysys/mf_iocache.c | 3 +-- sql/item_func.cc | 2 -- sql/sql_select.cc | 10 +--------- storage/innobase/fil/fil0crypt.cc | 2 -- storage/innobase/fsp/fsp0fsp.cc | 2 -- storage/innobase/row/row0ftsort.cc | 2 -- storage/maria/ma_check.c | 8 ++++++-- storage/myisam/mi_check.c | 8 ++++++-- 8 files changed, 14 insertions(+), 23 deletions(-) diff --git a/mysys/mf_iocache.c b/mysys/mf_iocache.c index 8ade76e922e..0b19aaf9015 100644 --- a/mysys/mf_iocache.c +++ b/mysys/mf_iocache.c @@ -1384,7 +1384,7 @@ static void copy_to_read_buffer(IO_CACHE *write_cache, static int _my_b_seq_read(IO_CACHE *info, uchar *Buffer, size_t Count) { - size_t length, diff_length, left_length= 0, save_count, max_length; + size_t length, diff_length, save_count, max_length; my_off_t pos_in_file; save_count=Count; @@ -1435,7 +1435,6 @@ static int _my_b_seq_read(IO_CACHE *info, uchar *Buffer, size_t Count) */ goto read_append_buffer; } - left_length+=length; diff_length=0; } diff --git a/sql/item_func.cc b/sql/item_func.cc index 7b39b7710fb..6b8025c9d0f 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -2756,7 +2756,6 @@ bool Item_func_min_max::fix_length_and_dec() max_length=0; maybe_null=0; Item_result tmp_cmp_type= args[0]->cmp_type(); - uint string_type_count= 0; uint temporal_type_count= 0; enum_field_types temporal_field_type= MYSQL_TYPE_DATETIME; @@ -2769,7 +2768,6 @@ bool Item_func_min_max::fix_length_and_dec() if (args[i]->maybe_null) maybe_null= 1; tmp_cmp_type= item_cmp_type(tmp_cmp_type, args[i]->cmp_type()); - string_type_count+= args[i]->cmp_type() == STRING_RESULT; if (args[i]->cmp_type() == TIME_RESULT) { if (!temporal_type_count) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index ce706209017..fcdb671941d 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -3928,7 +3928,7 @@ make_join_statistics(JOIN *join, List &tables_list, int error= 0; TABLE *UNINIT_VAR(table); /* inited in all loops */ uint i,table_count,const_count,key; - table_map found_const_table_map, all_table_map, found_ref, refs; + table_map found_const_table_map, all_table_map; key_map const_ref, eq_part; bool has_expensive_keyparts; TABLE **table_vector; @@ -4191,7 +4191,6 @@ make_join_statistics(JOIN *join, List &tables_list, { ref_changed = 0; more_const_tables_found: - found_ref=0; /* We only have to loop from stat_vector + const_count as @@ -4280,7 +4279,6 @@ make_join_statistics(JOIN *join, List &tables_list, key=keyuse->key; s->keys.set_bit(key); // TODO: remove this ? - refs=0; const_ref.clear_all(); eq_part.clear_all(); has_expensive_keyparts= false; @@ -4296,8 +4294,6 @@ make_join_statistics(JOIN *join, List &tables_list, if (keyuse->val->is_expensive()) has_expensive_keyparts= true; } - else - refs|=keyuse->used_tables; eq_part.set_bit(keyuse->keypart); } keyuse++; @@ -4348,8 +4344,6 @@ make_join_statistics(JOIN *join, List &tables_list, found_const_table_map|= table->map; break; } - else - found_ref|= refs; // Table is const if all refs are const } else if (base_const_ref == base_eq_part) s->const_keys.set_bit(key); @@ -26190,7 +26184,6 @@ static bool get_range_limit_read_cost(const JOIN_TAB *tab, */ if (tab) { - key_part_map const_parts= 0; key_part_map map= 1; uint kp; /* Find how many key parts would be used by ref(const) */ @@ -26198,7 +26191,6 @@ static bool get_range_limit_read_cost(const JOIN_TAB *tab, { if (!(table->const_key_parts[keynr] & map)) break; - const_parts |= map; } if (kp > 0) diff --git a/storage/innobase/fil/fil0crypt.cc b/storage/innobase/fil/fil0crypt.cc index 8195716f722..94899ed0f65 100644 --- a/storage/innobase/fil/fil0crypt.cc +++ b/storage/innobase/fil/fil0crypt.cc @@ -1012,13 +1012,11 @@ static bool fil_crypt_start_encrypting_space(fil_space_t* space) /* 4 - sync tablespace before publishing crypt data */ bool success = false; - ulint sum_pages = 0; do { ulint n_pages = 0; success = buf_flush_lists(ULINT_MAX, end_lsn, &n_pages); buf_flush_wait_batch_end(NULL, BUF_FLUSH_LIST); - sum_pages += n_pages; } while (!success); /* 5 - publish crypt data */ diff --git a/storage/innobase/fsp/fsp0fsp.cc b/storage/innobase/fsp/fsp0fsp.cc index 58aa18ac323..cb5eff07f88 100644 --- a/storage/innobase/fsp/fsp0fsp.cc +++ b/storage/innobase/fsp/fsp0fsp.cc @@ -2719,7 +2719,6 @@ fsp_reserve_free_extents( ulint n_free; ulint n_free_up; ulint reserve; - size_t total_reserved = 0; ut_ad(mtr); *n_reserved = n_ext; @@ -2801,7 +2800,6 @@ try_again: } try_to_extend: if (ulint n = fsp_try_extend_data_file(space, space_header, mtr)) { - total_reserved += n; goto try_again; } diff --git a/storage/innobase/row/row0ftsort.cc b/storage/innobase/row/row0ftsort.cc index 2ca930e0934..29e126290cf 100644 --- a/storage/innobase/row/row0ftsort.cc +++ b/storage/innobase/row/row0ftsort.cc @@ -770,7 +770,6 @@ fts_parallel_tokenization( row_merge_block_t** crypt_block; int tmpfd[FTS_NUM_AUX_INDEX]; ulint mycount[FTS_NUM_AUX_INDEX]; - ib_uint64_t total_rec = 0; ulint num_doc_processed = 0; doc_id_t last_doc_id = 0; mem_heap_t* blob_heap = NULL; @@ -1038,7 +1037,6 @@ exit: goto func_exit; } - total_rec += merge_file[i]->n_rec; close(tmpfd[i]); } diff --git a/storage/maria/ma_check.c b/storage/maria/ma_check.c index 2795528a044..cb4585d0f62 100644 --- a/storage/maria/ma_check.c +++ b/storage/maria/ma_check.c @@ -4191,7 +4191,7 @@ int maria_repair_parallel(HA_CHECK *param, register MARIA_HA *info, const char * name, my_bool rep_quick) { int got_error; - uint i,key, total_key_length, istep; + uint i,key, istep; ha_rows start_records; my_off_t new_header_length,del; File new_file; @@ -4353,7 +4353,9 @@ int maria_repair_parallel(HA_CHECK *param, register MARIA_HA *info, _ma_check_print_error(param,"Not enough memory for key!"); goto err; } - total_key_length=0; +#ifdef USING_SECOND_APPROACH + uint total_key_length=0; +#endif rec_per_key_part= param->new_rec_per_key_part; share->state.state.records=share->state.state.del=share->state.split=0; share->state.state.empty=0; @@ -4422,7 +4424,9 @@ int maria_repair_parallel(HA_CHECK *param, register MARIA_HA *info, if (keyseg->flag & HA_NULL_PART) sort_param[i].key_length++; } +#ifdef USING_SECOND_APPROACH total_key_length+=sort_param[i].key_length; +#endif if (sort_param[i].keyinfo->flag & HA_FULLTEXT) { diff --git a/storage/myisam/mi_check.c b/storage/myisam/mi_check.c index d9b9bb5af4a..8bae409d1e6 100644 --- a/storage/myisam/mi_check.c +++ b/storage/myisam/mi_check.c @@ -2614,7 +2614,7 @@ int mi_repair_parallel(HA_CHECK *param, register MI_INFO *info, const char * name, int rep_quick) { int got_error; - uint i,key, total_key_length, istep; + uint i,key, istep; ulong rec_length; ha_rows start_records; my_off_t new_header_length,del; @@ -2800,7 +2800,9 @@ int mi_repair_parallel(HA_CHECK *param, register MI_INFO *info, mi_check_print_error(param,"Not enough memory for key!"); goto err; } - total_key_length=0; +#ifdef USING_SECOND_APPROACH + uint total_key_length=0; +#endif rec_per_key_part= param->rec_per_key_part; info->state->records=info->state->del=share->state.split=0; info->state->empty=0; @@ -2869,7 +2871,9 @@ int mi_repair_parallel(HA_CHECK *param, register MI_INFO *info, if (keyseg->flag & HA_NULL_PART) sort_param[i].key_length++; } +#ifdef USING_SECOND_APPROACH total_key_length+=sort_param[i].key_length; +#endif if (sort_param[i].keyinfo->flag & HA_FULLTEXT) { From 18d5be5b54b1a05e6107a1c5828d9eed9cf18636 Mon Sep 17 00:00:00 2001 From: Julius Goryavsky Date: Wed, 9 Jun 2021 03:41:37 +0200 Subject: [PATCH 090/251] MDEV-25880: rsync may be mistakenly killed when overlapping SST This commit fixes a bug was originally discovered during the galera_nbo_sst_slave mtr test for 10.6 branch. However it is relevant for all versions and can lead to intermittent SST crashes via rsync on very fast server restarts - when a new SST process (for example, after starting a new server instance) overlaps the old SST process started by the previous, already terminated server. This overlap can result in the new rsync being killed instead of the old rsync, or the pid file from the new rsync being killed, which then lead to problems. --- scripts/wsrep_sst_common.sh | 2 +- scripts/wsrep_sst_rsync.sh | 28 ++++++++++++++++++++++++---- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/scripts/wsrep_sst_common.sh b/scripts/wsrep_sst_common.sh index 05944ef6035..c2f31b2818d 100644 --- a/scripts/wsrep_sst_common.sh +++ b/scripts/wsrep_sst_common.sh @@ -1190,7 +1190,6 @@ trim_string() check_pid() { local pid_file="$1" - local remove=${2:-0} if [ -r "$pid_file" ]; then local pid=$(cat "$pid_file" 2>/dev/null) if [ -n "$pid" ]; then @@ -1201,6 +1200,7 @@ check_pid() fi fi fi + local remove=${2:-0} if [ $remove -eq 1 ]; then rm -f "$pid_file" fi diff --git a/scripts/wsrep_sst_rsync.sh b/scripts/wsrep_sst_rsync.sh index 19a4d19fded..a602af79af0 100644 --- a/scripts/wsrep_sst_rsync.sh +++ b/scripts/wsrep_sst_rsync.sh @@ -68,6 +68,8 @@ cleanup_joiner() if [ "$WSREP_SST_OPT_ROLE" = 'joiner' ]; then wsrep_cleanup_progress_file fi + + [ -f "$SST_PID" ] && rm -f "$SST_PID" } check_pid_and_port() @@ -281,6 +283,7 @@ then *) wsrep_log_error "Unrecognized ssl-mode option: '$SSLMODE'" exit 22 # EINVAL + ;; esac if [ -z "$CAFILE_OPT" ]; then wsrep_log_error "Can't have ssl-mode='$SSLMODE' without CA file" @@ -499,6 +502,21 @@ elif [ "$WSREP_SST_OPT_ROLE" = 'joiner' ] then check_sockets_utils + SST_PID="$WSREP_SST_OPT_DATA/wsrep_rsync_sst.pid" + + # give some time for lingering stunnel from previous SST to complete + check_round=0 + while check_pid "$SST_PID" 0 + do + wsrep_log_info "previous SST not completed, waiting for it to exit" + check_round=$(( check_round + 1 )) + if [ $check_round -eq 10 ]; then + wsrep_log_error "SST script already running." + exit 114 # EALREADY + fi + sleep 1 + done + # give some time for lingering stunnel from previous SST to complete check_round=0 while check_pid "$STUNNEL_PID" 1 @@ -583,12 +601,14 @@ EOF RSYNC_ADDR="*" fi + echo $$ > "$SST_PID" + if [ -z "$STUNNEL" ] then rsync --daemon --no-detach --port "$RSYNC_PORT" --config "$RSYNC_CONF" $RSYNC_EXTRA_ARGS & RSYNC_REAL_PID=$! - TRANSFER_REAL_PID="$RSYNC_REAL_PID" - TRANSFER_PID=$RSYNC_PID + TRANSFER_REAL_PID=$RSYNC_REAL_PID + TRANSFER_PID="$RSYNC_PID" else # Let's check if the path to the config file contains a space? if [ "${RSYNC_CONF#* }" = "$RSYNC_CONF" ]; then @@ -631,8 +651,8 @@ EOF fi stunnel "$STUNNEL_CONF" & STUNNEL_REAL_PID=$! - TRANSFER_REAL_PID="$STUNNEL_REAL_PID" - TRANSFER_PID=$STUNNEL_PID + TRANSFER_REAL_PID=$STUNNEL_REAL_PID + TRANSFER_PID="$STUNNEL_PID" fi if [ "${SSLMODE#VERIFY}" != "$SSLMODE" ] From 2edb8e12e10179b970007b3e1d5c465b9d0e110e Mon Sep 17 00:00:00 2001 From: Julius Goryavsky Date: Tue, 15 Jun 2021 06:24:38 +0200 Subject: [PATCH 091/251] MDEV-25880 part 2: Improving reliability of the SST scripts Additional improvements aimed at improving operational reliability of the SST scripts: 1) Script need to give rsync and stunnel a short time to terminate after "kill -9" before the first PID check using ps utility; 2) The temporary file used to create the binlog index could sometimes remain in the data directory if tar failed and then may be reused without being cleaned up (the next time when SST was run) - now it's fixed; 3) The temporary file used to build the binlog index is now created using mktemp and, if this variable is present in the configuration file, in tmpdir; 4) Checking the secret tag in SST via rsync is made faster and does not require creating a temporary file, which could remain in the data directory in case of failure; 5) Added "-F" option to grep to check the tag when using mariabackup/xtrabackup-v2 - to avoid possible collisions in case of special characters in the tag value (unlikely scenario, but the new check is more reliable). --- scripts/wsrep_sst_common.sh | 7 ++-- scripts/wsrep_sst_mariabackup.sh | 6 +-- scripts/wsrep_sst_rsync.sh | 64 ++++++++++++++++++------------ scripts/wsrep_sst_xtrabackup-v2.sh | 6 +-- 4 files changed, 49 insertions(+), 34 deletions(-) diff --git a/scripts/wsrep_sst_common.sh b/scripts/wsrep_sst_common.sh index c2f31b2818d..4dedecb439f 100644 --- a/scripts/wsrep_sst_common.sh +++ b/scripts/wsrep_sst_common.sh @@ -1223,7 +1223,7 @@ check_pid() # cleanup_pid() { - local pid="$1" + local pid=$1 local pid_file="${2:-}" local config="${3:-}" @@ -1241,8 +1241,9 @@ cleanup_pid() round=8 force=1 kill -9 $pid >/dev/null 2>&1 + sleep 0.5 else - return 1; + return 1 fi fi done @@ -1254,7 +1255,7 @@ cleanup_pid() fi [ -n "$pid_file" ] && [ -f "$pid_file" ] && rm -f "$pid_file" - [ -n "$config" ] && [ -f "$config" ] && rm -f "$config" + [ -n "$config" ] && [ -f "$config" ] && rm -f "$config" return 0 } diff --git a/scripts/wsrep_sst_mariabackup.sh b/scripts/wsrep_sst_mariabackup.sh index 7f97d9e8dea..339a8fcf4a5 100644 --- a/scripts/wsrep_sst_mariabackup.sh +++ b/scripts/wsrep_sst_mariabackup.sh @@ -741,15 +741,15 @@ recv_joiner() fi # check donor supplied secret - SECRET=$(grep -- "$SECRET_TAG " "$MAGIC_FILE" 2>/dev/null | cut -d ' ' -f 2) + SECRET=$(grep -F -- "$SECRET_TAG " "$MAGIC_FILE" 2>/dev/null | cut -d ' ' -f 2) if [ "$SECRET" != "$MY_SECRET" ]; then wsrep_log_error "Donor does not know my secret!" wsrep_log_info "Donor:'$SECRET', my:'$MY_SECRET'" exit 32 fi - # remove secret from magic file - grep -v -- "$SECRET_TAG " "$MAGIC_FILE" > "$MAGIC_FILE.new" + # remove secret from the magic file + grep -v -F -- "$SECRET_TAG " "$MAGIC_FILE" > "$MAGIC_FILE.new" mv "$MAGIC_FILE.new" "$MAGIC_FILE" fi } diff --git a/scripts/wsrep_sst_rsync.sh b/scripts/wsrep_sst_rsync.sh index a602af79af0..fc9f5017937 100644 --- a/scripts/wsrep_sst_rsync.sh +++ b/scripts/wsrep_sst_rsync.sh @@ -429,7 +429,7 @@ EOF exit 255 # unknown error fi - # second, we transfer InnoDB log files + # second, we transfer InnoDB and Aria log files rsync ${STUNNEL:+--rsh="$STUNNEL"} \ --owner --group --perms --links --specials \ --ignore-times --inplace --dirs --delete --quiet \ @@ -504,20 +504,20 @@ then SST_PID="$WSREP_SST_OPT_DATA/wsrep_rsync_sst.pid" - # give some time for lingering stunnel from previous SST to complete + # give some time for previous SST to complete: check_round=0 while check_pid "$SST_PID" 0 do - wsrep_log_info "previous SST not completed, waiting for it to exit" + wsrep_log_info "previous SST is not completed, waiting for it to exit" check_round=$(( check_round + 1 )) if [ $check_round -eq 10 ]; then - wsrep_log_error "SST script already running." + wsrep_log_error "previous SST script still running." exit 114 # EALREADY fi sleep 1 done - # give some time for lingering stunnel from previous SST to complete + # give some time for stunnel from the previous SST to complete: check_round=0 while check_pid "$STUNNEL_PID" 1 do @@ -534,7 +534,7 @@ then RSYNC_PID="$WSREP_SST_OPT_DATA/$MODULE.pid" RSYNC_CONF="$WSREP_SST_OPT_DATA/$MODULE.conf" - # give some time for lingering rsync from previous SST to complete + # give some time for rsync from the previous SST to complete: check_round=0 while check_pid "$RSYNC_PID" 1 do @@ -711,35 +711,49 @@ EOF # Clean up old binlog files first rm -f "$BINLOG_FILENAME".[0-9]* - [ -f "$binlog_index" ] && rm "$binlog_index" + [ -f "$binlog_index" ] && rm -f "$binlog_index" + + # Create a temporary file: + tmpdir=$(parse_cnf '--mysqld|sst' 'tmpdir') + if [ -z "$tmpdir" ]; then + tmpfile="$(mktemp)" + else + tmpfile=$(mktemp "--tmpdir=$tmpdir") + fi wsrep_log_info "Extracting binlog files:" - tar -xvf "$BINLOG_TAR_FILE" >> _binlog_tmp_files_$! + if ! tar -xvf "$BINLOG_TAR_FILE" > "$tmpfile"; then + wsrep_log_error "Error unpacking tar file with binlog files" + rm -f "$tmpfile" + exit 32 + fi + + # Rebuild binlog index: while read bin_file; do echo "$BINLOG_DIRNAME/$bin_file" >> "$binlog_index" - done < _binlog_tmp_files_$! - rm -f _binlog_tmp_files_$! + done < "$tmpfile" + rm -f "$tmpfile" cd "$OLD_PWD" fi fi - if [ -r "$MAGIC_FILE" ] - then - # check donor supplied secret - SECRET=$(grep -F -- "$SECRET_TAG " "$MAGIC_FILE" 2>/dev/null | cut -d ' ' -f 2) - if [ "$SECRET" != "$MY_SECRET" ]; then - wsrep_log_error "Donor does not know my secret!" - wsrep_log_info "Donor:'$SECRET', my:'$MY_SECRET'" - exit 32 + if [ -r "$MAGIC_FILE" ]; then + if [ -n "$MY_SECRET" ]; then + # check donor supplied secret + SECRET=$(grep -F -- "$SECRET_TAG " "$MAGIC_FILE" 2>/dev/null | cut -d ' ' -f 2) + if [ "$SECRET" != "$MY_SECRET" ]; then + wsrep_log_error "Donor does not know my secret!" + wsrep_log_info "Donor:'$SECRET', my:'$MY_SECRET'" + exit 32 + fi + # remove secret from the magic file, and output + # the UUID:seqno & wsrep_gtid_domain_id: + grep -v -F -- "$SECRET_TAG " "$MAGIC_FILE" + else + # Output the UUID:seqno and wsrep_gtid_domain_id: + cat "$MAGIC_FILE" fi - - # remove secret from magic file - grep -v -F -- "$SECRET_TAG " "$MAGIC_FILE" > "$MAGIC_FILE.new" - - mv "$MAGIC_FILE.new" "$MAGIC_FILE" - # UUID:seqno & wsrep_gtid_domain_id is received here. - cat "$MAGIC_FILE" # Output : UUID:seqno wsrep_gtid_domain_id else # this message should cause joiner to abort echo "rsync process ended without creating '$MAGIC_FILE'" diff --git a/scripts/wsrep_sst_xtrabackup-v2.sh b/scripts/wsrep_sst_xtrabackup-v2.sh index 24bff12219d..d76dc346a82 100644 --- a/scripts/wsrep_sst_xtrabackup-v2.sh +++ b/scripts/wsrep_sst_xtrabackup-v2.sh @@ -750,15 +750,15 @@ recv_joiner() fi # check donor supplied secret - SECRET=$(grep -- "$SECRET_TAG " "$MAGIC_FILE" 2>/dev/null | cut -d ' ' -f 2) + SECRET=$(grep -F -- "$SECRET_TAG " "$MAGIC_FILE" 2>/dev/null | cut -d ' ' -f 2) if [ "$SECRET" != "$MY_SECRET" ]; then wsrep_log_error "Donor does not know my secret!" wsrep_log_info "Donor:'$SECRET', my:'$MY_SECRET'" exit 32 fi - # remove secret from magic file - grep -v -- "$SECRET_TAG " "$MAGIC_FILE" > "$MAGIC_FILE.new" + # remove secret from the magic file + grep -v -F -- "$SECRET_TAG " "$MAGIC_FILE" > "$MAGIC_FILE.new" mv "$MAGIC_FILE.new" "$MAGIC_FILE" fi } From 79a2dbc8794a8f28be92386acdb4028a887190cc Mon Sep 17 00:00:00 2001 From: Andrei Elkin Date: Mon, 14 Jun 2021 19:22:29 +0300 Subject: [PATCH 092/251] MDEV-21117 post-push fixes 1. work around MDEV-25912 to not apply assert at wsrep running time; 2. handle wsrep mode of the server recovery 3. convert hton calls to static binlog_commit ones. 4. satisfy MSAN complain on uninitialized std::pair --- sql/handler.cc | 19 +++++++++---------- sql/handler.h | 4 ++++ sql/log.cc | 2 +- sql/log.h | 2 +- sql/log_event.cc | 5 +++++ sql/sql_table.cc | 4 ++-- 6 files changed, 22 insertions(+), 14 deletions(-) diff --git a/sql/handler.cc b/sql/handler.cc index 78ee18a4542..0ec8afde16e 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -2401,16 +2401,16 @@ struct xarecover_st static xid_recovery_member* xid_member_insert(HASH *hash_arg, my_xid xid_arg, MEM_ROOT *ptr_mem_root) { - xid_recovery_member *member= (xid_recovery_member*) + xid_recovery_member *member= (xid_recovery_member *) alloc_root(ptr_mem_root, sizeof(xid_recovery_member)); + if (!member) return NULL; - member->xid= xid_arg; - member->in_engine_prepare= 1; - member->decided_to_commit= false; + *member= xid_recovery_member(xid_arg, 1, false); - return my_hash_insert(hash_arg, (uchar*) member) ? NULL : member; + return + my_hash_insert(hash_arg, (uchar*) member) ? NULL : member; } /* @@ -2636,13 +2636,11 @@ static my_bool xarecover_handlerton(THD *unused, plugin_ref plugin, sql_print_error("Error in memory allocation at xarecover_handlerton"); break; } - } else + } if (IF_WSREP((wsrep_emulate_bin_log && wsrep_is_wsrep_xid(info->list + i) && x <= wsrep_limit), false) || - (info->commit_list ? - my_hash_search(info->commit_list, (uchar *)&x, sizeof(x)) != 0 : - tc_heuristic_recover == TC_HEURISTIC_RECOVER_COMMIT)) + tc_heuristic_recover == TC_HEURISTIC_RECOVER_COMMIT) { int rc= hton->commit_by_xid(hton, info->list+i); if (rc == 0) @@ -2653,7 +2651,8 @@ static my_bool xarecover_handlerton(THD *unused, plugin_ref plugin, }); } } - else + else if (WSREP_ON || + tc_heuristic_recover == TC_HEURISTIC_RECOVER_ROLLBACK) { int rc= hton->rollback_by_xid(hton, info->list+i); if (rc == 0) diff --git a/sql/handler.h b/sql/handler.h index d2bb514f5cf..2f15ec8f389 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -956,6 +956,10 @@ struct xid_recovery_member uint in_engine_prepare; // number of engines that have xid prepared bool decided_to_commit; Binlog_offset binlog_coord; // semisync recovery binlog offset + + xid_recovery_member(my_xid xid_arg, uint prepare_arg, bool decided_arg) + : xid(xid_arg), in_engine_prepare(prepare_arg), + decided_to_commit(decided_arg) {}; }; /* for recover() handlerton call */ diff --git a/sql/log.cc b/sql/log.cc index 047d644e5da..a6e83d1b4f5 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -11040,7 +11040,7 @@ void Recovery_context::process_gtid(int round, Gtid_log_event *gev, last_gtid_coord= Binlog_offset(id_binlog, prev_event_pos); DBUG_ASSERT(!last_gtid_valid); - DBUG_ASSERT(!last_gtid.seq_no == 0); + DBUG_ASSERT(last_gtid.seq_no != 0); if (round == 1 || (do_truncate && !truncate_validated)) { diff --git a/sql/log.h b/sql/log.h index d61e4660330..6227e579757 100644 --- a/sql/log.h +++ b/sql/log.h @@ -1243,7 +1243,7 @@ class Gtid_list_log_event; const char * get_gtid_list_event(IO_CACHE *cache, Gtid_list_log_event **out_gtid_list); -int binlog_commit(THD *thd, bool all, bool is_ro_1pc); +int binlog_commit(THD *thd, bool all, bool is_ro_1pc= false); int binlog_commit_by_xid(handlerton *hton, XID *xid); int binlog_rollback_by_xid(handlerton *hton, XID *xid); diff --git a/sql/log_event.cc b/sql/log_event.cc index c77059ee8f5..b0d47ff496b 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -2624,6 +2624,11 @@ Gtid_log_event::Gtid_log_event(const uchar *buf, uint event_len, */ DBUG_ASSERT(static_cast(buf - buf_0) <= event_len); /* and the last of them is tested. */ +#ifdef MYSQL_SERVER +#ifdef WITH_WSREP + if (!WSREP_ON) +#endif +#endif DBUG_ASSERT(static_cast(buf - buf_0) == event_len || buf_0[event_len - 1] == 0); } diff --git a/sql/sql_table.cc b/sql/sql_table.cc index e637d680973..8953ca6c1a5 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -10410,7 +10410,7 @@ do_continue:; DROP + CREATE + data statement to the binary log */ thd->variables.option_bits&= ~OPTION_BIN_COMMIT_OFF; - (binlog_hton->commit)(binlog_hton, thd, 1); + binlog_commit(thd, true); } /* We don't replicate alter table statement on temporary tables */ @@ -10624,7 +10624,7 @@ do_continue:; thd->variables.option_bits&= ~OPTION_BIN_COMMIT_OFF; thd->binlog_xid= thd->query_id; ddl_log_update_xid(&ddl_log_state, thd->binlog_xid); - binlog_hton->commit(binlog_hton, thd, 1); + binlog_commit(thd, true); thd->binlog_xid= 0; } From e0647dc7338aaacaafafc8c74a1f688790612fa8 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 14 Jun 2021 19:53:23 +0200 Subject: [PATCH 093/251] update C/C to 3.2.2-rc --- libmariadb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmariadb b/libmariadb index 01ada4b85f1..a771b3ba206 160000 --- a/libmariadb +++ b/libmariadb @@ -1 +1 @@ -Subproject commit 01ada4b85f15c1c5841082f92180bf129d89debc +Subproject commit a771b3ba2069cbef54545ee1570db8e174bc8c71 From e5b9dc15368c7597a70569048eebfc5e05e98ef4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 15 Jun 2021 22:14:51 +0300 Subject: [PATCH 094/251] MDEV-25910: Make ALTER TABLE...ALGORITHM=COPY durable again ha_innobase::extra(HA_EXTRA_END_ALTER_COPY): Flush the redo log because the main transaction will not have written any log and thus will not initiate any log write either. But the DDL recovery layer expects that the operation will have been committed. --- storage/innobase/handler/ha_innodb.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 2c0a5f8f114..5dabab139b1 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -15308,6 +15308,7 @@ ha_innobase::extra( break; case HA_EXTRA_END_ALTER_COPY: m_prebuilt->table->skip_alter_undo = 0; + log_write_up_to(LSN_MAX, true); break; default:/* Do nothing */ ; From c307dc6efde682c0768dc900818f4c0b418f9c6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 16 Jun 2021 07:50:04 +0300 Subject: [PATCH 095/251] Remove a unused variable In commit 1c35a3f6fd92704d7a135a81c7752f5058aaede5 a useless computation that used the variable was removed. --- storage/innobase/fsp/fsp0fsp.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/storage/innobase/fsp/fsp0fsp.cc b/storage/innobase/fsp/fsp0fsp.cc index cb5eff07f88..43989d57db8 100644 --- a/storage/innobase/fsp/fsp0fsp.cc +++ b/storage/innobase/fsp/fsp0fsp.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2020, MariaDB Corporation. +Copyright (c) 2017, 2021, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -2799,7 +2799,7 @@ try_again: return(true); } try_to_extend: - if (ulint n = fsp_try_extend_data_file(space, space_header, mtr)) { + if (fsp_try_extend_data_file(space, space_header, mtr)) { goto try_again; } From 35b57c37bbbfa116da4a454df5892984550b151a Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 13 May 2021 17:54:15 +0200 Subject: [PATCH 096/251] MDEV-25617 10.5.10 upgrade: "scriptlet / line 6 : [: is-active : binary operator expected" --- support-files/rpm/server-posttrans.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/support-files/rpm/server-posttrans.sh b/support-files/rpm/server-posttrans.sh index 1525b592735..3250423da8f 100644 --- a/support-files/rpm/server-posttrans.sh +++ b/support-files/rpm/server-posttrans.sh @@ -3,7 +3,7 @@ if [ -r %{restart_flag} ] ; then # only restart the server if it was alredy running if [ -x /usr/bin/systemctl ] ; then /usr/bin/systemctl daemon-reload > /dev/null 2>&1 - if [ /usr/bin/systemctl is-active mysql ]; then + if /usr/bin/systemctl is-active mysql; then /usr/bin/systemctl restart mysql > /dev/null 2>&1 else /usr/bin/systemctl try-restart mariadb.service > /dev/null 2>&1 From 48938c57c7f75b2a7627212b01cd65cfd6830261 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Fri, 11 Jun 2021 17:13:19 +1000 Subject: [PATCH 097/251] MDEV-25894: support AIX as a platform in mtr Add fixed for tests mysqld--help,aix.rdiff and sysvars_server_notembedded,aix.rdiff AIX couldn't compile in embedded mode so leaving sysvars_server_embedded for later (if required). --- mysql-test/include/platform.combinations | 2 + mysql-test/lib/My/Platform.pm | 11 +- mysql-test/main/mysqld--help,aix.rdiff | 0 mysql-test/suite.pm | 8 +- .../suite/sys_vars/inc/sysvars_server.inc | 1 + .../r/sysvars_server_notembedded,aix.rdiff | 105 ++++++++++++++++++ 6 files changed, 125 insertions(+), 2 deletions(-) create mode 100644 mysql-test/main/mysqld--help,aix.rdiff create mode 100644 mysql-test/suite/sys_vars/r/sysvars_server_notembedded,aix.rdiff diff --git a/mysql-test/include/platform.combinations b/mysql-test/include/platform.combinations index 4681ac05314..4f0660b7a40 100644 --- a/mysql-test/include/platform.combinations +++ b/mysql-test/include/platform.combinations @@ -1,4 +1,6 @@ [win] +[aix] + [unix] diff --git a/mysql-test/lib/My/Platform.pm b/mysql-test/lib/My/Platform.pm index db1206f187e..b8bc9f8ec84 100644 --- a/mysql-test/lib/My/Platform.pm +++ b/mysql-test/lib/My/Platform.pm @@ -22,7 +22,7 @@ use File::Basename; use File::Path; use base qw(Exporter); -our @EXPORT= qw(IS_CYGWIN IS_WINDOWS IS_WIN32PERL +our @EXPORT= qw(IS_CYGWIN IS_WINDOWS IS_WIN32PERL IS_AIX native_path posix_path mixed_path check_socket_path_length process_alive open_for_append); @@ -54,6 +54,15 @@ BEGIN { } } +BEGIN { + if ($^O eq "aix") { + eval 'sub IS_AIX { 1 }'; + } + else { + eval 'sub IS_AIX { 0 }'; + } +} + # # native_path diff --git a/mysql-test/main/mysqld--help,aix.rdiff b/mysql-test/main/mysqld--help,aix.rdiff new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mysql-test/suite.pm b/mysql-test/suite.pm index 8ff2e95c083..faab55e9741 100644 --- a/mysql-test/suite.pm +++ b/mysql-test/suite.pm @@ -17,7 +17,13 @@ sub skip_combinations { unless $ENV{DEBUG_KEY_MANAGEMENT_SO}; # don't run tests for the wrong platform - $skip{'include/platform.combinations'} = [ (IS_WINDOWS) ? 'unix' : 'win' ]; + if (IS_WINDOWS) { + $skip{'include/platform.combinations'} = [ 'aix', 'unix' ]; + } elsif (IS_AIX) { + $skip{'include/platform.combinations'} = [ 'win', 'unix' ]; + } else { + $skip{'include/platform.combinations'} = [ 'aix', 'win' ]; + } $skip{'include/maybe_debug.combinations'} = [ defined $::mysqld_variables{'debug-dbug'} ? 'release' : 'debug' ]; diff --git a/mysql-test/suite/sys_vars/inc/sysvars_server.inc b/mysql-test/suite/sys_vars/inc/sysvars_server.inc index 025f8a8922d..8fca98e0383 100644 --- a/mysql-test/suite/sys_vars/inc/sysvars_server.inc +++ b/mysql-test/suite/sys_vars/inc/sysvars_server.inc @@ -1,5 +1,6 @@ --source include/have_perfschema.inc --source include/word_size.inc +--source include/platform.inc --vertical_results # need stable timestamp, because its current value is printed below diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded,aix.rdiff b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded,aix.rdiff new file mode 100644 index 00000000000..3fd273569c9 --- /dev/null +++ b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded,aix.rdiff @@ -0,0 +1,105 @@ +diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result +index bb3378139f2..ddab28508ec 100644 +--- a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result ++++ b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result +@@ -4259,99 +4259,9 @@ VARIABLE_COMMENT Define threads usage for handling queries + NUMERIC_MIN_VALUE NULL + NUMERIC_MAX_VALUE NULL + NUMERIC_BLOCK_SIZE NULL +-ENUM_VALUE_LIST one-thread-per-connection,no-threads,pool-of-threads ++ENUM_VALUE_LIST one-thread-per-connection,no-threads + READ_ONLY YES + COMMAND_LINE_ARGUMENT REQUIRED +-VARIABLE_NAME THREAD_POOL_DEDICATED_LISTENER +-VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BOOLEAN +-VARIABLE_COMMENT If set to 1,listener thread will not pick up queries +-NUMERIC_MIN_VALUE NULL +-NUMERIC_MAX_VALUE NULL +-NUMERIC_BLOCK_SIZE NULL +-ENUM_VALUE_LIST OFF,ON +-READ_ONLY NO +-COMMAND_LINE_ARGUMENT OPTIONAL +-VARIABLE_NAME THREAD_POOL_EXACT_STATS +-VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE BOOLEAN +-VARIABLE_COMMENT If set to 1, provides better statistics in information_schema threadpool tables +-NUMERIC_MIN_VALUE NULL +-NUMERIC_MAX_VALUE NULL +-NUMERIC_BLOCK_SIZE NULL +-ENUM_VALUE_LIST OFF,ON +-READ_ONLY NO +-COMMAND_LINE_ARGUMENT OPTIONAL +-VARIABLE_NAME THREAD_POOL_IDLE_TIMEOUT +-VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE INT UNSIGNED +-VARIABLE_COMMENT Timeout in seconds for an idle thread in the thread pool.Worker thread will be shut down after timeout +-NUMERIC_MIN_VALUE 1 +-NUMERIC_MAX_VALUE 4294967295 +-NUMERIC_BLOCK_SIZE 1 +-ENUM_VALUE_LIST NULL +-READ_ONLY NO +-COMMAND_LINE_ARGUMENT REQUIRED +-VARIABLE_NAME THREAD_POOL_MAX_THREADS +-VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE INT UNSIGNED +-VARIABLE_COMMENT Maximum allowed number of worker threads in the thread pool +-NUMERIC_MIN_VALUE 1 +-NUMERIC_MAX_VALUE 65536 +-NUMERIC_BLOCK_SIZE 1 +-ENUM_VALUE_LIST NULL +-READ_ONLY NO +-COMMAND_LINE_ARGUMENT REQUIRED +-VARIABLE_NAME THREAD_POOL_OVERSUBSCRIBE +-VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE INT UNSIGNED +-VARIABLE_COMMENT How many additional active worker threads in a group are allowed. +-NUMERIC_MIN_VALUE 1 +-NUMERIC_MAX_VALUE 1000 +-NUMERIC_BLOCK_SIZE 1 +-ENUM_VALUE_LIST NULL +-READ_ONLY NO +-COMMAND_LINE_ARGUMENT REQUIRED +-VARIABLE_NAME THREAD_POOL_PRIORITY +-VARIABLE_SCOPE SESSION +-VARIABLE_TYPE ENUM +-VARIABLE_COMMENT Threadpool priority. High priority connections usually start executing earlier than low priority.If priority set to 'auto', the the actual priority(low or high) is determined based on whether or not connection is inside transaction. +-NUMERIC_MIN_VALUE NULL +-NUMERIC_MAX_VALUE NULL +-NUMERIC_BLOCK_SIZE NULL +-ENUM_VALUE_LIST high,low,auto +-READ_ONLY NO +-COMMAND_LINE_ARGUMENT REQUIRED +-VARIABLE_NAME THREAD_POOL_PRIO_KICKUP_TIMER +-VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE INT UNSIGNED +-VARIABLE_COMMENT The number of milliseconds before a dequeued low-priority statement is moved to the high-priority queue +-NUMERIC_MIN_VALUE 0 +-NUMERIC_MAX_VALUE 4294967295 +-NUMERIC_BLOCK_SIZE 1 +-ENUM_VALUE_LIST NULL +-READ_ONLY NO +-COMMAND_LINE_ARGUMENT REQUIRED +-VARIABLE_NAME THREAD_POOL_SIZE +-VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE INT UNSIGNED +-VARIABLE_COMMENT Number of thread groups in the pool. This parameter is roughly equivalent to maximum number of concurrently executing threads (threads in a waiting state do not count as executing). +-NUMERIC_MIN_VALUE 1 +-NUMERIC_MAX_VALUE 100000 +-NUMERIC_BLOCK_SIZE 1 +-ENUM_VALUE_LIST NULL +-READ_ONLY NO +-COMMAND_LINE_ARGUMENT REQUIRED +-VARIABLE_NAME THREAD_POOL_STALL_LIMIT +-VARIABLE_SCOPE GLOBAL +-VARIABLE_TYPE INT UNSIGNED +-VARIABLE_COMMENT Maximum query execution time in milliseconds,before an executing non-yielding thread is considered stalled.If a worker thread is stalled, additional worker thread may be created to handle remaining clients. +-NUMERIC_MIN_VALUE 1 +-NUMERIC_MAX_VALUE 4294967295 +-NUMERIC_BLOCK_SIZE 1 +-ENUM_VALUE_LIST NULL +-READ_ONLY NO +-COMMAND_LINE_ARGUMENT REQUIRED + VARIABLE_NAME THREAD_STACK + VARIABLE_SCOPE GLOBAL + VARIABLE_TYPE BIGINT UNSIGNED From 71964c76fe0d7266103025c31d5b7f5d50854383 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 16 Jun 2021 09:03:02 +0300 Subject: [PATCH 098/251] MDEV-25910: Aim to make all InnoDB DDL durable Before any committed DDL operation returns control to the caller, we must ensure that it will have been durably committed before the ddl_log state may be changed, no matter if innodb_flush_log_at_trx_commit=0 is being used. Operations that would involve deleting files were already safe, because the durable write of the FILE_DELETE record that would precede the file deletion would also have made the commit durable. Furthermore, when we clean up ADD INDEX stubs that were left behind by a previous ha_innobase::commit_inplace_alter_table(commit=false) when MDL could not be acquired, we will use the same interface as for dropping indexes. This safety measure should be dead code, because ADD FULLTEXT INDEX is not supported online, and dropping indexes only involves file deletion for FULLTEXT INDEX. --- mysql-test/suite/atomic/alter_table.result | 2 +- storage/innobase/handler/ha_innodb.cc | 18 +++++-- storage/innobase/handler/handler0alter.cc | 58 ++++++++++++---------- 3 files changed, 49 insertions(+), 29 deletions(-) diff --git a/mysql-test/suite/atomic/alter_table.result b/mysql-test/suite/atomic/alter_table.result index 9807008e119..cd4c1ad5617 100644 --- a/mysql-test/suite/atomic/alter_table.result +++ b/mysql-test/suite/atomic/alter_table.result @@ -2134,7 +2134,7 @@ t1 CREATE TABLE `t1` ( KEY `a` (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='new' count(*) -0 +2 master-bin.000002 # Query # # use `test`; ALTER TABLE t1 ADD COLUMN c INT, ALGORITHM=copy, COMMENT "new" crash point: ddl_log_alter_after_rename_to_backup t1.frm diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 5dabab139b1..11e9ab2e8cd 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -1559,6 +1559,8 @@ retry: mem_heap_free(heap); for (pfs_os_file_t detached : to_close) os_file_close(detached); + /* Any changes must be persisted before we return. */ + log_write_up_to(mtr.commit_lsn(), true); } my_free(namebuf); @@ -13033,6 +13035,9 @@ ha_innobase::create( row_mysql_unlock_data_dictionary(trx); for (pfs_os_file_t d : deleted) os_file_close(d); error = info.create_table_update_dict(); + if (!(info.flags2() & DICT_TF2_TEMPORARY)) { + log_write_up_to(trx->commit_lsn, true); + } } if (own_trx) { @@ -13379,10 +13384,11 @@ err_exit: std::vector deleted; trx->commit(deleted); row_mysql_unlock_data_dictionary(trx); - if (trx != parent_trx) - trx->free(); for (pfs_os_file_t d : deleted) os_file_close(d); + log_write_up_to(trx->commit_lsn, true); + if (trx != parent_trx) + trx->free(); if (fts) purge_sys.resume_FTS(); DBUG_RETURN(0); @@ -13595,6 +13601,7 @@ int ha_innobase::truncate() err = create(name, table, &info, dict_table_is_file_per_table(ib_table), trx); + /* On success, create() durably committed trx. */ if (fts) { purge_sys.resume_FTS(); } @@ -13690,6 +13697,9 @@ ha_innobase::rename_table( } row_mysql_unlock_data_dictionary(trx); + if (error == DB_SUCCESS) { + log_write_up_to(trx->commit_lsn, true); + } trx->free(); if (error == DB_DUPLICATE_KEY) { @@ -15308,7 +15318,9 @@ ha_innobase::extra( break; case HA_EXTRA_END_ALTER_COPY: m_prebuilt->table->skip_alter_undo = 0; - log_write_up_to(LSN_MAX, true); + if (!m_prebuilt->table->is_temporary()) { + log_write_up_to(LSN_MAX, true); + } break; default:/* Do nothing */ ; diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index fce6c06b6c6..e020955502e 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -4090,6 +4090,26 @@ online_retry_drop_indexes_low( } } +/** After commit, unlock the data dictionary and close any deleted files. +@param deleted handles of deleted files +@param trx committed transaction */ +static void unlock_and_close_files(const std::vector &deleted, + trx_t *trx) +{ + row_mysql_unlock_data_dictionary(trx); + for (pfs_os_file_t d : deleted) + os_file_close(d); + log_write_up_to(trx->commit_lsn, true); +} + +/** Commit a DDL transaction and unlink any deleted files. */ +static void commit_unlock_and_unlink(trx_t *trx) +{ + std::vector deleted; + trx->commit(deleted); + unlock_and_close_files(deleted, trx); +} + /********************************************************************//** Drop any indexes that we were not able to free previously due to open table handles. */ @@ -4107,8 +4127,7 @@ online_retry_drop_indexes( row_mysql_lock_data_dictionary(trx); online_retry_drop_indexes_low(table, trx); - trx_commit_for_mysql(trx); - row_mysql_unlock_data_dictionary(trx); + commit_unlock_and_unlink(trx); trx->free(); } @@ -4139,7 +4158,16 @@ online_retry_drop_indexes_with_trx( trx_start_for_ddl(trx); online_retry_drop_indexes_low(table, trx); - trx_commit_for_mysql(trx); + std::vector deleted; + trx->commit(deleted); + /* FIXME: We are holding the data dictionary latch here + while waiting for the files to be actually deleted. + However, we should never have any deleted files here, + because they would be related to ADD FULLTEXT INDEX, + and that operation is never supported online. */ + for (pfs_os_file_t d : deleted) { + os_file_close(d); + } } } @@ -6094,24 +6122,6 @@ create_index_dict( DBUG_RETURN(index); } -/** After releasing the data dictionary latch, close deleted files -@param deleted handles of deleted files */ -static void close_unlinked_files(const std::vector &deleted) -{ - dict_sys.assert_not_locked(); - for (pfs_os_file_t d : deleted) - os_file_close(d); -} - -/** Commit a DDL transaction and unlink any deleted files. */ -static void commit_unlock_and_unlink(trx_t *trx) -{ - std::vector deleted; - trx->commit(deleted); - row_mysql_unlock_data_dictionary(trx); - close_unlinked_files(deleted); -} - /** Update internal structures with concurrent writes blocked, while preparing ALTER TABLE. @@ -11146,9 +11156,8 @@ foreign_fail: ctx->prebuilt->table, altered_table->s); } - row_mysql_unlock_data_dictionary(trx); + unlock_and_close_files(deleted, trx); trx->free(); - close_unlinked_files(deleted); if (fts_exist) { purge_sys.resume_FTS(); } @@ -11199,9 +11208,8 @@ foreign_fail: #endif } - row_mysql_unlock_data_dictionary(trx); + unlock_and_close_files(deleted, trx); trx->free(); - close_unlinked_files(deleted); if (fts_exist) { purge_sys.resume_FTS(); } From da65cb4d97fbd55411dd08108ecc2cf72712851d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 16 Jun 2021 12:23:41 +0300 Subject: [PATCH 099/251] MDEV-25936 Crash during DDL that involves FULLTEXT INDEX In commit 1bd681c8b3c5213ce1f7976940a7dc38b48a0d39 we introduced a work-around for the missing MDL protection when the internal tables of FULLTEXT INDEX are dropped during DDL operations. That work-around suffered from a race condition. A purge thread could have narrowly passed purge_sys.check_stop_FTS() and then (while holding dict_sys.mutex) acquire a table reference right after fts_lock_table() determined that no references were being held. fts_lock_table(): Protect the reference check with dict_sys.mutex. Thanks to Thirunarayanan Balathandayuthapani for repeating the failure and testing the fix. --- storage/innobase/fts/fts0fts.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/storage/innobase/fts/fts0fts.cc b/storage/innobase/fts/fts0fts.cc index d1b71f3e72e..be9a4cc25c3 100644 --- a/storage/innobase/fts/fts0fts.cc +++ b/storage/innobase/fts/fts0fts.cc @@ -1549,15 +1549,19 @@ static dberr_t fts_lock_table(trx_t *trx, const char *table_name) { dberr_t err= lock_table_for_trx(table, trx, LOCK_X); /* Wait for purge threads to stop using the table. */ + dict_sys.mutex_lock(); for (uint n= 15; table->get_ref_count() > 1; ) { + dict_sys.mutex_unlock(); if (!--n) { err= DB_LOCK_WAIT_TIMEOUT; break; } std::this_thread::sleep_for(std::chrono::milliseconds(50)); + dict_sys.mutex_lock(); } + dict_sys.mutex_unlock(); table->release(); return err; } From e95f78f4752e4c0433e969f34e01b4b6be39efa1 Mon Sep 17 00:00:00 2001 From: Andrei Elkin Date: Wed, 16 Jun 2021 17:10:11 +0300 Subject: [PATCH 100/251] MDEV-21117 post-push to cover a "custom" xid format Due to wsrep uses its own xid format for its recovery, the xid hashing has to be refined. When a xid object is not in the server "mysql" format, the hash record made to contain the xid also in the full format. --- sql/handler.cc | 41 ++++++++++++++++++++++++++++------------- sql/handler.h | 6 ++++-- 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/sql/handler.cc b/sql/handler.cc index 0ec8afde16e..393f6234653 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -2399,15 +2399,22 @@ struct xarecover_st or NULL. */ static xid_recovery_member* -xid_member_insert(HASH *hash_arg, my_xid xid_arg, MEM_ROOT *ptr_mem_root) +xid_member_insert(HASH *hash_arg, my_xid xid_arg, MEM_ROOT *ptr_mem_root, + XID *full_xid_arg) { xid_recovery_member *member= (xid_recovery_member *) alloc_root(ptr_mem_root, sizeof(xid_recovery_member)); + XID *xid_full= NULL; - if (!member) + if (full_xid_arg) + xid_full= (XID*) alloc_root(ptr_mem_root, sizeof(XID)); + + if (!member || (full_xid_arg && !xid_full)) return NULL; - *member= xid_recovery_member(xid_arg, 1, false); + if (full_xid_arg) + *xid_full= *full_xid_arg; + *member= xid_recovery_member(xid_arg, 1, false, xid_full); return my_hash_insert(hash_arg, (uchar*) member) ? NULL : member; @@ -2421,14 +2428,15 @@ xid_member_insert(HASH *hash_arg, my_xid xid_arg, MEM_ROOT *ptr_mem_root) true otherwise. */ static bool xid_member_replace(HASH *hash_arg, my_xid xid_arg, - MEM_ROOT *ptr_mem_root) + MEM_ROOT *ptr_mem_root, + XID *full_xid_arg) { xid_recovery_member* member; if ((member= (xid_recovery_member *) my_hash_search(hash_arg, (uchar *)& xid_arg, sizeof(xid_arg)))) member->in_engine_prepare++; else - member= xid_member_insert(hash_arg, xid_arg, ptr_mem_root); + member= xid_member_insert(hash_arg, xid_arg, ptr_mem_root, full_xid_arg); return member == NULL; } @@ -2479,7 +2487,10 @@ static void xarecover_do_commit_or_rollback(handlerton *hton, xid_recovery_member *member= arg->member; Binlog_offset *ptr_commit_max= arg->binlog_coord; - x.set(member->xid); + if (!member->full_xid) + x.set(member->xid); + else + x= *member->full_xid; rc= xarecover_decide_to_commit(member, ptr_commit_max) ? hton->commit_by_xid(hton, &x) : hton->rollback_by_xid(hton, &x); @@ -2601,10 +2612,13 @@ static my_bool xarecover_handlerton(THD *unused, plugin_ref plugin, for (int i=0; i < got; i ++) { - my_xid x= IF_WSREP(wsrep_is_wsrep_xid(&info->list[i]) ? - wsrep_xid_seqno(&info->list[i]) : - info->list[i].get_my_xid(), - info->list[i].get_my_xid()); + my_xid x= info->list[i].get_my_xid(); + bool is_server_xid= x > 0; + +#ifdef WITH_WSREP + if (!is_server_xid && wsrep_is_wsrep_xid(&info->list[i])) + x= wsrep_xid_seqno(&info->list[i]); +#endif if (!x) // not "mine" - that is generated by external TM { DBUG_EXECUTE("info",{ @@ -2630,7 +2644,9 @@ static my_bool xarecover_handlerton(THD *unused, plugin_ref plugin, */ if (info->mem_root) { - if (xid_member_replace(info->commit_list, x, info->mem_root)) + // remember "full" xid too when it's not in mysql format + if (xid_member_replace(info->commit_list, x, info->mem_root, + is_server_xid? NULL : &info->list[i])) { info->error= true; sql_print_error("Error in memory allocation at xarecover_handlerton"); @@ -2651,8 +2667,7 @@ static my_bool xarecover_handlerton(THD *unused, plugin_ref plugin, }); } } - else if (WSREP_ON || - tc_heuristic_recover == TC_HEURISTIC_RECOVER_ROLLBACK) + else if (!info->mem_root) { int rc= hton->rollback_by_xid(hton, info->list+i); if (rc == 0) diff --git a/sql/handler.h b/sql/handler.h index 2f15ec8f389..7ad00ee546b 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -956,10 +956,12 @@ struct xid_recovery_member uint in_engine_prepare; // number of engines that have xid prepared bool decided_to_commit; Binlog_offset binlog_coord; // semisync recovery binlog offset + XID *full_xid; // needed by wsrep or past it recovery - xid_recovery_member(my_xid xid_arg, uint prepare_arg, bool decided_arg) + xid_recovery_member(my_xid xid_arg, uint prepare_arg, bool decided_arg, + XID *full_xid_arg) : xid(xid_arg), in_engine_prepare(prepare_arg), - decided_to_commit(decided_arg) {}; + decided_to_commit(decided_arg), full_xid(full_xid_arg) {}; }; /* for recover() handlerton call */ From f778a5d5e2aaff7c58000f9e2423a809db14747c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 17 Jun 2021 13:46:16 +0300 Subject: [PATCH 101/251] MDEV-25854: Remove garbage tables after restoring a backup In commit 1c5ae9919463ee0fc1d65fdfc7ec39534495ecaf (MDEV-25666) we had changed Mariabackup so that it would no longer skip files whose names start with #sql. This turned out to be wrong. Because operations on such named files are not protected by any locks in the server, it is not safe to copy them. Not copying the files may make the InnoDB data dictionary inconsistent with the file system. So, we must do something in InnoDB to adjust for that. If InnoDB is being started up without the redo log (ib_logfile0) or with a zero-length log file, we will assume that the server was restored from a backup, and adjust things as follows: dict_check_sys_tables(), fil_ibd_open(): Do not complain about missing #sql files if they would be dropped a little later. dict_stats_update_if_needed(): Never add #sql tables to the recomputing queue. This avoids a potential race condition when dropping the garbage tables. drop_garbage_tables_after_restore(): Try to drop any garbage tables. innodb_ddl_recovery_done(): Invoke drop_garbage_tables_after_restore() if srv_start_after_restore (a new flag) was set and we are not in read-only mode (innodb_read_only=ON or innodb_force_recovery>3). The tests and dbug_mariabackup_event() instrumentation were developed by Vladislav Vaintroub, who also reviewed this. --- extra/mariabackup/backup_mysql.cc | 2 + extra/mariabackup/xtrabackup.cc | 21 +++- extra/mariabackup/xtrabackup.h | 12 ++ .../suite/mariabackup/alter_copy_excluded.opt | 1 + .../mariabackup/alter_copy_excluded.result | 25 ++++ .../mariabackup/alter_copy_excluded.test | 65 +++++++++++ .../suite/mariabackup/alter_copy_race.result | 24 ++++ .../suite/mariabackup/alter_copy_race.test | 50 ++++++++ sql/sql_table.cc | 3 +- storage/innobase/dict/dict0load.cc | 17 ++- storage/innobase/dict/dict0stats_bg.cc | 3 + storage/innobase/fil/fil0fil.cc | 21 +++- storage/innobase/handler/ha_innodb.cc | 108 ++++++++++++++++++ storage/innobase/include/srv0srv.h | 3 + storage/innobase/srv/srv0srv.cc | 3 + storage/innobase/srv/srv0start.cc | 7 +- 16 files changed, 351 insertions(+), 14 deletions(-) create mode 100644 mysql-test/suite/mariabackup/alter_copy_excluded.opt create mode 100644 mysql-test/suite/mariabackup/alter_copy_excluded.result create mode 100644 mysql-test/suite/mariabackup/alter_copy_excluded.test create mode 100644 mysql-test/suite/mariabackup/alter_copy_race.result create mode 100644 mysql-test/suite/mariabackup/alter_copy_race.test diff --git a/extra/mariabackup/backup_mysql.cc b/extra/mariabackup/backup_mysql.cc index e1afbf6f99b..f287af82e6f 100644 --- a/extra/mariabackup/backup_mysql.cc +++ b/extra/mariabackup/backup_mysql.cc @@ -921,9 +921,11 @@ bool lock_tables(MYSQL *connection) } xb_mysql_query(connection, "BACKUP STAGE START", true); + DBUG_MARIABACKUP_EVENT("after_backup_stage_start", {}); // xb_mysql_query(connection, "BACKUP STAGE FLUSH", true); // xb_mysql_query(connection, "BACKUP STAGE BLOCK_DDL", true); xb_mysql_query(connection, "BACKUP STAGE BLOCK_COMMIT", true); + DBUG_MARIABACKUP_EVENT("after_backup_stage_block_commit", {}); /* Set the maximum supported session value for lock_wait_timeout to prevent unnecessary timeouts when the global value is changed from the default */ diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index 37337e8d990..21f27c0c8ed 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -2546,11 +2546,24 @@ check_if_skip_table( dbname = NULL; tbname = name; - while ((ptr = strchr(tbname, '/')) != NULL) { + for (;;) { + ptr= strchr(tbname, '/'); +#ifdef _WIN32 + if (!ptr) { + ptr= strchr(tbname,'\\'); + } +#endif + if (!ptr) { + break; + } dbname = tbname; tbname = ptr + 1; } + if (strncmp(tbname, tmp_file_prefix, tmp_file_prefix_length) == 0) { + return TRUE; + } + if (regex_exclude_list.empty() && regex_include_list.empty() && !tables_include_hash.array && @@ -3038,7 +3051,7 @@ To use this facility, you need to for the variable) 3. start mariabackup with --dbug=+d,debug_mariabackup_events */ -static void dbug_mariabackup_event(const char *event, +void dbug_mariabackup_event(const char *event, const fil_space_t::name_type key) { char *sql = dbug_mariabackup_get_val(event, key); @@ -3047,10 +3060,6 @@ static void dbug_mariabackup_event(const char *event, xb_mysql_query(mysql_connection, sql, false, true); } } -# define DBUG_MARIABACKUP_EVENT(A, B) \ - DBUG_EXECUTE_IF("mariabackup_events", dbug_mariabackup_event(A,B);) -#else -# define DBUG_MARIABACKUP_EVENT(A, B) /* empty */ #endif // DBUG_OFF /** Datafiles copying thread.*/ diff --git a/extra/mariabackup/xtrabackup.h b/extra/mariabackup/xtrabackup.h index 0d1d3eb5a6b..37cc54e5abb 100644 --- a/extra/mariabackup/xtrabackup.h +++ b/extra/mariabackup/xtrabackup.h @@ -284,4 +284,16 @@ fil_file_readdir_next_file( os_file_dir_t dir, /*!< in: directory stream */ os_file_stat_t* info); /*!< in/out: buffer where the info is returned */ + +#ifndef DBUG_OFF +#include +extern void dbug_mariabackup_event(const char *event, + const fil_space_t::name_type key); + +#define DBUG_MARIABACKUP_EVENT(A, B) \ + DBUG_EXECUTE_IF("mariabackup_events", dbug_mariabackup_event(A, B);) +#else +#define DBUG_MARIABACKUP_EVENT(A, B) /* empty */ +#endif // DBUG_OFF + #endif /* XB_XTRABACKUP_H */ diff --git a/mysql-test/suite/mariabackup/alter_copy_excluded.opt b/mysql-test/suite/mariabackup/alter_copy_excluded.opt new file mode 100644 index 00000000000..56434e883de --- /dev/null +++ b/mysql-test/suite/mariabackup/alter_copy_excluded.opt @@ -0,0 +1 @@ +--loose-innodb_sys_tablespaces diff --git a/mysql-test/suite/mariabackup/alter_copy_excluded.result b/mysql-test/suite/mariabackup/alter_copy_excluded.result new file mode 100644 index 00000000000..18e55f8d46b --- /dev/null +++ b/mysql-test/suite/mariabackup/alter_copy_excluded.result @@ -0,0 +1,25 @@ +# xtrabackup backup +CREATE TABLE t1(i int) ENGINE=InnoDB; +INSERT into t1 values(1); +connect con2, localhost, root,,; +connection con2; +SET debug_sync='copy_data_between_tables_before_reset_backup_lock SIGNAL go WAIT_FOR after_backup_stage_block_commit' ; +SET debug_sync='now WAIT_FOR after_backup_stage_start';ALTER TABLE test.t1 FORCE, algorithm=COPY;| +connection default; +connection con2; +SET debug_sync='RESET'; +disconnect con2; +connection default; +# xtrabackup prepare +# shutdown server +# remove datadir +# xtrabackup move back +# restart +SELECT COUNT(*) AS expect_0 FROM INFORMATION_SCHEMA.innodb_sys_tablespaces WHERE name like '%/#sql%'; +expect_0 +0 +SELECT * FROM t1; +i +1 +DROP TABLE t1; +# restart diff --git a/mysql-test/suite/mariabackup/alter_copy_excluded.test b/mysql-test/suite/mariabackup/alter_copy_excluded.test new file mode 100644 index 00000000000..047b83fa66b --- /dev/null +++ b/mysql-test/suite/mariabackup/alter_copy_excluded.test @@ -0,0 +1,65 @@ +--source include/have_innodb.inc +--source include/have_debug.inc + +# The test demonstrates that intermediate tables (ALTER TABLE...ALGORITHM=COPY) +# will not be included in a backup. + +echo # xtrabackup backup; +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; + +CREATE TABLE t1(i int) ENGINE=InnoDB; +INSERT into t1 values(1); + +connect con2, localhost, root,,; +connection con2; +SET debug_sync='copy_data_between_tables_before_reset_backup_lock SIGNAL go WAIT_FOR after_backup_stage_block_commit' ; +DELIMITER |; +send SET debug_sync='now WAIT_FOR after_backup_stage_start';ALTER TABLE test.t1 FORCE, algorithm=COPY;| +DELIMITER ;| +connection default; + +# Setup mariabackup events +# - After BACKUP STAGE START , let concurrent ALTER run, wand wait for it to create temporary tables +# - After BACKUP STAGE COMMIT, check that temporary files are in the database + +let after_backup_stage_start=SET debug_sync='now SIGNAL after_backup_stage_start WAIT_FOR go'; +DELIMITER |; +# The following query only works if there are innodb "intermediate" tables +# in the system tables , which we want to prove there +let after_backup_stage_block_commit= + IF (SELECT COUNT(*) > 0 FROM INFORMATION_SCHEMA.innodb_sys_tablespaces WHERE name like '%/#sql%') THEN + SET debug_sync='now SIGNAL after_backup_stage_block_commit'; + END IF| +DELIMITER ;| + +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir --dbug=+d,mariabackup_events; +--enable_result_log + +# There should be no temp files in the backup. +--list_files $targetdir/test #sql* + +connection con2; +#Wait for ALTER to finish, cleanup +reap; +SET debug_sync='RESET'; +disconnect con2; + +connection default; +echo # xtrabackup prepare; +--disable_result_log +exec $XTRABACKUP --prepare --target-dir=$targetdir; +-- source include/restart_and_restore.inc +--enable_result_log + +# Check there are no temp tablespaces in sys_tablespaces, after backup +SELECT COUNT(*) AS expect_0 FROM INFORMATION_SCHEMA.innodb_sys_tablespaces WHERE name like '%/#sql%'; +SELECT * FROM t1; +DROP TABLE t1; + +# Restart once again to clear first_start_after_backup flag +# This is to catch potential warnings, since "missing file" for #sql is suppressed +# during the first start after backup +--source include/restart_mysqld.inc + +rmdir $targetdir; diff --git a/mysql-test/suite/mariabackup/alter_copy_race.result b/mysql-test/suite/mariabackup/alter_copy_race.result new file mode 100644 index 00000000000..82202249f81 --- /dev/null +++ b/mysql-test/suite/mariabackup/alter_copy_race.result @@ -0,0 +1,24 @@ +# xtrabackup backup +CREATE TABLE t1(i int) ENGINE=InnoDB; +INSERT into t1 values(1); +connect con2, localhost, root,,; +connection con2; +set lock_wait_timeout=1; +SET debug_sync='copy_data_between_tables_before_reset_backup_lock SIGNAL go WAIT_FOR after_backup_stage_block_commit'; +SET debug_sync='alter_table_after_temp_table_drop SIGNAL temp_table_dropped'; +SET debug_sync='now WAIT_FOR after_backup_stage_start';ALTER TABLE test.t1 FORCE, algorithm=COPY;| +connection default; +connection con2; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +SET debug_sync='RESET'; +disconnect con2; +connection default; +# xtrabackup prepare +# shutdown server +# remove datadir +# xtrabackup move back +# restart +SELECT * FROM t1; +i +1 +DROP TABLE t1; diff --git a/mysql-test/suite/mariabackup/alter_copy_race.test b/mysql-test/suite/mariabackup/alter_copy_race.test new file mode 100644 index 00000000000..1ee69168115 --- /dev/null +++ b/mysql-test/suite/mariabackup/alter_copy_race.test @@ -0,0 +1,50 @@ +--source include/have_innodb.inc +--source include/have_debug.inc + +# The test demonstrates that intermediate tables (ALTER TABLE...ALGORITHM=COPY) +# are not always properly locked, e.g., can be dropped after +# BACKUP STAGE BLOCK_COMMIT +# succeeded. +# Thus mariabackup decides not to have them in backup at all, +# since they keep changing even after the backup LSN was determined. + +echo # xtrabackup backup; +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; + +CREATE TABLE t1(i int) ENGINE=InnoDB; +INSERT into t1 values(1); + +connect con2, localhost, root,,; +connection con2; +set lock_wait_timeout=1; +SET debug_sync='copy_data_between_tables_before_reset_backup_lock SIGNAL go WAIT_FOR after_backup_stage_block_commit'; +SET debug_sync='alter_table_after_temp_table_drop SIGNAL temp_table_dropped'; +DELIMITER |; +send SET debug_sync='now WAIT_FOR after_backup_stage_start';ALTER TABLE test.t1 FORCE, algorithm=COPY;| +DELIMITER ;| +connection default; + +# setup mariabackup events +let after_backup_stage_start=SET debug_sync='now SIGNAL after_backup_stage_start WAIT_FOR go'; +let after_backup_stage_block_commit=SET debug_sync='now SIGNAL after_backup_stage_block_commit'; +let backup_fix_ddl=SET debug_sync='now WAIT_FOR temp_table_dropped'; +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir --dbug=+d,mariabackup_events; +--enable_result_log + +connection con2; +--error ER_LOCK_WAIT_TIMEOUT +reap; +SET debug_sync='RESET'; +disconnect con2; + +connection default; +echo # xtrabackup prepare; +--disable_result_log +exec $XTRABACKUP --prepare --target-dir=$targetdir; +-- source include/restart_and_restore.inc +--enable_result_log + +SELECT * FROM t1; +DROP TABLE t1; +rmdir $targetdir; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 8953ca6c1a5..16ac5e06809 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -10743,7 +10743,7 @@ err_new_table_cleanup: &alter_ctx.new_db, &alter_ctx.tmp_name, (FN_IS_TMP | (no_ha_table ? NO_HA_TABLE : 0)), alter_ctx.get_tmp_path()); - + DEBUG_SYNC(thd, "alter_table_after_temp_table_drop"); err_cleanup: my_free(const_cast(frm.str)); ddl_log_complete(&ddl_log_state); @@ -11178,6 +11178,7 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to, cleanup_done= 1; to->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY); + DEBUG_SYNC(thd, "copy_data_between_tables_before_reset_backup_lock"); if (backup_reset_alter_copy_lock(thd)) error= 1; diff --git a/storage/innobase/dict/dict0load.cc b/storage/innobase/dict/dict0load.cc index 2b9078a1c85..ac81de9a25c 100644 --- a/storage/innobase/dict/dict0load.cc +++ b/storage/innobase/dict/dict0load.cc @@ -888,11 +888,18 @@ static ulint dict_check_sys_tables() IBD, false); /* Check that the .ibd file exists. */ - if (!fil_ibd_open( - false, - FIL_TYPE_TABLESPACE, - space_id, dict_tf_to_fsp_flags(flags), - name, filepath)) { + if (fil_ibd_open(false, FIL_TYPE_TABLESPACE, + space_id, dict_tf_to_fsp_flags(flags), + name, filepath)) { + } else if (srv_operation == SRV_OPERATION_NORMAL + && srv_start_after_restore + && srv_force_recovery < SRV_FORCE_NO_BACKGROUND + && dict_table_t::is_temporary_name(filepath)) { + /* Mariabackup will not copy files whose + names start with #sql-. This table ought to + be dropped by drop_garbage_tables_after_restore() + a little later. */ + } else { sql_print_warning("InnoDB: Ignoring tablespace for" " %.*s because it" " could not be opened.", diff --git a/storage/innobase/dict/dict0stats_bg.cc b/storage/innobase/dict/dict0stats_bg.cc index 52ff6d7bfe4..dbaff373ac4 100644 --- a/storage/innobase/dict/dict0stats_bg.cc +++ b/storage/innobase/dict/dict0stats_bg.cc @@ -168,6 +168,9 @@ void dict_stats_update_if_needed_func(dict_table_t *table) ulonglong n_rows = dict_table_get_n_rows(table); if (dict_stats_is_persistent_enabled(table)) { + if (table->name.is_temporary()) { + return; + } if (counter > n_rows / 10 /* 10% */ && dict_stats_auto_recalc_is_enabled(table)) { diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index 5f6b9e5578d..c4a7cef0ba1 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -2246,7 +2246,19 @@ func_exit: /* Always look for a file at the default location. But don't log an error if the tablespace is already open in remote or dict. */ ut_a(df_default.filepath()); - const bool strict = (tablespaces_found == 0); + + /* Mariabackup will not copy files whose names start with + #sql-. We will suppress messages about such files missing on + the first server startup. The tables ought to be dropped by + drop_garbage_tables_after_restore() a little later. */ + + const bool strict = !tablespaces_found + && !(srv_operation == SRV_OPERATION_NORMAL + && srv_start_after_restore + && srv_force_recovery < SRV_FORCE_NO_BACKGROUND + && dict_table_t::is_temporary_name( + df_default.filepath())); + if (df_default.open_read_only(strict) == DB_SUCCESS) { ut_ad(df_default.is_open()); ++tablespaces_found; @@ -2281,6 +2293,13 @@ func_exit: /* Make sense of these three possible locations. First, bail out if no tablespace files were found. */ if (valid_tablespaces_found == 0) { + if (!strict + && IF_WIN(GetLastError() == ERROR_FILE_NOT_FOUND, + errno == ENOENT)) { + /* Suppress a message about a missing file. */ + goto corrupted; + } + os_file_get_last_error(true); sql_print_error("InnoDB: Could not find a valid tablespace" " file for %.*s. %s", diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 11e9ab2e8cd..4ca78884009 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -1954,6 +1954,112 @@ static int innodb_check_version(handlerton *hton, const char *path, DBUG_RETURN(2); } +/** Drop any garbage intermediate tables that existed in the system +after a backup was restored. + +In a final phase of Mariabackup, the commit of DDL operations is blocked, +and those DDL operations will have to be rolled back. Because the +normal DDL recovery will not run due to the lack of the log file, +at least some #sql-alter- garbage tables may remain in the InnoDB +data dictionary (while the data files themselves are missing). +We will attempt to drop the tables here. */ +static void drop_garbage_tables_after_restore() +{ + btr_pcur_t pcur; + mtr_t mtr; + trx_t *trx= trx_create(); + + mtr.start(); + btr_pcur_open_at_index_side(true, dict_sys.sys_tables->indexes.start, + BTR_SEARCH_LEAF, &pcur, true, 0, &mtr); + for (;;) + { + btr_pcur_move_to_next_user_rec(&pcur, &mtr); + + if (!btr_pcur_is_on_user_rec(&pcur)) + break; + + const rec_t *rec= btr_pcur_get_rec(&pcur); + if (rec_get_deleted_flag(rec, 0)) + continue; + + static_assert(DICT_FLD__SYS_TABLES__NAME == 0, "compatibility"); + size_t len; + if (rec_get_1byte_offs_flag(rec)) + { + len= rec_1_get_field_end_info(rec, 0); + if (len & REC_1BYTE_SQL_NULL_MASK) + continue; /* corrupted SYS_TABLES.NAME */ + } + else + { + len= rec_2_get_field_end_info(rec, 0); + static_assert(REC_2BYTE_EXTERN_MASK == 16384, "compatibility"); + if (len >= REC_2BYTE_EXTERN_MASK) + continue; /* corrupted SYS_TABLES.NAME */ + } + + if (len < tmp_file_prefix_length) + continue; + if (const char *f= static_cast + (memchr(rec, '/', len - tmp_file_prefix_length))) + { + if (memcmp(f + 1, tmp_file_prefix, tmp_file_prefix_length)) + continue; + } + else + continue; + + btr_pcur_store_position(&pcur, &mtr); + btr_pcur_commit_specify_mtr(&pcur, &mtr); + + trx_start_for_ddl(trx); + std::vector deleted; + row_mysql_lock_data_dictionary(trx); + dberr_t err= DB_TABLE_NOT_FOUND; + + if (dict_table_t *table= dict_sys.load_table + ({reinterpret_cast(pcur.old_rec), len}, + DICT_ERR_IGNORE_DROP)) + { + ut_ad(table->stats_bg_flag == BG_STAT_NONE); + table->acquire(); + err= lock_table_for_trx(table, trx, LOCK_X); + if (err == DB_SUCCESS && + (table->flags2 & (DICT_TF2_FTS_HAS_DOC_ID | DICT_TF2_FTS))) + { + fts_optimize_remove_table(table); + err= fts_lock_tables(trx, *table); + } + table->release(); + + if (err == DB_SUCCESS) + err= trx->drop_table(*table); + if (err != DB_SUCCESS) + goto fail; + trx->commit(deleted); + } + else + { +fail: + trx->rollback(); + sql_print_error("InnoDB: cannot drop %.*s: %s", + static_cast(len), pcur.old_rec, ut_strerr(err)); + } + + row_mysql_unlock_data_dictionary(trx); + for (pfs_os_file_t d : deleted) + os_file_close(d); + + mtr.start(); + btr_pcur_restore_position(BTR_SEARCH_LEAF, &pcur, &mtr); + } + + btr_pcur_close(&pcur); + mtr.commit(); + trx->free(); +} + static void innodb_ddl_recovery_done(handlerton*) { ut_ad(!ddl_recovery_done); @@ -1961,6 +2067,8 @@ static void innodb_ddl_recovery_done(handlerton*) if (!srv_read_only_mode && srv_operation == SRV_OPERATION_NORMAL && srv_force_recovery < SRV_FORCE_NO_BACKGROUND) { + if (srv_start_after_restore && !high_level_read_only) + drop_garbage_tables_after_restore(); srv_init_purge_tasks(); purge_sys.coordinator_startup(); srv_wake_purge_thread_if_not_active(); diff --git a/storage/innobase/include/srv0srv.h b/storage/innobase/include/srv0srv.h index 41a0be0c5ff..3c22d8823e2 100644 --- a/storage/innobase/include/srv0srv.h +++ b/storage/innobase/include/srv0srv.h @@ -430,6 +430,9 @@ enum srv_operation_mode { /** Current mode of operation */ extern enum srv_operation_mode srv_operation; +/** whether this is the server's first start after mariabackup --prepare */ +extern bool srv_start_after_restore; + extern my_bool srv_print_innodb_monitor; extern my_bool srv_print_innodb_lock_monitor; extern ibool srv_print_verbose_log; diff --git a/storage/innobase/srv/srv0srv.cc b/storage/innobase/srv/srv0srv.cc index 1f2b05ecfa4..2bcd6c52935 100644 --- a/storage/innobase/srv/srv0srv.cc +++ b/storage/innobase/srv/srv0srv.cc @@ -370,6 +370,9 @@ ulonglong srv_defragment_interval; /** Current mode of operation */ enum srv_operation_mode srv_operation; +/** whether this is the server's first start after mariabackup --prepare */ +bool srv_start_after_restore; + /* Set the following to 0 if you want InnoDB to write messages on stderr on startup/shutdown. Not enabled on the embedded server. */ ibool srv_print_verbose_log; diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc index 9b51d225318..165a8e7f821 100644 --- a/storage/innobase/srv/srv0start.cc +++ b/storage/innobase/srv/srv0start.cc @@ -989,6 +989,9 @@ static dberr_t find_and_check_log_file(bool &log_file_found) if (is_operation_restore()) return DB_NOT_FOUND; + /* This might be first start after mariabackup + copy-back or move-back. */ + srv_start_after_restore= true; return DB_SUCCESS; } @@ -1019,7 +1022,9 @@ static dberr_t find_and_check_log_file(bool &log_file_found) header, checkpoint page 1, empty, checkpoint page 2, redo log page(s). Mariabackup --prepare would create an empty LOG_FILE_NAME. Tolerate it. */ - if (size != 0 && size <= OS_FILE_LOG_BLOCK_SIZE * 4) + if (size == 0) + srv_start_after_restore= true; + else if (size <= OS_FILE_LOG_BLOCK_SIZE * 4) { ib::error() << "Log file " << logfile0 << " size " << size << " is too small"; From cd1a195b22d2dac248228b6b7ecbd0a54997ecf7 Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Thu, 17 Jun 2021 16:10:11 +0530 Subject: [PATCH 102/251] MDEV-25947 innodb_fts.misc_debug fails in buildbot - Make innodb_fts.misc_debug test case more stable. --- mysql-test/suite/innodb_fts/r/misc_debug.result | 10 ++++------ mysql-test/suite/innodb_fts/t/misc_debug.test | 12 ++++-------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/mysql-test/suite/innodb_fts/r/misc_debug.result b/mysql-test/suite/innodb_fts/r/misc_debug.result index b162b2f7415..70b239bb189 100644 --- a/mysql-test/suite/innodb_fts/r/misc_debug.result +++ b/mysql-test/suite/innodb_fts/r/misc_debug.result @@ -31,19 +31,17 @@ DROP TABLE t2, t1; # CREATE TABLE t1(a INT, b TEXT, c TEXT, FULLTEXT INDEX(b)) ENGINE=InnoDB; connect con1,localhost,root,,test; -SET DEBUG_SYNC='innodb_inplace_alter_table_enter SIGNAL s1 WAIT_FOR g1'; +SET DEBUG_DBUG="+d,innodb_OOM_inplace_alter"; SET DEBUG_SYNC='innodb_commit_inplace_alter_table_enter SIGNAL s2 WAIT_FOR g2'; ALTER TABLE t1 ADD FULLTEXT(c); connection default; -SET DEBUG_SYNC='now WAIT_FOR s1'; -KILL QUERY @id; -SET DEBUG_SYNC='now SIGNAL g1 WAIT_FOR s2'; +SET DEBUG_SYNC='now WAIT_FOR s2'; START TRANSACTION; SELECT * FROM t1; a b c -SET DEBUG_SYNC='now SIGNAL s2'; +SET DEBUG_SYNC='now SIGNAL g2'; connection con1; -ERROR 70100: Query execution was interrupted +ERROR HY000: Out of memory; check if mysqld or some other process uses all available memory; if not, you may have to use 'ulimit' to allow mysqld to use more memory or you can add more swap space disconnect con1; connection default; SET DEBUG_SYNC=RESET; diff --git a/mysql-test/suite/innodb_fts/t/misc_debug.test b/mysql-test/suite/innodb_fts/t/misc_debug.test index 461e3f1d9d4..e42fc09bcd5 100644 --- a/mysql-test/suite/innodb_fts/t/misc_debug.test +++ b/mysql-test/suite/innodb_fts/t/misc_debug.test @@ -60,20 +60,16 @@ DROP TABLE t2, t1; --echo # CREATE TABLE t1(a INT, b TEXT, c TEXT, FULLTEXT INDEX(b)) ENGINE=InnoDB; connect(con1,localhost,root,,test); -let $ID= `SELECT @id := CONNECTION_ID()`; -SET DEBUG_SYNC='innodb_inplace_alter_table_enter SIGNAL s1 WAIT_FOR g1'; +SET DEBUG_DBUG="+d,innodb_OOM_inplace_alter"; SET DEBUG_SYNC='innodb_commit_inplace_alter_table_enter SIGNAL s2 WAIT_FOR g2'; send ALTER TABLE t1 ADD FULLTEXT(c); connection default; -SET DEBUG_SYNC='now WAIT_FOR s1'; -let $ignore= `SELECT @id := $ID`; -KILL QUERY @id; -SET DEBUG_SYNC='now SIGNAL g1 WAIT_FOR s2'; +SET DEBUG_SYNC='now WAIT_FOR s2'; START TRANSACTION; SELECT * FROM t1; -SET DEBUG_SYNC='now SIGNAL s2'; +SET DEBUG_SYNC='now SIGNAL g2'; connection con1; ---error ER_QUERY_INTERRUPTED +--error ER_OUT_OF_RESOURCES reap; disconnect con1; connection default; From 9370c6e83c148b4a5d4f08de7778e6a02da6adcb Mon Sep 17 00:00:00 2001 From: Dmitry Shulga Date: Thu, 22 Apr 2021 14:52:19 +0700 Subject: [PATCH 103/251] MDEV-16708: Unsupported commands for prepared statements Withing this task the following changes were made: - Added sending of metadata info in prepare phase for the admin related command (check table, checksum table, repair, optimize, analyze). - Refactored implmentation of HELP command to support its execution in PS mode - Added support for execution of LOAD INTO and XA- related statements in PS mode - Modified mysqltest.cc to run statements in PS mode unconditionally in case the option --ps-protocol is set. Formerly, only those statements were executed using PS protocol that matched the hard-coded regular expression - Fixed the following issues: The statement explain select (select 2) executed in regular and PS mode produces different results: MariaDB [test]> prepare stmt from "explain select (select 2)"; Query OK, 0 rows affected (0,000 sec) Statement prepared MariaDB [test]> execute stmt; +------+-------------+-------+------+---------------+------+---------+------+------+----------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +------+-------------+-------+------+---------------+------+---------+------+------+----------------+ | 1 | PRIMARY | NULL | NULL | NULL | NULL | NULL | NULL | NULL | No tables used | | 2 | SUBQUERY | NULL | NULL | NULL | NULL | NULL | NULL | NULL | No tables used | +------+-------------+-------+------+---------------+------+---------+------+------+----------------+ 2 rows in set (0,000 sec) MariaDB [test]> explain select (select 2); +------+-------------+-------+------+---------------+------+---------+------+------+----------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +------+-------------+-------+------+---------------+------+---------+------+------+----------------+ | 1 | SIMPLE | NULL | NULL | NULL | NULL | NULL | NULL | NULL | No tables used | +------+-------------+-------+------+---------------+------+---------+------+------+----------------+ 1 row in set, 1 warning (0,000 sec) In case the statement CREATE TABLE t1 SELECT * FROM (SELECT 1 AS a, (SELECT a+0)) a is run in PS mode it fails with the error ERROR 1054 (42S22): Unknown column 'a' in 'field list'. - Uniform handling of read-only variables both in case the SET var=val statement is executed as regular or prepared statememt. - Fixed assertion firing on handling LOAD DATA statement for temporary tables - Relaxed assert condition in the function lex_end_stage1() by adding the commands SQLCOM_ALTER_EVENT, SQLCOM_CREATE_PACKAGE, SQLCOM_CREATE_PACKAGE_BODY to a list of supported command - Removed raising of the error ER_UNSUPPORTED_PS in the function check_prepared_statement() for the ALTER VIEW command - Added initialization of the data memember st_select_lex_unit::last_procedure (assign NULL value) in the constructor Without this change the test case main.ctype_utf8 fails with the following report in case it is run with the optoin --ps-protocol. mysqltest: At line 2278: query 'VALUES (_latin1 0xDF) UNION VALUES(_utf8'a' COLLATE utf8_bin)' failed: 2013: Lost connection - The following bug reports were fixed: MDEV-24460: Multiple rows result set returned from stored routine over prepared statement binary protocol is handled incorrectly CONC-519: mariadb client library doesn't handle server_status and warnign_count fields received in the packet COM_STMT_EXECUTE_RESPONSE. Reasons for these bug reports have the same nature and caused by missing loop iteration on results sent by server in response to COM_STMT_EXECUTE packet. Enclosing of statements for processing of COM_STMT_EXECUTE response in the construct like do { ... } while (!mysql_stmt_next_result()); fixes the above mentioned bug reports. --- client/mysqltest.cc | 213 ++-- mysql-test/main/func_time.test | 4 +- mysql-test/main/get_diagnostics.result | 4 +- mysql-test/main/get_diagnostics.test | 4 +- mysql-test/main/ps.result | 24 +- mysql-test/main/ps.test | 33 +- mysql-test/main/ps_1general.result | 9 - mysql-test/main/ps_1general.test | 10 - mysql-test/main/ps_ddl.result | 2 - mysql-test/main/ps_ddl.test | 2 - mysql-test/main/ps_missed_cmds.result | 910 ++++++++++++++++++ mysql-test/main/ps_missed_cmds.test | 758 +++++++++++++++ .../main/ps_missed_cmds_bin_prot.result | 264 +++++ mysql-test/main/ps_missed_cmds_bin_prot.test | 298 ++++++ mysql-test/main/query_cache.result | 8 +- mysql-test/main/query_cache.test | 8 +- mysql-test/main/signal.result | 2 - mysql-test/main/signal.test | 3 - mysql-test/main/sp-dynamic.result | 16 +- mysql-test/main/sp-dynamic.test | 6 +- mysql-test/main/sp-security.result | 1 + mysql-test/main/sp-security.test | 1 + sql/item.cc | 7 +- sql/item_subselect.cc | 12 +- sql/protocol.h | 4 - sql/set_var.cc | 5 + sql/sql_admin.cc | 50 +- sql/sql_admin.h | 2 +- sql/sql_help.cc | 344 +++++-- sql/sql_help.h | 2 + sql/sql_lex.h | 2 +- sql/sql_load.cc | 9 + sql/sql_parse.cc | 4 +- sql/sql_parse.h | 2 +- sql/sql_prepare.cc | 225 ++++- sql/sql_table.cc | 36 +- sql/sql_table.h | 3 +- sql/xa.cc | 58 +- sql/xa.h | 3 + 39 files changed, 2965 insertions(+), 383 deletions(-) create mode 100644 mysql-test/main/ps_missed_cmds.result create mode 100644 mysql-test/main/ps_missed_cmds.test create mode 100644 mysql-test/main/ps_missed_cmds_bin_prot.result create mode 100644 mysql-test/main/ps_missed_cmds_bin_prot.test diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 8d3046faae0..fb36c4b075d 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -258,7 +258,6 @@ static const char *opt_suite_dir, *opt_overlay_dir; static size_t suite_dir_len, overlay_dir_len; /* Precompiled re's */ -static regex_t ps_re; /* the query can be run using PS protocol */ static regex_t sp_re; /* the query can be run as a SP */ static regex_t view_re; /* the query can be run as a view*/ @@ -8324,116 +8323,119 @@ void run_query_stmt(struct st_connection *cn, struct st_command *command, goto end; } - /* - When running in cursor_protocol get the warnings from execute here - and keep them in a separate string for later. - */ - if (cursor_protocol_enabled && !disable_warnings) - append_warnings(&ds_execute_warnings, mysql); - - /* - We instruct that we want to update the "max_length" field in - mysql_stmt_store_result(), this is our only way to know how much - buffer to allocate for result data - */ - { - my_bool one= 1; - if (mysql_stmt_attr_set(stmt, STMT_ATTR_UPDATE_MAX_LENGTH, (void*) &one)) - die("mysql_stmt_attr_set(STMT_ATTR_UPDATE_MAX_LENGTH) failed': %d %s", - mysql_stmt_errno(stmt), mysql_stmt_error(stmt)); - } - - /* - If we got here the statement succeeded and was expected to do so, - get data. Note that this can still give errors found during execution! - Store the result of the query if if will return any fields - */ - if (mysql_stmt_field_count(stmt) && mysql_stmt_store_result(stmt)) - { - handle_error(command, mysql_stmt_errno(stmt), - mysql_stmt_error(stmt), mysql_stmt_sqlstate(stmt), ds); - goto end; - } - - /* If we got here the statement was both executed and read successfully */ - handle_no_error(command); - if (!disable_result_log) + do { /* - Not all statements creates a result set. If there is one we can - now create another normal result set that contains the meta - data. This set can be handled almost like any other non prepared - statement result set. + When running in cursor_protocol get the warnings from execute here + and keep them in a separate string for later. + */ + if (cursor_protocol_enabled && !disable_warnings) + append_warnings(&ds_execute_warnings, mysql); + + /* + We instruct that we want to update the "max_length" field in + mysql_stmt_store_result(), this is our only way to know how much + buffer to allocate for result data */ - if ((res= mysql_stmt_result_metadata(stmt)) != NULL) { - /* Take the column count from meta info */ - MYSQL_FIELD *fields= mysql_fetch_fields(res); - uint num_fields= mysql_num_fields(res); - - if (display_metadata) - append_metadata(ds, fields, num_fields); - - if (!display_result_vertically) - append_table_headings(ds, fields, num_fields); - - append_stmt_result(ds, stmt, fields, num_fields); - - mysql_free_result(res); /* Free normal result set with meta data */ - - /* - Normally, if there is a result set, we do not show warnings from the - prepare phase. This is because some warnings are generated both during - prepare and execute; this would generate different warning output - between normal and ps-protocol test runs. - - The --enable_prepare_warnings command can be used to change this so - that warnings from both the prepare and execute phase are shown. - */ - if (!disable_warnings && !prepare_warnings_enabled) - dynstr_set(&ds_prepare_warnings, NULL); - } - else - { - /* - This is a query without resultset - */ + my_bool one= 1; + if (mysql_stmt_attr_set(stmt, STMT_ATTR_UPDATE_MAX_LENGTH, (void*) &one)) + die("mysql_stmt_attr_set(STMT_ATTR_UPDATE_MAX_LENGTH) failed': %d %s", + mysql_stmt_errno(stmt), mysql_stmt_error(stmt)); } /* - Fetch info before fetching warnings, since it will be reset - otherwise. + If we got here the statement succeeded and was expected to do so, + get data. Note that this can still give errors found during execution! + Store the result of the query if if will return any fields */ - if (!disable_info) - append_info(ds, mysql_stmt_affected_rows(stmt), mysql_info(mysql)); - - if (display_session_track_info) - append_session_track_info(ds, mysql); - - - if (!disable_warnings) + if (mysql_stmt_field_count(stmt) && mysql_stmt_store_result(stmt)) { - /* Get the warnings from execute */ + handle_error(command, mysql_stmt_errno(stmt), + mysql_stmt_error(stmt), mysql_stmt_sqlstate(stmt), ds); + goto end; + } - /* Append warnings to ds - if there are any */ - if (append_warnings(&ds_execute_warnings, mysql) || - ds_execute_warnings.length || - ds_prepare_warnings.length || - ds_warnings->length) + /* If we got here the statement was both executed and read successfully */ + handle_no_error(command); + if (!disable_result_log) + { + /* + Not all statements creates a result set. If there is one we can + now create another normal result set that contains the meta + data. This set can be handled almost like any other non prepared + statement result set. + */ + if ((res= mysql_stmt_result_metadata(stmt)) != NULL) { - dynstr_append_mem(ds, "Warnings:\n", 10); - if (ds_warnings->length) - dynstr_append_mem(ds, ds_warnings->str, - ds_warnings->length); - if (ds_prepare_warnings.length) - dynstr_append_mem(ds, ds_prepare_warnings.str, - ds_prepare_warnings.length); - if (ds_execute_warnings.length) - dynstr_append_mem(ds, ds_execute_warnings.str, - ds_execute_warnings.length); + /* Take the column count from meta info */ + MYSQL_FIELD *fields= mysql_fetch_fields(res); + uint num_fields= mysql_num_fields(res); + + if (display_metadata) + append_metadata(ds, fields, num_fields); + + if (!display_result_vertically) + append_table_headings(ds, fields, num_fields); + + append_stmt_result(ds, stmt, fields, num_fields); + + mysql_free_result(res); /* Free normal result set with meta data */ + + /* + Normally, if there is a result set, we do not show warnings from the + prepare phase. This is because some warnings are generated both during + prepare and execute; this would generate different warning output + between normal and ps-protocol test runs. + + The --enable_prepare_warnings command can be used to change this so + that warnings from both the prepare and execute phase are shown. + */ + if (!disable_warnings && !prepare_warnings_enabled) + dynstr_set(&ds_prepare_warnings, NULL); + } + else + { + /* + This is a query without resultset + */ + } + + /* + Fetch info before fetching warnings, since it will be reset + otherwise. + */ + if (!disable_info) + append_info(ds, mysql_stmt_affected_rows(stmt), mysql_info(mysql)); + + if (display_session_track_info) + append_session_track_info(ds, mysql); + + + if (!disable_warnings) + { + /* Get the warnings from execute */ + + /* Append warnings to ds - if there are any */ + if (append_warnings(&ds_execute_warnings, mysql) || + ds_execute_warnings.length || + ds_prepare_warnings.length || + ds_warnings->length) + { + dynstr_append_mem(ds, "Warnings:\n", 10); + if (ds_warnings->length) + dynstr_append_mem(ds, ds_warnings->str, + ds_warnings->length); + if (ds_prepare_warnings.length) + dynstr_append_mem(ds, ds_prepare_warnings.str, + ds_prepare_warnings.length); + if (ds_execute_warnings.length) + dynstr_append_mem(ds, ds_execute_warnings.str, + ds_execute_warnings.length); + } } } - } + } while ( !mysql_stmt_next_result(stmt)); end: if (!disable_warnings) @@ -8719,8 +8721,7 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags) statement already and we can't do it twice */ if (ps_protocol_enabled && - complete_query && - match_re(&ps_re, query)) + complete_query) run_query_stmt(cn, command, query, query_len, ds, &ds_warnings); else run_query_normal(cn, command, flags, query, query_len, @@ -8795,9 +8796,9 @@ void init_re(void) { /* Filter for queries that can be run using the - MySQL Prepared Statements C API + Stored procedures */ - const char *ps_re_str = + const char *sp_re_str = "^(" "[[:space:]]*ALTER[[:space:]]+SEQUENCE[[:space:]]|" "[[:space:]]*ALTER[[:space:]]+TABLE[[:space:]]|" @@ -8850,12 +8851,6 @@ void init_re(void) "[[:space:]]*UPDATE[[:space:]]" ")"; - /* - Filter for queries that can be run using the - Stored procedures - */ - const char *sp_re_str =ps_re_str; - /* Filter for queries that can be run as views */ @@ -8863,7 +8858,6 @@ void init_re(void) "^(" "[[:space:]]*SELECT[[:space:]])"; - init_re_comp(&ps_re, ps_re_str); init_re_comp(&sp_re, sp_re_str); init_re_comp(&view_re, view_re_str); } @@ -8899,7 +8893,6 @@ int match_re(regex_t *re, char *str) void free_re(void) { - regfree(&ps_re); regfree(&sp_re); regfree(&view_re); } diff --git a/mysql-test/main/func_time.test b/mysql-test/main/func_time.test index 970d3e44a77..ccec4d18ea3 100644 --- a/mysql-test/main/func_time.test +++ b/mysql-test/main/func_time.test @@ -621,8 +621,10 @@ SET GLOBAL log_bin_trust_function_creators = 1; create table t1 (a timestamp default '2005-05-05 01:01:01', b timestamp default '2005-05-05 01:01:01'); -delimiter //; +--disable_warnings drop function if exists t_slow_sysdate; +--enable_warnings +delimiter //; create function t_slow_sysdate() returns timestamp begin do sleep(2); diff --git a/mysql-test/main/get_diagnostics.result b/mysql-test/main/get_diagnostics.result index bcecce95a00..fbd25dc603c 100644 --- a/mysql-test/main/get_diagnostics.result +++ b/mysql-test/main/get_diagnostics.result @@ -258,12 +258,10 @@ DROP PROCEDURE p1; # Test GET DIAGNOSTICS runtime # -# GET DIAGNOSTICS cannot be the object of a PREPARE statement. +# GET DIAGNOSTICS can be the object of a PREPARE statement. PREPARE stmt FROM "GET DIAGNOSTICS CONDITION 1 @var = CLASS_ORIGIN"; -ERROR HY000: This command is not supported in the prepared statement protocol yet PREPARE stmt FROM "GET DIAGNOSTICS @var = NUMBER"; -ERROR HY000: This command is not supported in the prepared statement protocol yet # GET DIAGNOSTICS does not clear the diagnostics area. diff --git a/mysql-test/main/get_diagnostics.test b/mysql-test/main/get_diagnostics.test index 4667ec727dd..d9faf184a62 100644 --- a/mysql-test/main/get_diagnostics.test +++ b/mysql-test/main/get_diagnostics.test @@ -331,12 +331,10 @@ DROP PROCEDURE p1; --echo # --echo ---echo # GET DIAGNOSTICS cannot be the object of a PREPARE statement. +--echo # GET DIAGNOSTICS can be the object of a PREPARE statement. --echo ---error ER_UNSUPPORTED_PS PREPARE stmt FROM "GET DIAGNOSTICS CONDITION 1 @var = CLASS_ORIGIN"; ---error ER_UNSUPPORTED_PS PREPARE stmt FROM "GET DIAGNOSTICS @var = NUMBER"; --echo diff --git a/mysql-test/main/ps.result b/mysql-test/main/ps.result index c1334b0b9a7..70ea6870368 100644 --- a/mysql-test/main/ps.result +++ b/mysql-test/main/ps.result @@ -28,11 +28,9 @@ ERROR HY000: Unknown prepared statement handler (no_such_statement) given to DEA execute stmt1; ERROR HY000: Incorrect arguments to EXECUTE prepare stmt2 from 'prepare nested_stmt from "select 1"'; -ERROR HY000: This command is not supported in the prepared statement protocol yet prepare stmt2 from 'execute stmt1'; -ERROR HY000: This command is not supported in the prepared statement protocol yet prepare stmt2 from 'deallocate prepare z'; -ERROR HY000: This command is not supported in the prepared statement protocol yet +deallocate prepare stmt2; prepare stmt3 from 'insert into t1 values (?,?)'; set @arg1=5, @arg2='five'; execute stmt3 using @arg1, @arg2; @@ -2726,9 +2724,7 @@ ERROR 42000: FUNCTION test.func_1 does not exist drop function func_1; ERROR 42000: FUNCTION test.func_1 does not exist prepare abc from "create event xyz on schedule at now() do select 123"; -ERROR HY000: This command is not supported in the prepared statement protocol yet deallocate prepare abc; -ERROR HY000: Unknown prepared statement handler (abc) given to DEALLOCATE PREPARE drop event if exists xyz; create event xyz on schedule every 5 minute disable do select 123; create procedure proc_1() alter event xyz comment 'xyz'; @@ -2748,9 +2744,7 @@ drop procedure proc_1; create function func_1() returns int begin alter event xyz comment 'xyz'; return 1; end| ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger prepare abc from "alter event xyz comment 'xyz'"; -ERROR HY000: This command is not supported in the prepared statement protocol yet deallocate prepare abc; -ERROR HY000: Unknown prepared statement handler (abc) given to DEALLOCATE PREPARE drop event if exists xyz; create event xyz on schedule every 5 minute disable do select 123; create procedure proc_1() drop event xyz; @@ -2765,9 +2759,7 @@ drop procedure proc_1; create function func_1() returns int begin drop event xyz; return 1; end| ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger prepare abc from "drop event xyz"; -ERROR HY000: This command is not supported in the prepared statement protocol yet deallocate prepare abc; -ERROR HY000: Unknown prepared statement handler (abc) given to DEALLOCATE PREPARE drop table if exists t1; create table t1 (a int, b char(5)) engine=myisam; insert into t1 values (1, "one"), (2, "two"), (3, "three"); @@ -3087,15 +3079,15 @@ DROP TABLE t1; CREATE TABLE t1(f1 INT); INSERT INTO t1 VALUES (1),(1); PREPARE stmt FROM 'EXPLAIN SELECT 1 FROM t1 WHERE (SELECT (SELECT 1 FROM t1 GROUP BY f1))'; +Warnings: +Note 1249 Select 2 was reduced during optimization EXECUTE stmt; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 -2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used 3 SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort EXECUTE stmt; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 -2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used 3 SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort DEALLOCATE PREPARE stmt; DROP TABLE t1; @@ -4727,13 +4719,13 @@ ERROR HY000: Incorrect arguments to EXECUTE EXECUTE IMMEDIATE 'SELECT ?'; ERROR HY000: Incorrect arguments to EXECUTE EXECUTE IMMEDIATE 'EXECUTE IMMEDIATE "SELECT 1"'; -ERROR HY000: This command is not supported in the prepared statement protocol yet +1 +1 EXECUTE IMMEDIATE 'PREPARE stmt FROM "SELECT 1"'; -ERROR HY000: This command is not supported in the prepared statement protocol yet EXECUTE IMMEDIATE 'EXECUTE stmt'; -ERROR HY000: This command is not supported in the prepared statement protocol yet +1 +1 EXECUTE IMMEDIATE 'DEALLOCATE PREPARE stmt'; -ERROR HY000: This command is not supported in the prepared statement protocol yet EXECUTE IMMEDIATE 'SELECT ?' USING _latin1'a'=_latin2'a'; ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2_general_ci,COERCIBLE) for operation '=' EXECUTE IMMEDIATE 'SELECT ?' USING ROW(1,2); @@ -4944,7 +4936,7 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp PREPARE stmt FROM CONCAT(NULL); ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'NULL' at line 1 EXECUTE IMMEDIATE ? USING 'SELECT 1'; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '? USING 'SELECT 1'' at line 1 +Got one of the listed errors EXECUTE IMMEDIATE 10; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '10' at line 1 EXECUTE IMMEDIATE TIME'10:20:30'; diff --git a/mysql-test/main/ps.test b/mysql-test/main/ps.test index 837fa6f2b6e..5933aea4a03 100644 --- a/mysql-test/main/ps.test +++ b/mysql-test/main/ps.test @@ -37,15 +37,11 @@ deallocate prepare no_such_statement; --error 1210 execute stmt1; -# Nesting ps commands is not allowed: ---error ER_UNSUPPORTED_PS +# Nesting ps commands is now allowed: prepare stmt2 from 'prepare nested_stmt from "select 1"'; - ---error ER_UNSUPPORTED_PS prepare stmt2 from 'execute stmt1'; - ---error ER_UNSUPPORTED_PS prepare stmt2 from 'deallocate prepare z'; +deallocate prepare stmt2; # PS insert prepare stmt3 from 'insert into t1 values (?,?)'; @@ -2763,11 +2759,10 @@ delimiter ;| select func_1(), func_1(), func_1() from dual; --error ER_SP_DOES_NOT_EXIST drop function func_1; ---error ER_UNSUPPORTED_PS -prepare abc from "create event xyz on schedule at now() do select 123"; ---error ER_UNKNOWN_STMT_HANDLER -deallocate prepare abc; +# CREATE EVENT is now supported by prepared statements +prepare abc from "create event xyz on schedule at now() do select 123"; +deallocate prepare abc; --disable_warnings drop event if exists xyz; @@ -2787,9 +2782,9 @@ delimiter |; --error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG create function func_1() returns int begin alter event xyz comment 'xyz'; return 1; end| delimiter ;| ---error ER_UNSUPPORTED_PS + +# ALTER EVENT is now supported by prepared statements prepare abc from "alter event xyz comment 'xyz'"; ---error ER_UNKNOWN_STMT_HANDLER deallocate prepare abc; @@ -2808,9 +2803,8 @@ delimiter |; --error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG create function func_1() returns int begin drop event xyz; return 1; end| delimiter ;| ---error ER_UNSUPPORTED_PS +# DROP EVENT is now supported by prepared statements prepare abc from "drop event xyz"; ---error ER_UNKNOWN_STMT_HANDLER deallocate prepare abc; @@ -4199,16 +4193,12 @@ EXECUTE IMMEDIATE 'SELECT 1' USING @a; --error ER_WRONG_ARGUMENTS EXECUTE IMMEDIATE 'SELECT ?'; ---error ER_UNSUPPORTED_PS EXECUTE IMMEDIATE 'EXECUTE IMMEDIATE "SELECT 1"'; ---error ER_UNSUPPORTED_PS EXECUTE IMMEDIATE 'PREPARE stmt FROM "SELECT 1"'; ---error ER_UNSUPPORTED_PS EXECUTE IMMEDIATE 'EXECUTE stmt'; ---error ER_UNSUPPORTED_PS EXECUTE IMMEDIATE 'DEALLOCATE PREPARE stmt'; --error ER_CANT_AGGREGATE_2COLLATIONS @@ -4414,7 +4404,12 @@ EXECUTE IMMEDIATE CONCAT(NULL); --error ER_PARSE_ERROR PREPARE stmt FROM CONCAT(NULL); ---error ER_PARSE_ERROR +# Expects any of the following errors CR_PARAMS_NOT_BOUND, ER_PARSE_ERROR. +# ER_PARSE_ERROR is generated in case the EXECUTE IMMEDIATE statement +# is sent as a regular statement via text protocol. The error +# CR_PARAMS_NOT_BOUND is generated by the MySQL API function mysql_stmt_execute +# when this test file is run with the option --ps-protocol +--error 2031,ER_PARSE_ERROR EXECUTE IMMEDIATE ? USING 'SELECT 1'; --error ER_PARSE_ERROR diff --git a/mysql-test/main/ps_1general.result b/mysql-test/main/ps_1general.result index 149c297621b..c42b3d07bbc 100644 --- a/mysql-test/main/ps_1general.result +++ b/mysql-test/main/ps_1general.result @@ -381,15 +381,10 @@ drop table t5 ; deallocate prepare stmt_do ; deallocate prepare stmt_set ; prepare stmt1 from ' prepare stmt2 from '' select 1 '' ' ; -ERROR HY000: This command is not supported in the prepared statement protocol yet prepare stmt1 from ' execute stmt2 ' ; -ERROR HY000: This command is not supported in the prepared statement protocol yet prepare stmt1 from ' deallocate prepare never_prepared ' ; -ERROR HY000: This command is not supported in the prepared statement protocol yet prepare stmt1 from 'alter view v1 as select 2'; -ERROR HY000: This command is not supported in the prepared statement protocol yet prepare stmt4 from ' use test ' ; -ERROR HY000: This command is not supported in the prepared statement protocol yet prepare stmt3 from ' create database mysqltest '; create database mysqltest ; prepare stmt3 from ' drop database mysqltest '; @@ -403,12 +398,9 @@ drop table t2 ; execute stmt3; ERROR 42S02: Table 'test.t2' doesn't exist prepare stmt3 from ' lock tables t1 read ' ; -ERROR HY000: This command is not supported in the prepared statement protocol yet prepare stmt3 from ' unlock tables ' ; -ERROR HY000: This command is not supported in the prepared statement protocol yet prepare stmt1 from ' load data infile ''/tmp/data.txt'' into table t1 fields terminated by ''\t'' '; -ERROR HY000: This command is not supported in the prepared statement protocol yet prepare stmt1 from ' select * into outfile ''/tmp/data.txt'' from t1 '; execute stmt1 ; prepare stmt1 from ' optimize table t1 ' ; @@ -416,7 +408,6 @@ prepare stmt1 from ' analyze table t1 ' ; prepare stmt1 from ' checksum table t1 ' ; prepare stmt1 from ' repair table t1 ' ; prepare stmt1 from ' handler t1 open '; -ERROR HY000: This command is not supported in the prepared statement protocol yet prepare stmt3 from ' commit ' ; prepare stmt3 from ' rollback ' ; prepare stmt4 from ' SET sql_mode=ansi '; diff --git a/mysql-test/main/ps_1general.test b/mysql-test/main/ps_1general.test index 47db79cb6c6..f98c05a69fb 100644 --- a/mysql-test/main/ps_1general.test +++ b/mysql-test/main/ps_1general.test @@ -406,19 +406,13 @@ deallocate prepare stmt_do ; deallocate prepare stmt_set ; ## nonsense like prepare of prepare,execute or deallocate ---error ER_UNSUPPORTED_PS prepare stmt1 from ' prepare stmt2 from '' select 1 '' ' ; ---error ER_UNSUPPORTED_PS prepare stmt1 from ' execute stmt2 ' ; ---error ER_UNSUPPORTED_PS prepare stmt1 from ' deallocate prepare never_prepared ' ; -## We don't support alter view as prepared statements ---error ER_UNSUPPORTED_PS prepare stmt1 from 'alter view v1 as select 2'; ## switch the database connection ---error ER_UNSUPPORTED_PS prepare stmt4 from ' use test ' ; ## create/drop database @@ -435,9 +429,7 @@ drop table t2 ; --error ER_NO_SUCH_TABLE execute stmt3; ## lock/unlock ---error ER_UNSUPPORTED_PS prepare stmt3 from ' lock tables t1 read ' ; ---error ER_UNSUPPORTED_PS prepare stmt3 from ' unlock tables ' ; ## Load/Unload table contents @@ -446,7 +438,6 @@ prepare stmt3 from ' unlock tables ' ; --remove_file $datafile --replace_result $MYSQLTEST_VARDIR ---error ER_UNSUPPORTED_PS eval prepare stmt1 from ' load data infile ''$datafile'' into table t1 fields terminated by ''\t'' '; --replace_result $MYSQLTEST_VARDIR @@ -461,7 +452,6 @@ prepare stmt1 from ' repair table t1 ' ; --remove_file $datafile ## handler ---error ER_UNSUPPORTED_PS prepare stmt1 from ' handler t1 open '; diff --git a/mysql-test/main/ps_ddl.result b/mysql-test/main/ps_ddl.result index 86a294b732d..d99aeb0fa54 100644 --- a/mysql-test/main/ps_ddl.result +++ b/mysql-test/main/ps_ddl.result @@ -2244,7 +2244,6 @@ SUCCESS drop table if exists t1; create table t1 (a varchar(20)); prepare stmt from "load data infile '../std_data_ln/words.dat' into table t1"; -ERROR HY000: This command is not supported in the prepared statement protocol yet drop table t1; # # SQLCOM_SHOW_DATABASES @@ -2516,7 +2515,6 @@ SUCCESS drop view if exists v1; create view v1 as select 1; prepare stmt from "alter view v1 as select 2"; -ERROR HY000: This command is not supported in the prepared statement protocol yet drop view v1; # Cleanup # diff --git a/mysql-test/main/ps_ddl.test b/mysql-test/main/ps_ddl.test index 694ee61fd0c..5a2a0f60a70 100644 --- a/mysql-test/main/ps_ddl.test +++ b/mysql-test/main/ps_ddl.test @@ -1880,7 +1880,6 @@ call p_verify_reprepare_count(8); drop table if exists t1; --enable_warnings create table t1 (a varchar(20)); ---error ER_UNSUPPORTED_PS prepare stmt from "load data infile '../std_data_ln/words.dat' into table t1"; drop table t1; @@ -2202,7 +2201,6 @@ call p_verify_reprepare_count(17); drop view if exists v1; --enable_warnings create view v1 as select 1; ---error ER_UNSUPPORTED_PS prepare stmt from "alter view v1 as select 2"; drop view v1; diff --git a/mysql-test/main/ps_missed_cmds.result b/mysql-test/main/ps_missed_cmds.result new file mode 100644 index 00000000000..f16cae445fb --- /dev/null +++ b/mysql-test/main/ps_missed_cmds.result @@ -0,0 +1,910 @@ +SET @save_storage_engine= @@default_storage_engine; +SET default_storage_engine= InnoDB; +# +# MDEV-16708: Unsupported commands for prepared statements +# +# Disable ps-protocol explicitly in order to test support of +# prepared statements for use case when statements passed +# to the server via text client-server protocol (in contrast +# with binary protocol used in the test file +# ps_missed_cmds_bin_prot.test) +# Test case 1: Check that the statement 'LOAD DATA' is supported +# by prepared statements +# First, set up environment for use by the 'LOAD DATA' statement +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1); +COMMIT; +SELECT * INTO OUTFILE 'load.data' FROM t1; +PREPARE stmt_1 FROM "LOAD DATA INFILE 'load.data' INTO TABLE t1"; +EXECUTE stmt_1; +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the 'LOAD DATA' statement +# were damaged. +EXECUTE stmt_1; +SELECT * FROM t1; +a +1 +1 +1 +# Clean up +DEALLOCATE PREPARE stmt_1; +DROP TABLE t1; +# Test case 2: Check that the 'LOCK TABLE', 'UNLOCK TABLES' statements +# are supported by prepared statements +CREATE TABLE t1 (a INT); +PREPARE stmt_1 FROM "LOCK TABLE t1 READ"; +EXECUTE stmt_1; +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the 'LOCK TABLE READ' +# statement were damaged. +EXECUTE stmt_1; +PREPARE stmt_1 FROM "UNLOCK TABLE"; +EXECUTE stmt_1; +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the 'UNLOCK TABLE' statement +# were damaged. +EXECUTE stmt_1; +PREPARE stmt_1 FROM "LOCK TABLE t1 WRITE"; +EXECUTE stmt_1; +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the 'LOCK TABLE WRITE' +# statement were damaged. +EXECUTE stmt_1; +# Clean up +DEALLOCATE PREPARE stmt_1; +UNLOCK TABLE; +DROP TABLE t1; +# Test case 3: Check that the 'USE' statement is supported by +# prepared statements +CREATE DATABASE mdev_16708_db; +PREPARE stmt_1 FROM 'USE mdev_16708_db'; +EXECUTE stmt_1; +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the 'USE' statement +# were damaged. +EXECUTE stmt_1; +# Check that the current database has been changed +SELECT DATABASE(); +DATABASE() +mdev_16708_db +# Clean up +DEALLOCATE PREPARE stmt_1; +USE test; +DROP DATABASE mdev_16708_db; +# Test case 4: Check that the 'ALTER DATABASE' statement is supported +# by prepared statements +CREATE DATABASE mdev_16708_db; +PREPARE stmt_1 FROM "ALTER DATABASE mdev_16708_db COMMENT 'New comment'"; +EXECUTE stmt_1; +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the 'ALTER DATABASE' statement +# were damaged. +EXECUTE stmt_1; +# Clean up +DEALLOCATE PREPARE stmt_1; +USE test; +DROP DATABASE mdev_16708_db; +# Test case 5: Check that the 'CREATE FUNCTION/ALTER FUNCTION/ +# DROP FUNCTION' statements are supported by prepared statements +PREPARE stmt_1 FROM 'CREATE FUNCTION f1() RETURNS INT RETURN 1'; +EXECUTE stmt_1; +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the 'CREATE FUNCTION' +# statement were damaged. The second attempt to execute the prepared +# statement stmt_1 results in error ER_SP_ALREADY_EXISTS since +# the stored function f() has been created on first run of stmt1. +EXECUTE stmt_1; +ERROR 42000: FUNCTION f1 already exists +PREPARE stmt_1 FROM 'ALTER FUNCTION f1 SQL SECURITY INVOKER'; +EXECUTE stmt_1; +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the 'ALTER FUNCTION' +# statement were damaged. +EXECUTE stmt_1; +PREPARE stmt_1 FROM 'DROP FUNCTION f1'; +EXECUTE stmt_1; +# Execute the same prepared statement the second time to check that +# no internal structures used for handling 'DROP FUNCTION' statement +# were damaged. The second attempt to run 'DROP FUNCTION f1' using +# prepared statement expectedly results in issuing the error +# ER_SP_DOES_NOT_EXIST since the stored function was dropped on first +# executuon of the prepared statement stmt_1. +EXECUTE stmt_1; +ERROR 42000: FUNCTION test.f1 does not exist +# Test case 6: Check that the 'CHECK TABLE' statement is supported +# by prepared statements +CREATE TABLE t1 (a INT); +PREPARE stmt_1 FROM 'CHECK TABLE t1'; +EXECUTE stmt_1; +Table Op Msg_type Msg_text +test.t1 check status OK +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the 'CHECK TABLE' statement +# were damaged. +EXECUTE stmt_1; +Table Op Msg_type Msg_text +test.t1 check status OK +# Clean up +DEALLOCATE PREPARE stmt_1; +DROP TABLE t1; +# Test case 7: Check that the BEGIN/SAVEPOINT/RELEASE SAVEPOINT +# statements are supported by prepared statements +# Set up environmentr for the test case +CREATE TABLE t1 (a INT); +PREPARE stmt_1 FROM 'BEGIN'; +EXECUTE stmt_1; +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the 'BEGIN' statement +# were damaged. +EXECUTE stmt_1; +INSERT INTO t1 VALUES (1); +# Run 'SAVEPOINT s1' using prepared statements +PREPARE stmt_2 FROM 'SAVEPOINT s1'; +EXECUTE stmt_2; +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the 'SAVEPOINT' statement +# were damaged. +EXECUTE stmt_2; +INSERT INTO t1 VALUES (2); +# Expected rows: '1' and '2' +SELECT * FROM t1; +a +1 +2 +# Rollback the last row inserted ('2') +ROLLBACK TO SAVEPOINT s1; +# Expected output from t1 after transaction has been rolled back +# to the savepoint is '1'. If it is case then the statement SAVEPOINT +# was handled successfully with prepared statement +SELECT * FROM t1; +a +1 +PREPARE stmt_3 FROM 'RELEASE SAVEPOINT s1'; +EXECUTE stmt_3; +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the 'RELEASE' statement +# were damaged. The second attempt to release the same savepoint +# expectedly lead to error 'SAVEPOINT s1 does not exist' +# that's just ignored. +EXECUTE stmt_3; +ERROR 42000: SAVEPOINT s1 does not exist +# Clean up +DEALLOCATE PREPARE stmt_1; +DEALLOCATE PREPARE stmt_2; +DEALLOCATE PREPARE stmt_3; +DROP TABLE t1; +# Test case 8: Check that the 'PURGE BINARY LOGS BEFORE' statement +# is supported by prepared statements +PREPARE stmt_1 FROM "PURGE BINARY LOGS BEFORE '2020-11-17'"; +EXECUTE stmt_1; +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the 'PURGE BINARY LOGS BEFORE' +# statement were damaged. +EXECUTE stmt_1; +# Check that the 'PURGE BINARY LOGS TO' statement is supported by +# prepared statements +PREPARE stmt_1 FROM "PURGE BINARY LOGS TO 'mariadb-bin.000063'"; +EXECUTE stmt_1; +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the 'PURGE BINARY LOGS TO' +# statement were damaged. +EXECUTE stmt_1; +# Test case 9: Check that the 'HANDLER OPEN/HANDLER READ/ +# HANDLER CLOSE' statements are supported by prepared statements +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (1); +COMMIT; +PREPARE stmt_1 FROM 'HANDLER t1 OPEN'; +EXECUTE stmt_1; +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the 'HANDLER OPEN' +# statement were damaged. Execution of this statement the second +# time expectedly results in emitting the error ER_NONUNIQ_TABLE. +# The same error is issued in case the statement 'HANDLER t1 OPEN' is +# executed twice using a regular statement. +EXECUTE stmt_1; +ERROR 42000: Not unique table/alias: 't1' +PREPARE stmt_2 FROM 'HANDLER t1 READ FIRST'; +PREPARE stmt_3 FROM 'HANDLER t1 READ NEXT'; +PREPARE stmt_4 FROM 'HANDLER t1 CLOSE'; +EXECUTE stmt_2; +a +1 +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the 'HANDLER READ FIRST' +# statement were damaged. +EXECUTE stmt_2; +a +1 +EXECUTE stmt_3; +a +1 +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the 'HANDLER READ NEXT' +# statement were damaged. +EXECUTE stmt_3; +a +EXECUTE stmt_4; +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the 'HANDLER CLOSE' +# statement were damaged. Execution of this statement the second +# time results in emitting the error ER_UNKNOWN_TABLE. The same error +# is issued in case the statement 'HANDLER t1 CLOSE' executed twice +# using a regular statement. +EXECUTE stmt_4; +ERROR 42S02: Unknown table 't1' in HANDLER +# Clean up +DEALLOCATE PREPARE stmt_1; +DEALLOCATE PREPARE stmt_2; +DEALLOCATE PREPARE stmt_3; +DEALLOCATE PREPARE stmt_4; +DROP TABLE t1; +# Test case 10: Check that the HELP statement +# is supported by prepared statements +PREPARE stmt_1 FROM "HELP `UPDATE`"; +EXECUTE stmt_1; +name description example +UPDATE Syntax +------ +Single-table syntax: + +UPDATE [LOW_PRIORITY] [IGNORE] table_reference + [PARTITION (partition_list)] + SET col1={expr1|DEFAULT} [,col2={expr2|DEFAULT}] ... + [WHERE where_condition] + [ORDER BY ...] + [LIMIT row_count] + +Multiple-table syntax: + +UPDATE [LOW_PRIORITY] [IGNORE] table_references + SET col1={expr1|DEFAULT} [, col2={expr2|DEFAULT}] ... + [WHERE where_condition] + +Description +----------- +For the single-table syntax, the UPDATE statement updates +columns of existing rows in the named table with new values. +The +SET clause indicates which columns to modify and the values +they should be given. Each value can be given as an +expression, or the keyword +DEFAULT to set a column explicitly to its default value. The +WHERE clause, if given, specifies the conditions that +identify +which rows to update. With no WHERE clause, all rows are +updated. If the ORDER BY clause is specified, the rows are +updated in the order that is specified. The LIMIT clause +places a limit on the number of rows that can be updated. + +The PARTITION clause was introduced in MariaDB 10.0. See +Partition Pruning and Selection for details. + +Until MariaDB 10.3.2, for the multiple-table syntax, UPDATE +updates rows in each +table named in table_references that satisfy the conditions. +In this case, +ORDER BY and LIMIT cannot be used. This restriction was +lifted in MariaDB 10.3.2 and both clauses can be used with +multiple-table updates. An UPDATE can also reference tables +which are located in different databases; see Identifier +Qualifiers for the syntax. + +where_condition is an expression that evaluates to true for +each row to be updated. + +table_references and where_condition are as +specified as described in SELECT. + +Assignments are evaluated in left-to-right order, unless the +SIMULTANEOUS_ASSIGNMENT sql_mode (available from MariaDB +10.3.5) is set, in which case the UPDATE statement evaluates +all assignments simultaneously. + +You need the UPDATE privilege only for columns referenced in +an UPDATE that are actually updated. You need only the +SELECT privilege for any columns that are read but +not modified. See GRANT. + +The UPDATE statement supports the following modifiers: +If you use the LOW_PRIORITY keyword, execution of + the UPDATE is delayed until no other clients are reading +from + the table. This affects only storage engines that use only +table-level + locking (MyISAM, MEMORY, MERGE). See HIGH_PRIORITY and +LOW_PRIORITY clauses for details. +If you use the IGNORE keyword, the update statement does + not abort even if errors occur during the update. Rows for +which + duplicate-key conflicts occur are not updated. Rows for +which columns are + updated to values that would cause data conversion errors +are updated to the + closest valid values instead. + +UPDATE Statements With the Same Source and Target + +From MariaDB 10.3.2, UPDATE statements may have the same +source and target. + +For example, given the following table: + +DROP TABLE t1; + +CREATE TABLE t1 (c1 INT, c2 INT); +INSERT INTO t1 VALUES (10,10), (20,20); + +Until MariaDB 10.3.1, the following UPDATE statement would +not work: + +UPDATE t1 SET c1=c1+1 WHERE c2=(SELECT MAX(c2) FROM t1); +ERROR 1093 (HY000): Table 't1' is specified twice, + both as a target for 'UPDATE' and as a separate source +for data + +From MariaDB 10.3.2, the statement executes successfully: + +UPDATE t1 SET c1=c1+1 WHERE c2=(SELECT MAX(c2) FROM t1); + +SELECT * FROM t1; + ++------+------+ +| c1 | c2 | ++------+------+ +| 10 | 10 | +| 21 | 20 | ++------+------+ + +Example + +Single-table syntax: + +UPDATE table_name SET column1 = value1, column2 = value2 +WHERE id=100; + +Multiple-table syntax: + +UPDATE tab1, tab2 SET tab1.column1 = value1, tab1.column2 = +value2 WHERE tab1.id = tab2.id; + + + +URL: https://mariadb.com/kb/en/library/update/ +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the 'HELP' statement +# were damaged. +EXECUTE stmt_1; +name description example +UPDATE Syntax +------ +Single-table syntax: + +UPDATE [LOW_PRIORITY] [IGNORE] table_reference + [PARTITION (partition_list)] + SET col1={expr1|DEFAULT} [,col2={expr2|DEFAULT}] ... + [WHERE where_condition] + [ORDER BY ...] + [LIMIT row_count] + +Multiple-table syntax: + +UPDATE [LOW_PRIORITY] [IGNORE] table_references + SET col1={expr1|DEFAULT} [, col2={expr2|DEFAULT}] ... + [WHERE where_condition] + +Description +----------- +For the single-table syntax, the UPDATE statement updates +columns of existing rows in the named table with new values. +The +SET clause indicates which columns to modify and the values +they should be given. Each value can be given as an +expression, or the keyword +DEFAULT to set a column explicitly to its default value. The +WHERE clause, if given, specifies the conditions that +identify +which rows to update. With no WHERE clause, all rows are +updated. If the ORDER BY clause is specified, the rows are +updated in the order that is specified. The LIMIT clause +places a limit on the number of rows that can be updated. + +The PARTITION clause was introduced in MariaDB 10.0. See +Partition Pruning and Selection for details. + +Until MariaDB 10.3.2, for the multiple-table syntax, UPDATE +updates rows in each +table named in table_references that satisfy the conditions. +In this case, +ORDER BY and LIMIT cannot be used. This restriction was +lifted in MariaDB 10.3.2 and both clauses can be used with +multiple-table updates. An UPDATE can also reference tables +which are located in different databases; see Identifier +Qualifiers for the syntax. + +where_condition is an expression that evaluates to true for +each row to be updated. + +table_references and where_condition are as +specified as described in SELECT. + +Assignments are evaluated in left-to-right order, unless the +SIMULTANEOUS_ASSIGNMENT sql_mode (available from MariaDB +10.3.5) is set, in which case the UPDATE statement evaluates +all assignments simultaneously. + +You need the UPDATE privilege only for columns referenced in +an UPDATE that are actually updated. You need only the +SELECT privilege for any columns that are read but +not modified. See GRANT. + +The UPDATE statement supports the following modifiers: +If you use the LOW_PRIORITY keyword, execution of + the UPDATE is delayed until no other clients are reading +from + the table. This affects only storage engines that use only +table-level + locking (MyISAM, MEMORY, MERGE). See HIGH_PRIORITY and +LOW_PRIORITY clauses for details. +If you use the IGNORE keyword, the update statement does + not abort even if errors occur during the update. Rows for +which + duplicate-key conflicts occur are not updated. Rows for +which columns are + updated to values that would cause data conversion errors +are updated to the + closest valid values instead. + +UPDATE Statements With the Same Source and Target + +From MariaDB 10.3.2, UPDATE statements may have the same +source and target. + +For example, given the following table: + +DROP TABLE t1; + +CREATE TABLE t1 (c1 INT, c2 INT); +INSERT INTO t1 VALUES (10,10), (20,20); + +Until MariaDB 10.3.1, the following UPDATE statement would +not work: + +UPDATE t1 SET c1=c1+1 WHERE c2=(SELECT MAX(c2) FROM t1); +ERROR 1093 (HY000): Table 't1' is specified twice, + both as a target for 'UPDATE' and as a separate source +for data + +From MariaDB 10.3.2, the statement executes successfully: + +UPDATE t1 SET c1=c1+1 WHERE c2=(SELECT MAX(c2) FROM t1); + +SELECT * FROM t1; + ++------+------+ +| c1 | c2 | ++------+------+ +| 10 | 10 | +| 21 | 20 | ++------+------+ + +Example + +Single-table syntax: + +UPDATE table_name SET column1 = value1, column2 = value2 +WHERE id=100; + +Multiple-table syntax: + +UPDATE tab1, tab2 SET tab1.column1 = value1, tab1.column2 = +value2 WHERE tab1.id = tab2.id; + + + +URL: https://mariadb.com/kb/en/library/update/ +# Test case 11: Check that the 'CREATE PROCEDURE' statement +# is supported by prepared statements +PREPARE stmt_1 FROM 'CREATE PROCEDURE p1() SET @a=1'; +EXECUTE stmt_1; +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the 'CREATE PROCEDURE' +# statement were damaged. Execution of this statement the second +# time expectedly results in emitting the error ER_SP_ALREADY_EXISTS. +# The same error is issued in case the 'HANDLER t1 OPEN' statement +# is executed twice using a regular statement. +EXECUTE stmt_1; +ERROR 42000: PROCEDURE p1 already exists +# Test case 12: Check that the 'ALTER PROCEDURE' statement is supported +# by prepared statements. +PREPARE stmt_1 FROM 'ALTER PROCEDURE p1 SQL SECURITY INVOKER'; +EXECUTE stmt_1; +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the 'ALTER PROCEDURE' +# statement were damaged. +EXECUTE stmt_1; +# Test case 13: Check that the 'DROP PROCEDURE' statement is supported +# by prepared statements. +PREPARE stmt_1 FROM 'DROP PROCEDURE p1'; +EXECUTE stmt_1; +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the 'DROP PROCEDURE' statement +# were damaged. Execution of this statement the second time expectedly +# results in emitting the error ER_SP_DOES_NOT_EXIST. +EXECUTE stmt_1; +ERROR 42000: PROCEDURE test.p1 does not exist +# Test case 14: Check that the 'CALL' statement is supported +# by prepared statements. +CREATE PROCEDURE p1() SET @a=1; +PREPARE stmt_1 FROM 'CALL p1()'; +EXECUTE stmt_1; +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the 'CALL' statement +# were damaged. +EXECUTE stmt_1; +# Clean up +DEALLOCATE PREPARE stmt_1; +DROP PROCEDURE p1; +# Test case 15: Check that the 'PREPARE FROM' statement can be executed +# as a prepared statement. +PREPARE stmt_1 FROM 'PREPARE stmt_2 FROM "SELECT 1"'; +EXECUTE stmt_1; +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the 'PREPARE' statement +# were damaged. +EXECUTE stmt_1; +# Now execute the prepared statement with the name stmt_2 +# It is expected that output contains the single row '1' +EXECUTE stmt_2; +1 +1 +# Clean up +DEALLOCATE PREPARE stmt_1; +DEALLOCATE PREPARE stmt_2; +# Test case 16: Check that the 'EXECUTE' statement can be executed +# as a prepared statement. +PREPARE stmt_1 FROM 'SELECT 1'; +PREPARE stmt_2 FROM 'EXECUTE stmt_1'; +# Execute the statement stmt_2. Expected result is output of one row '1' +EXECUTE stmt_2; +1 +1 +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the 'EXECUTE' statement +# were damaged. +EXECUTE stmt_2; +1 +1 +# Clean up +DEALLOCATE PREPARE stmt_1; +DEALLOCATE PREPARE stmt_2; +# Test case 17: Check that the statement 'DEALLOCATE PREPARE' +# can be executed as a prepared statement. +PREPARE stmt_1 FROM 'SELECT 1'; +PREPARE stmt_2 FROM 'DEALLOCATE PREPARE stmt_1'; +# After the prepared statement 'stmt_2' be executed +# the prepared statement stmt_1 will be deallocated. +EXECUTE stmt_2; +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the 'DEALLOCATE PREPARE' +# statement were damaged. This time invocation results in the error +# ER_UNKNOWN_STMT_HANDLER since the prepared statement stmt_1 +# has just been released. So, just ignore this error. +EXECUTE stmt_2; +ERROR HY000: Unknown prepared statement handler (stmt_1) given to DEALLOCATE PREPARE +# Check that the stmt_1 doesn't no longer exist +EXECUTE stmt_1; +ERROR HY000: Unknown prepared statement handler (stmt_1) given to EXECUTE +# Clean up +DEALLOCATE PREPARE stmt_2; +# Test case 18: Check that the 'CREATE VIEW' statement can be executed +# as a prepared statement. +# Create environment for the test case +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1); +COMMIT; +PREPARE stmt_1 FROM 'CREATE VIEW v1 AS SELECT * FROM t1'; +EXECUTE stmt_1; +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the 'CREATE VIEW' +# statement were damaged. The second execution of the prepared +# statement stmt_1 results in error ER_TABLE_EXISTS_ERROR since +# the view v1 does already exist. It is expected behaviour. +EXECUTE stmt_1; +ERROR 42S01: Table 'v1' already exists +# Clean up +DEALLOCATE PREPARE stmt_1; +DROP VIEW v1; +DROP TABLE t1; +# Test case 19: Check that the 'CREATE TRIGGER' statement can be executed +# as a prepared statement. +CREATE TABLE t1 (a INT); +PREPARE stmt_1 FROM 'CREATE TRIGGER trg1 BEFORE INSERT ON t1 FOR EACH ROW SET @a=1'; +EXECUTE stmt_1; +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the 'CREATE VIEW' statement +# were damaged. The second execution of the prepared statement stmt_1 +# results in error ER_TRG_ALREADY_EXISTS since the trigger trg1 does +# already exist. It is expected behaviour. +EXECUTE stmt_1; +ERROR HY000: Trigger 'test.trg1' already exists +# Test case 20: Check that the 'DROP TRIGGER' statement can be executed +# as a prepared statement. +# This test relies on presence of the trigger trg1 created by +# the test case 19. +PREPARE stmt_1 FROM 'DROP TRIGGER trg1'; +EXECUTE stmt_1; +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the 'DROP TRIGGER' statement +# were damaged. Execution of this statement the second time expectedly +# results in emitting the error ER_TRG_DOES_NOT_EXIST. +EXECUTE stmt_1; +ERROR HY000: Trigger does not exist +# Clean up +DEALLOCATE PREPARE stmt_1; +DROP TABLE t1; +# Test case 21: Check that XA related SQL statements can be executed +# as prepared statements. +# Create the table t1 used by XA transaction. +CREATE TABLE t1 (a INT); +PREPARE stmt_1 FROM "XA START 'xid1'"; +PREPARE stmt_2 FROM "XA END 'xid1'"; +PREPARE stmt_3 FROM "XA PREPARE 'xid1'"; +PREPARE stmt_4 FROM "XA RECOVER"; +PREPARE stmt_5 FROM "XA COMMIT 'xid1'"; +PREPARE stmt_6 FROM "XA ROLLBACK 'xid1'"; +# Start a new XA transaction +EXECUTE stmt_1; +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the 'XA START' statement +# were damaged. Execution of this statement the second time expectedly +# results in emitting the error XAER_RMFAIL since there is active +# XA transaction that has just been already. +EXECUTE stmt_1; +ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the ACTIVE state +INSERT INTO t1 VALUES (1); +# End the current XA transaction +EXECUTE stmt_2; +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the 'XA END' statement +# were damaged. Execution of this statement the second time expectedly +# results in emitting the error XAER_RMFAIL since the XA transaction +# with XID 'xid1' has been already ended. +EXECUTE stmt_2; +ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the IDLE state +# Prepare the current XA transaction for finalization +EXECUTE stmt_3; +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the 'XA END' statement +# were damaged. Execution of this statement the second time expectedly +# results in emitting the error XAER_RMFAIL since the XA transaction +# with XID 'xid1' has been already ended. +EXECUTE stmt_3; +ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the PREPARED state +# Run XA RECOVER as a prepared statement +EXECUTE stmt_4; +formatID gtrid_length bqual_length data +1 4 0 xid1 +# And execute it yet another time to check that no internal structures +# used for handling the statement 'XA RECOVER' were damaged. +EXECUTE stmt_4; +formatID gtrid_length bqual_length data +1 4 0 xid1 +# Commit the current XA transaction +EXECUTE stmt_5; +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the 'XA COMMIT' statement +# were damaged. Execution of this statement the second time expectedly +# results in emitting the error XAER_NOTA since the XA transaction +# with XID 'xid1' has been finalized and no more exists. +EXECUTE stmt_5; +ERROR XAE04: XAER_NOTA: Unknown XID +# Query the table t1 to check that it contains a record inserted by +# the XA transaction just finished. +SELECT * FROM t1; +a +1 +# Using prepared statements start a new XA transaction, INSERT a row +# into the table t1, prepare the XA transaction and rollback it. +# This use case is similar to precedence one except it does rollback +# XA transaction instead commit it. Therefore every prepared statement +# is executed only once except the last XA ROLLBACK. +# Start a new XA transaction +EXECUTE stmt_1; +INSERT INTO t1 VALUES (1); +# End the current XA transaction +EXECUTE stmt_2; +# Prepare the current XA transaction for finalization +EXECUTE stmt_3; +# Rolback the current XA transaction +EXECUTE stmt_6; +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the statement 'XA ROLLBACK' +# were damaged. Execution of this statement the second time expectedly +# results in emitting the error XAER_NOTA since the XA transaction +# with XID 'xid1' has been finalized and no more exists. +EXECUTE stmt_6; +ERROR XAE04: XAER_NOTA: Unknown XID +# Clean up +DROP TABLE t1; +DEALLOCATE PREPARE stmt_1; +DEALLOCATE PREPARE stmt_2; +DEALLOCATE PREPARE stmt_3; +DEALLOCATE PREPARE stmt_4; +DEALLOCATE PREPARE stmt_5; +DEALLOCATE PREPARE stmt_6; +# Test case 22: Check that the CREATE SERVER/ALTER SERVER/DROP SERVER +# statements can be executed as prepared statements. +PREPARE stmt_1 FROM "CREATE SERVER s FOREIGN DATA WRAPPER mysql OPTIONS (USER 'u1', HOST '127.0.0.1')"; +PREPARE stmt_2 FROM "ALTER SERVER s OPTIONS (USER 'u2')"; +PREPARE stmt_3 FROM "DROP SERVER s"; +EXECUTE stmt_1; +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the 'CREATE SERVER' statement +# were damaged. Execution of this statement the second time expectedly +# results in emitting the error ER_FOREIGN_SERVER_EXISTS +# since a server with same has just been created. +EXECUTE stmt_1; +ERROR HY000: The foreign server, s, you are trying to create already exists +EXECUTE stmt_2; +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the 'ALTER SERVER' statement +# were damaged. +EXECUTE stmt_2; +EXECUTE stmt_3; +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the 'DROP SERVER' statement +# were damaged. Execution of this statement the second time expectedly +# results in emitting the error ER_FOREIGN_SERVER_DOESNT_EXIST +# since the server with same has just been dropped. +EXECUTE stmt_3; +ERROR HY000: The foreign server name you are trying to reference does not exist. Data source error: s +# Clean up +DEALLOCATE PREPARE stmt_1; +DEALLOCATE PREPARE stmt_2; +DEALLOCATE PREPARE stmt_3; +# Test case 23: Check that the CREATE EVENT/ALTER EVENT/DROP EVENT +# statements can be executed as a prepared statement +PREPARE stmt_1 FROM "CREATE EVENT e1 ON SCHEDULE AT CURRENT_TIMESTAMP - INTERVAL 1 DAY ON COMPLETION PRESERVE DO SET @a=1"; +PREPARE stmt_2 FROM "ALTER EVENT e1 COMMENT 'New comment'"; +PREPARE stmt_3 FROM "DROP EVENT e1"; +# Create the event e1 that specifies time in past. Such event is created +# just for the sake of its existence and never will be triggered. +# Disable warnings temprorary in order to hide the following warnings +# generated in result of execution the 'CREATE EVENT' statement: +# "1544 | Event execution time is in the past. Event has been disabled" +# "1105 | Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it." +EXECUTE stmt_1; +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the 'CREATE EVENT' statement +# were damaged. Execution of this statement the second time expectedly +# results in emitting the error ER_EVENT_ALREADY_EXISTS since the event +# with the same name has just been created. +EXECUTE stmt_1; +ERROR HY000: Event 'e1' already exists +# Alter event e1 +EXECUTE stmt_2; +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the 'ALTER EVENT' statement +# were damaged. +EXECUTE stmt_2; +# Drop event e1 +EXECUTE stmt_3; +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the 'DROP EVENT' statement +# were damaged. Execution of this statement the second time expectedly +# results in emitting the error ER_EVENT_DOESNT_EXIST since the event +# with the same name has just been dropped. +EXECUTE stmt_3; +ERROR HY000: Unknown event 'e1' +# Clean up +DEALLOCATE PREPARE stmt_1; +DEALLOCATE PREPARE stmt_2; +DEALLOCATE PREPARE stmt_3; +# Test case 24: Check that the SIGNAL and RESIGNAL statements +# can be executed as a prepared statement +PREPARE stmt_1 FROM "SIGNAL SQLSTATE '45000' SET MYSQL_ERRNO=30001, MESSAGE_TEXT='Hello, world!'"; +EXECUTE stmt_1; +ERROR 45000: Hello, world! +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the 'SIGNAL' statement +# were damaged. +EXECUTE stmt_1; +ERROR 45000: Hello, world! +PREPARE stmt_1 FROM 'RESIGNAL SET MYSQL_ERRNO = 5'; +EXECUTE stmt_1; +ERROR 0K000: RESIGNAL when handler not active +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the 'RESIGNAL' statement +# were damaged. +EXECUTE stmt_1; +ERROR 0K000: RESIGNAL when handler not active +# Clean up +DEALLOCATE PREPARE stmt_1; +# Test case 25: Check that the 'SHOW RELAYLOG EVENTS' statement can be +# executed as a prepared statement. +PREPARE stmt_1 FROM 'SHOW RELAYLOG EVENTS'; +EXECUTE stmt_1; +Log_name Pos Event_type Server_id End_log_pos Info +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the 'SHOW RELAYLOG EVENTS' +# statement were damaged. +EXECUTE stmt_1; +Log_name Pos Event_type Server_id End_log_pos Info +# Clean up +DEALLOCATE PREPARE stmt_1; +# Test case 26: Check the 'GET DIAGNOSTICS' statement +# can be executed as a prepared statement +PREPARE stmt_1 FROM 'GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE, @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT'; +# Query from non existent table to fill the diagnostics area +# with information +SELECT * FROM non_existent_table_1; +ERROR 42S02: Table 'test.non_existent_table_1' doesn't exist +EXECUTE stmt_1; +# Check that information from diagnostics area has been retrieved +SELECT @sqlstate, @errno, @text; +@sqlstate @errno @text +42S02 1146 Table 'test.non_existent_table_1' doesn't exist +SELECT * FROM non_existent_table_1; +ERROR 42S02: Table 'test.non_existent_table_1' doesn't exist +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the +# 'GET DIAGNOSTICS CONDITION' statement were damaged. +EXECUTE stmt_1; +# Clean up +DEALLOCATE PREPARE stmt_1; +# Test case 27: Check the the statement 'EXECUTE IMMEDIATE' +# can be executed as a prepared statement +PREPARE stmt_1 FROM "EXECUTE IMMEDIATE 'SELECT 1'"; +EXECUTE stmt_1; +1 +1 +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the 'EXECUTE IMMEDIATE' +# statement were damaged. +# Clean up +DEALLOCATE PREPARE stmt_1; +# Test Test case 28: Check the statements 'BACKUP'/'BACKUP UNLOCK' +# can be executed as a prepared statement +CREATE TABLE t1 (a INT); +PREPARE stmt_1 FROM 'BACKUP LOCK t1'; +PREPARE stmt_2 FROM 'BACKUP UNLOCK'; +EXECUTE stmt_1; +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the 'BACKUP LOCK' +# statement were damaged. +EXECUTE stmt_1; +EXECUTE stmt_2; +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the 'BACKUP UNLOCK' +# statement were damaged. +EXECUTE stmt_2; +# Clean up +DROP TABLE t1; +DEALLOCATE PREPARE stmt_1; +DEALLOCATE PREPARE stmt_2; +# Test Test case 29: Check the statements 'CREATE/ALTER/DROP TABLEPSPACE' +# can be executed as a prepared statement +PREPARE stmt_1 FROM "CREATE TABLESPACE ts1 ADD DATAFILE 'ts1.ibd' ENGINE=InnoDB"; +PREPARE stmt_2 FROM "ALTER TABLESPACE ts1 ADD DATAFILE 'ts1_1.ibd' ENGINE=InnoDB"; +PREPARE stmt_3 FROM "DROP TABLESPACE ts1 ENGINE=InnoDB"; +EXECUTE stmt_1; +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the 'CREATE TABLESPACE' +# statement were damaged. +EXECUTE stmt_1; +EXECUTE stmt_2; +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the 'ALTER TABLESPACE' +# statement were damaged. +EXECUTE stmt_2; +EXECUTE stmt_3; +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the 'DROP TABLESPACE' +# statement were damaged. +EXECUTE stmt_3; +DEALLOCATE PREPARE stmt_1; +DEALLOCATE PREPARE stmt_2; +DEALLOCATE PREPARE stmt_3; +SET default_storage_engine= @save_storage_engine; diff --git a/mysql-test/main/ps_missed_cmds.test b/mysql-test/main/ps_missed_cmds.test new file mode 100644 index 00000000000..b621ef6d611 --- /dev/null +++ b/mysql-test/main/ps_missed_cmds.test @@ -0,0 +1,758 @@ +--source include/have_innodb.inc + +if (`SELECT $PS_PROTOCOL != 0`) +{ + --skip Need regular protocol but ps-protocol was specified +} + +SET @save_storage_engine= @@default_storage_engine; +SET default_storage_engine= InnoDB; + +--echo # +--echo # MDEV-16708: Unsupported commands for prepared statements +--echo # + +--echo # Disable ps-protocol explicitly in order to test support of +--echo # prepared statements for use case when statements passed +--echo # to the server via text client-server protocol (in contrast +--echo # with binary protocol used in the test file +--echo # ps_missed_cmds_bin_prot.test) +--disable_ps_protocol + +--echo # Test case 1: Check that the statement 'LOAD DATA' is supported +--echo # by prepared statements + +--echo # First, set up environment for use by the 'LOAD DATA' statement +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1); +COMMIT; +SELECT * INTO OUTFILE 'load.data' FROM t1; + +PREPARE stmt_1 FROM "LOAD DATA INFILE 'load.data' INTO TABLE t1"; +EXECUTE stmt_1; +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the 'LOAD DATA' statement +--echo # were damaged. +EXECUTE stmt_1; +SELECT * FROM t1; +--echo # Clean up +DEALLOCATE PREPARE stmt_1; +DROP TABLE t1; +--let $datadir= `select @@datadir` +--remove_file $datadir/test/load.data + +--echo # Test case 2: Check that the 'LOCK TABLE', 'UNLOCK TABLES' statements +--echo # are supported by prepared statements +CREATE TABLE t1 (a INT); + +PREPARE stmt_1 FROM "LOCK TABLE t1 READ"; +EXECUTE stmt_1; +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the 'LOCK TABLE READ' +--echo # statement were damaged. +EXECUTE stmt_1; + +PREPARE stmt_1 FROM "UNLOCK TABLE"; +EXECUTE stmt_1; +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the 'UNLOCK TABLE' statement +--echo # were damaged. +EXECUTE stmt_1; + +PREPARE stmt_1 FROM "LOCK TABLE t1 WRITE"; +EXECUTE stmt_1; +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the 'LOCK TABLE WRITE' +--echo # statement were damaged. +EXECUTE stmt_1; +--echo # Clean up +DEALLOCATE PREPARE stmt_1; +UNLOCK TABLE; +DROP TABLE t1; + +--echo # Test case 3: Check that the 'USE' statement is supported by +--echo # prepared statements + +CREATE DATABASE mdev_16708_db; +PREPARE stmt_1 FROM 'USE mdev_16708_db'; +EXECUTE stmt_1; +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the 'USE' statement +--echo # were damaged. +EXECUTE stmt_1; + +--echo # Check that the current database has been changed +SELECT DATABASE(); + +--echo # Clean up +DEALLOCATE PREPARE stmt_1; +USE test; +DROP DATABASE mdev_16708_db; + +--echo # Test case 4: Check that the 'ALTER DATABASE' statement is supported +--echo # by prepared statements +CREATE DATABASE mdev_16708_db; +PREPARE stmt_1 FROM "ALTER DATABASE mdev_16708_db COMMENT 'New comment'"; +EXECUTE stmt_1; +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the 'ALTER DATABASE' statement +--echo # were damaged. +EXECUTE stmt_1; + +--echo # Clean up +DEALLOCATE PREPARE stmt_1; +USE test; +DROP DATABASE mdev_16708_db; + +--echo # Test case 5: Check that the 'CREATE FUNCTION/ALTER FUNCTION/ +--echo # DROP FUNCTION' statements are supported by prepared statements +PREPARE stmt_1 FROM 'CREATE FUNCTION f1() RETURNS INT RETURN 1'; +EXECUTE stmt_1; +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the 'CREATE FUNCTION' +--echo # statement were damaged. The second attempt to execute the prepared +--echo # statement stmt_1 results in error ER_SP_ALREADY_EXISTS since +--echo # the stored function f() has been created on first run of stmt1. +--error ER_SP_ALREADY_EXISTS +EXECUTE stmt_1; + +PREPARE stmt_1 FROM 'ALTER FUNCTION f1 SQL SECURITY INVOKER'; +EXECUTE stmt_1; +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the 'ALTER FUNCTION' +--echo # statement were damaged. +EXECUTE stmt_1; + +PREPARE stmt_1 FROM 'DROP FUNCTION f1'; +EXECUTE stmt_1; +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling 'DROP FUNCTION' statement +--echo # were damaged. The second attempt to run 'DROP FUNCTION f1' using +--echo # prepared statement expectedly results in issuing the error +--echo # ER_SP_DOES_NOT_EXIST since the stored function was dropped on first +--echo # executuon of the prepared statement stmt_1. +--error ER_SP_DOES_NOT_EXIST +EXECUTE stmt_1; + +--echo # Test case 6: Check that the 'CHECK TABLE' statement is supported +--echo # by prepared statements +CREATE TABLE t1 (a INT); +PREPARE stmt_1 FROM 'CHECK TABLE t1'; +EXECUTE stmt_1; +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the 'CHECK TABLE' statement +--echo # were damaged. +EXECUTE stmt_1; + +--echo # Clean up +DEALLOCATE PREPARE stmt_1; +DROP TABLE t1; + +--echo # Test case 7: Check that the BEGIN/SAVEPOINT/RELEASE SAVEPOINT +--echo # statements are supported by prepared statements + +--echo # Set up environmentr for the test case +CREATE TABLE t1 (a INT); + +PREPARE stmt_1 FROM 'BEGIN'; +EXECUTE stmt_1; +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the 'BEGIN' statement +--echo # were damaged. +EXECUTE stmt_1; + +INSERT INTO t1 VALUES (1); +--echo # Run 'SAVEPOINT s1' using prepared statements +PREPARE stmt_2 FROM 'SAVEPOINT s1'; +EXECUTE stmt_2; +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the 'SAVEPOINT' statement +--echo # were damaged. +EXECUTE stmt_2; + +INSERT INTO t1 VALUES (2); +--echo # Expected rows: '1' and '2' +SELECT * FROM t1; +--echo # Rollback the last row inserted ('2') +ROLLBACK TO SAVEPOINT s1; +--echo # Expected output from t1 after transaction has been rolled back +--echo # to the savepoint is '1'. If it is case then the statement SAVEPOINT +--echo # was handled successfully with prepared statement +SELECT * FROM t1; + +PREPARE stmt_3 FROM 'RELEASE SAVEPOINT s1'; +EXECUTE stmt_3; +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the 'RELEASE' statement +--echo # were damaged. The second attempt to release the same savepoint +--echo # expectedly lead to error 'SAVEPOINT s1 does not exist' +--echo # that's just ignored. +--error ER_SP_DOES_NOT_EXIST +EXECUTE stmt_3; + +--echo # Clean up +DEALLOCATE PREPARE stmt_1; +DEALLOCATE PREPARE stmt_2; +DEALLOCATE PREPARE stmt_3; +DROP TABLE t1; + +--echo # Test case 8: Check that the 'PURGE BINARY LOGS BEFORE' statement +--echo # is supported by prepared statements +PREPARE stmt_1 FROM "PURGE BINARY LOGS BEFORE '2020-11-17'"; +EXECUTE stmt_1; +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the 'PURGE BINARY LOGS BEFORE' +--echo # statement were damaged. +EXECUTE stmt_1; + +--echo # Check that the 'PURGE BINARY LOGS TO' statement is supported by +--echo # prepared statements +PREPARE stmt_1 FROM "PURGE BINARY LOGS TO 'mariadb-bin.000063'"; +EXECUTE stmt_1; +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the 'PURGE BINARY LOGS TO' +--echo # statement were damaged. +EXECUTE stmt_1; + +--echo # Test case 9: Check that the 'HANDLER OPEN/HANDLER READ/ +--echo # HANDLER CLOSE' statements are supported by prepared statements +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (1); +COMMIT; + +PREPARE stmt_1 FROM 'HANDLER t1 OPEN'; +EXECUTE stmt_1; +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the 'HANDLER OPEN' +--echo # statement were damaged. Execution of this statement the second +--echo # time expectedly results in emitting the error ER_NONUNIQ_TABLE. +--echo # The same error is issued in case the statement 'HANDLER t1 OPEN' is +--echo # executed twice using a regular statement. +--error ER_NONUNIQ_TABLE +EXECUTE stmt_1; + +PREPARE stmt_2 FROM 'HANDLER t1 READ FIRST'; +PREPARE stmt_3 FROM 'HANDLER t1 READ NEXT'; +PREPARE stmt_4 FROM 'HANDLER t1 CLOSE'; + +EXECUTE stmt_2; +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the 'HANDLER READ FIRST' +--echo # statement were damaged. +EXECUTE stmt_2; + +EXECUTE stmt_3; +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the 'HANDLER READ NEXT' +--echo # statement were damaged. +EXECUTE stmt_3; + +EXECUTE stmt_4; +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the 'HANDLER CLOSE' +--echo # statement were damaged. Execution of this statement the second +--echo # time results in emitting the error ER_UNKNOWN_TABLE. The same error +--echo # is issued in case the statement 'HANDLER t1 CLOSE' executed twice +--echo # using a regular statement. +--error ER_UNKNOWN_TABLE +EXECUTE stmt_4; + +--echo # Clean up +DEALLOCATE PREPARE stmt_1; +DEALLOCATE PREPARE stmt_2; +DEALLOCATE PREPARE stmt_3; +DEALLOCATE PREPARE stmt_4; +DROP TABLE t1; + +--echo # Test case 10: Check that the HELP statement +--echo # is supported by prepared statements +PREPARE stmt_1 FROM "HELP `UPDATE`"; +EXECUTE stmt_1; +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the 'HELP' statement +--echo # were damaged. + +EXECUTE stmt_1; + +--echo # Test case 11: Check that the 'CREATE PROCEDURE' statement +--echo # is supported by prepared statements +PREPARE stmt_1 FROM 'CREATE PROCEDURE p1() SET @a=1'; +EXECUTE stmt_1; +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the 'CREATE PROCEDURE' +--echo # statement were damaged. Execution of this statement the second +--echo # time expectedly results in emitting the error ER_SP_ALREADY_EXISTS. +--echo # The same error is issued in case the 'HANDLER t1 OPEN' statement +--echo # is executed twice using a regular statement. +--error ER_SP_ALREADY_EXISTS +EXECUTE stmt_1; + +--echo # Test case 12: Check that the 'ALTER PROCEDURE' statement is supported +--echo # by prepared statements. +# This test case relies on artefacts of the test case 11 (the procedure p1) + +PREPARE stmt_1 FROM 'ALTER PROCEDURE p1 SQL SECURITY INVOKER'; +EXECUTE stmt_1; +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the 'ALTER PROCEDURE' +--echo # statement were damaged. +EXECUTE stmt_1; + +--echo # Test case 13: Check that the 'DROP PROCEDURE' statement is supported +--echo # by prepared statements. +# This test case relies on artefacts of the test case 11 (the procedure p1) +PREPARE stmt_1 FROM 'DROP PROCEDURE p1'; +EXECUTE stmt_1; +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the 'DROP PROCEDURE' statement +--echo # were damaged. Execution of this statement the second time expectedly +--echo # results in emitting the error ER_SP_DOES_NOT_EXIST. + +--error ER_SP_DOES_NOT_EXIST +EXECUTE stmt_1; + +--echo # Test case 14: Check that the 'CALL' statement is supported +--echo # by prepared statements. + +CREATE PROCEDURE p1() SET @a=1; +PREPARE stmt_1 FROM 'CALL p1()'; +EXECUTE stmt_1; +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the 'CALL' statement +--echo # were damaged. +EXECUTE stmt_1; + +--echo # Clean up +DEALLOCATE PREPARE stmt_1; +DROP PROCEDURE p1; + +--echo # Test case 15: Check that the 'PREPARE FROM' statement can be executed +--echo # as a prepared statement. +PREPARE stmt_1 FROM 'PREPARE stmt_2 FROM "SELECT 1"'; +EXECUTE stmt_1; +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the 'PREPARE' statement +--echo # were damaged. +EXECUTE stmt_1; +--echo # Now execute the prepared statement with the name stmt_2 +--echo # It is expected that output contains the single row '1' +EXECUTE stmt_2; +--echo # Clean up +DEALLOCATE PREPARE stmt_1; +DEALLOCATE PREPARE stmt_2; + +--echo # Test case 16: Check that the 'EXECUTE' statement can be executed +--echo # as a prepared statement. +PREPARE stmt_1 FROM 'SELECT 1'; +PREPARE stmt_2 FROM 'EXECUTE stmt_1'; +--echo # Execute the statement stmt_2. Expected result is output of one row '1' +EXECUTE stmt_2; +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the 'EXECUTE' statement +--echo # were damaged. +EXECUTE stmt_2; + +--echo # Clean up +DEALLOCATE PREPARE stmt_1; +DEALLOCATE PREPARE stmt_2; + +--echo # Test case 17: Check that the statement 'DEALLOCATE PREPARE' +--echo # can be executed as a prepared statement. +PREPARE stmt_1 FROM 'SELECT 1'; +PREPARE stmt_2 FROM 'DEALLOCATE PREPARE stmt_1'; +--echo # After the prepared statement 'stmt_2' be executed +--echo # the prepared statement stmt_1 will be deallocated. +EXECUTE stmt_2; +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the 'DEALLOCATE PREPARE' +--echo # statement were damaged. This time invocation results in the error +--echo # ER_UNKNOWN_STMT_HANDLER since the prepared statement stmt_1 +--echo # has just been released. So, just ignore this error. +--error ER_UNKNOWN_STMT_HANDLER +EXECUTE stmt_2; + +--echo # Check that the stmt_1 doesn't no longer exist +--error ER_UNKNOWN_STMT_HANDLER +EXECUTE stmt_1; + +--echo # Clean up +DEALLOCATE PREPARE stmt_2; + +--echo # Test case 18: Check that the 'CREATE VIEW' statement can be executed +--echo # as a prepared statement. +--echo # Create environment for the test case +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1); +COMMIT; + +PREPARE stmt_1 FROM 'CREATE VIEW v1 AS SELECT * FROM t1'; +EXECUTE stmt_1; +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the 'CREATE VIEW' +--echo # statement were damaged. The second execution of the prepared +--echo # statement stmt_1 results in error ER_TABLE_EXISTS_ERROR since +--echo # the view v1 does already exist. It is expected behaviour. + +--error ER_TABLE_EXISTS_ERROR +EXECUTE stmt_1; + +--echo # Clean up +DEALLOCATE PREPARE stmt_1; + +DROP VIEW v1; +DROP TABLE t1; + +--echo # Test case 19: Check that the 'CREATE TRIGGER' statement can be executed +--echo # as a prepared statement. +CREATE TABLE t1 (a INT); +PREPARE stmt_1 FROM 'CREATE TRIGGER trg1 BEFORE INSERT ON t1 FOR EACH ROW SET @a=1'; +EXECUTE stmt_1; +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the 'CREATE VIEW' statement +--echo # were damaged. The second execution of the prepared statement stmt_1 +--echo # results in error ER_TRG_ALREADY_EXISTS since the trigger trg1 does +--echo # already exist. It is expected behaviour. +--error ER_TRG_ALREADY_EXISTS +EXECUTE stmt_1; + +--echo # Test case 20: Check that the 'DROP TRIGGER' statement can be executed +--echo # as a prepared statement. +--echo # This test relies on presence of the trigger trg1 created by +--echo # the test case 19. +PREPARE stmt_1 FROM 'DROP TRIGGER trg1'; +EXECUTE stmt_1; +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the 'DROP TRIGGER' statement +--echo # were damaged. Execution of this statement the second time expectedly +--echo # results in emitting the error ER_TRG_DOES_NOT_EXIST. +--error ER_TRG_DOES_NOT_EXIST +EXECUTE stmt_1; + +--echo # Clean up +DEALLOCATE PREPARE stmt_1; +DROP TABLE t1; + +--echo # Test case 21: Check that XA related SQL statements can be executed +--echo # as prepared statements. +--echo # Create the table t1 used by XA transaction. +CREATE TABLE t1 (a INT); +PREPARE stmt_1 FROM "XA START 'xid1'"; +PREPARE stmt_2 FROM "XA END 'xid1'"; +PREPARE stmt_3 FROM "XA PREPARE 'xid1'"; +PREPARE stmt_4 FROM "XA RECOVER"; +PREPARE stmt_5 FROM "XA COMMIT 'xid1'"; +PREPARE stmt_6 FROM "XA ROLLBACK 'xid1'"; + +--echo # Start a new XA transaction +EXECUTE stmt_1; +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the 'XA START' statement +--echo # were damaged. Execution of this statement the second time expectedly +--echo # results in emitting the error XAER_RMFAIL since there is active +--echo # XA transaction that has just been already. +--error ER_XAER_RMFAIL +EXECUTE stmt_1; + +INSERT INTO t1 VALUES (1); + +--echo # End the current XA transaction +EXECUTE stmt_2; +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the 'XA END' statement +--echo # were damaged. Execution of this statement the second time expectedly +--echo # results in emitting the error XAER_RMFAIL since the XA transaction +--echo # with XID 'xid1' has been already ended. +--error ER_XAER_RMFAIL +EXECUTE stmt_2; + +--echo # Prepare the current XA transaction for finalization +EXECUTE stmt_3; +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the 'XA END' statement +--echo # were damaged. Execution of this statement the second time expectedly +--echo # results in emitting the error XAER_RMFAIL since the XA transaction +--echo # with XID 'xid1' has been already ended. +--error ER_XAER_RMFAIL +EXECUTE stmt_3; + +--echo # Run XA RECOVER as a prepared statement +EXECUTE stmt_4; +--echo # And execute it yet another time to check that no internal structures +--echo # used for handling the statement 'XA RECOVER' were damaged. +EXECUTE stmt_4; + +--echo # Commit the current XA transaction +EXECUTE stmt_5; +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the 'XA COMMIT' statement +--echo # were damaged. Execution of this statement the second time expectedly +--echo # results in emitting the error XAER_NOTA since the XA transaction +--echo # with XID 'xid1' has been finalized and no more exists. +--error ER_XAER_NOTA +EXECUTE stmt_5; + +--echo # Query the table t1 to check that it contains a record inserted by +--echo # the XA transaction just finished. +SELECT * FROM t1; + +--echo # Using prepared statements start a new XA transaction, INSERT a row +--echo # into the table t1, prepare the XA transaction and rollback it. +--echo # This use case is similar to precedence one except it does rollback +--echo # XA transaction instead commit it. Therefore every prepared statement +--echo # is executed only once except the last XA ROLLBACK. + +--echo # Start a new XA transaction +EXECUTE stmt_1; + +INSERT INTO t1 VALUES (1); + +--echo # End the current XA transaction +EXECUTE stmt_2; + +--echo # Prepare the current XA transaction for finalization +EXECUTE stmt_3; + +--echo # Rolback the current XA transaction +EXECUTE stmt_6; + +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the statement 'XA ROLLBACK' +--echo # were damaged. Execution of this statement the second time expectedly +--echo # results in emitting the error XAER_NOTA since the XA transaction +--echo # with XID 'xid1' has been finalized and no more exists. +--error ER_XAER_NOTA +EXECUTE stmt_6; + +--echo # Clean up +DROP TABLE t1; +DEALLOCATE PREPARE stmt_1; +DEALLOCATE PREPARE stmt_2; +DEALLOCATE PREPARE stmt_3; +DEALLOCATE PREPARE stmt_4; +DEALLOCATE PREPARE stmt_5; +DEALLOCATE PREPARE stmt_6; + +--echo # Test case 22: Check that the CREATE SERVER/ALTER SERVER/DROP SERVER +--echo # statements can be executed as prepared statements. + +PREPARE stmt_1 FROM "CREATE SERVER s FOREIGN DATA WRAPPER mysql OPTIONS (USER 'u1', HOST '127.0.0.1')"; +PREPARE stmt_2 FROM "ALTER SERVER s OPTIONS (USER 'u2')"; +PREPARE stmt_3 FROM "DROP SERVER s"; + +EXECUTE stmt_1; +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the 'CREATE SERVER' statement +--echo # were damaged. Execution of this statement the second time expectedly +--echo # results in emitting the error ER_FOREIGN_SERVER_EXISTS +--echo # since a server with same has just been created. +--error ER_FOREIGN_SERVER_EXISTS +EXECUTE stmt_1; + +EXECUTE stmt_2; +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the 'ALTER SERVER' statement +--echo # were damaged. +EXECUTE stmt_2; + +EXECUTE stmt_3; +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the 'DROP SERVER' statement +--echo # were damaged. Execution of this statement the second time expectedly +--echo # results in emitting the error ER_FOREIGN_SERVER_DOESNT_EXIST +--echo # since the server with same has just been dropped. +--error ER_FOREIGN_SERVER_DOESNT_EXIST +EXECUTE stmt_3; + +--echo # Clean up +DEALLOCATE PREPARE stmt_1; +DEALLOCATE PREPARE stmt_2; +DEALLOCATE PREPARE stmt_3; + +--echo # Test case 23: Check that the CREATE EVENT/ALTER EVENT/DROP EVENT +--echo # statements can be executed as a prepared statement + +PREPARE stmt_1 FROM "CREATE EVENT e1 ON SCHEDULE AT CURRENT_TIMESTAMP - INTERVAL 1 DAY ON COMPLETION PRESERVE DO SET @a=1"; + +PREPARE stmt_2 FROM "ALTER EVENT e1 COMMENT 'New comment'"; + +PREPARE stmt_3 FROM "DROP EVENT e1"; +--echo # Create the event e1 that specifies time in past. Such event is created +--echo # just for the sake of its existence and never will be triggered. +--echo # Disable warnings temprorary in order to hide the following warnings +--echo # generated in result of execution the 'CREATE EVENT' statement: +--echo # "1544 | Event execution time is in the past. Event has been disabled" +--echo # "1105 | Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it." + +--disable_warnings +EXECUTE stmt_1; + +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the 'CREATE EVENT' statement +--echo # were damaged. Execution of this statement the second time expectedly +--echo # results in emitting the error ER_EVENT_ALREADY_EXISTS since the event +--echo # with the same name has just been created. +--error ER_EVENT_ALREADY_EXISTS +EXECUTE stmt_1; + +--enable_warnings + +--echo # Alter event e1 +EXECUTE stmt_2; +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the 'ALTER EVENT' statement +--echo # were damaged. +EXECUTE stmt_2; + +--echo # Drop event e1 +EXECUTE stmt_3; +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the 'DROP EVENT' statement +--echo # were damaged. Execution of this statement the second time expectedly +--echo # results in emitting the error ER_EVENT_DOESNT_EXIST since the event +--echo # with the same name has just been dropped. +--error ER_EVENT_DOES_NOT_EXIST +EXECUTE stmt_3; +--echo # Clean up +DEALLOCATE PREPARE stmt_1; +DEALLOCATE PREPARE stmt_2; +DEALLOCATE PREPARE stmt_3; + +--echo # Test case 24: Check that the SIGNAL and RESIGNAL statements +--echo # can be executed as a prepared statement +PREPARE stmt_1 FROM "SIGNAL SQLSTATE '45000' SET MYSQL_ERRNO=30001, MESSAGE_TEXT='Hello, world!'"; +--error 30001 +EXECUTE stmt_1; +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the 'SIGNAL' statement +--echo # were damaged. +--error 30001 +EXECUTE stmt_1; + +PREPARE stmt_1 FROM 'RESIGNAL SET MYSQL_ERRNO = 5'; +--error ER_RESIGNAL_WITHOUT_ACTIVE_HANDLER +EXECUTE stmt_1; +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the 'RESIGNAL' statement +--echo # were damaged. +--error ER_RESIGNAL_WITHOUT_ACTIVE_HANDLER +EXECUTE stmt_1; + +--echo # Clean up +DEALLOCATE PREPARE stmt_1; + +--echo # Test case 25: Check that the 'SHOW RELAYLOG EVENTS' statement can be +--echo # executed as a prepared statement. +PREPARE stmt_1 FROM 'SHOW RELAYLOG EVENTS'; +EXECUTE stmt_1; +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the 'SHOW RELAYLOG EVENTS' +--echo # statement were damaged. +EXECUTE stmt_1; +--echo # Clean up +DEALLOCATE PREPARE stmt_1; + +--echo # Test case 26: Check the 'GET DIAGNOSTICS' statement +--echo # can be executed as a prepared statement +PREPARE stmt_1 FROM 'GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE, @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT'; + +--echo # Query from non existent table to fill the diagnostics area +--echo # with information +--error ER_NO_SUCH_TABLE +SELECT * FROM non_existent_table_1; +EXECUTE stmt_1; +--echo # Check that information from diagnostics area has been retrieved +SELECT @sqlstate, @errno, @text; + +--error ER_NO_SUCH_TABLE +SELECT * FROM non_existent_table_1; +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the +--echo # 'GET DIAGNOSTICS CONDITION' statement were damaged. +EXECUTE stmt_1; + +--echo # Clean up +DEALLOCATE PREPARE stmt_1; + +--echo # Test case 27: Check the the statement 'EXECUTE IMMEDIATE' +--echo # can be executed as a prepared statement + +PREPARE stmt_1 FROM "EXECUTE IMMEDIATE 'SELECT 1'"; +EXECUTE stmt_1; +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the 'EXECUTE IMMEDIATE' +--echo # statement were damaged. + +--echo # Clean up +DEALLOCATE PREPARE stmt_1; + +--echo # Test Test case 28: Check the statements 'BACKUP'/'BACKUP UNLOCK' +--echo # can be executed as a prepared statement +CREATE TABLE t1 (a INT); +PREPARE stmt_1 FROM 'BACKUP LOCK t1'; +PREPARE stmt_2 FROM 'BACKUP UNLOCK'; + +EXECUTE stmt_1; +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the 'BACKUP LOCK' +--echo # statement were damaged. +EXECUTE stmt_1; + +EXECUTE stmt_2; +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the 'BACKUP UNLOCK' +--echo # statement were damaged. +EXECUTE stmt_2; + +--echo # Clean up +DROP TABLE t1; +DEALLOCATE PREPARE stmt_1; +DEALLOCATE PREPARE stmt_2; + +--echo # Test Test case 29: Check the statements 'CREATE/ALTER/DROP TABLEPSPACE' +--echo # can be executed as a prepared statement + +PREPARE stmt_1 FROM "CREATE TABLESPACE ts1 ADD DATAFILE 'ts1.ibd' ENGINE=InnoDB"; +PREPARE stmt_2 FROM "ALTER TABLESPACE ts1 ADD DATAFILE 'ts1_1.ibd' ENGINE=InnoDB"; +PREPARE stmt_3 FROM "DROP TABLESPACE ts1 ENGINE=InnoDB"; + +# Since MariaDB supports for tablespaces only on syntax level disable warnings +# before run CREATE/ALTER/DROP TABLESPACE statements in order to exclude +# the following in result output +# Warning 1478 Table storage engine 'InnoDB' does not support the create option 'TABLESPACE +--disable_warnings + +EXECUTE stmt_1; +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the 'CREATE TABLESPACE' +--echo # statement were damaged. +# Since the 'CREATE TABLESPACE' statement is supported by MariaDB on syntax +# level only the second invocation of the CREATE TABLESPACE statement for +# the same tablespace name doesn't lead to error. +EXECUTE stmt_1; + +EXECUTE stmt_2; +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the 'ALTER TABLESPACE' +--echo # statement were damaged. +EXECUTE stmt_2; + +EXECUTE stmt_3; +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the 'DROP TABLESPACE' +--echo # statement were damaged. + +# Since the 'DROP TABLESPACE' statement is supported by MariaDB on syntax +# level only the second invocation of the DROP TABLESPACE statement for +# the same tablespace name doesn't lead to an error that tablespace +# doesn't exist. +EXECUTE stmt_3; + +--enable_warnings + +DEALLOCATE PREPARE stmt_1; +DEALLOCATE PREPARE stmt_2; +DEALLOCATE PREPARE stmt_3; + +--enable_ps_protocol +SET default_storage_engine= @save_storage_engine; diff --git a/mysql-test/main/ps_missed_cmds_bin_prot.result b/mysql-test/main/ps_missed_cmds_bin_prot.result new file mode 100644 index 00000000000..3b56d9a1a5b --- /dev/null +++ b/mysql-test/main/ps_missed_cmds_bin_prot.result @@ -0,0 +1,264 @@ +# +# MDEV-16708: Unsupported commands for prepared statements +# +SET @save_storage_engine= @@default_storage_engine; +SET default_storage_engine= InnoDB; +# Test case 1: Check that the statement 'LOAD DATA' is supported +# by prepared statements +# First, set up environment for use by the statement 'LOAD DATA' +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1); +COMMIT; +SELECT * INTO OUTFILE 'load.data' FROM t1; +LOAD DATA INFILE 'load.data' INTO TABLE t1; +SELECT * FROM t1; +a +1 +1 +# Clean up +DROP TABLE t1; +# Test case 2: Check that the statements 'LOCK TABLE', 'UNLOCK TABLES' +# are supported by prepared statements +CREATE TABLE t1 (a INT); +LOCK TABLE t1 READ; +UNLOCK TABLE; +LOCK TABLE t1 WRITE; +# Clean up +UNLOCK TABLE; +DROP TABLE t1; +# Test case 3: Check that the statement 'USE' is supported by +# prepared statements +CREATE DATABASE mdev_16708_db; +USE mdev_16708_db; +# Check that the current database has been changed +SELECT DATABASE(); +DATABASE() +mdev_16708_db +# Clean up +USE test; +DROP DATABASE mdev_16708_db; +# Test case 4: Check that the statement 'ALTER DATABASE' is supported +# by prepared statements +CREATE DATABASE mdev_16708_db; +ALTER DATABASE mdev_16708_db COMMENT 'New comment on database'; +# Clean up +DROP DATABASE mdev_16708_db; +# Test case 5: Check that the statements 'CREATE FUNCTION/ALTER FUNCTION/ +# DROP FUNCTION' are supported by prepared statements +CREATE FUNCTION f1() RETURNS INT RETURN 1; +ALTER FUNCTION f1 SQL SECURITY INVOKER; +DROP FUNCTION f1; +# Test case 6: Check that the statements 'CHECK TABLE' is supported +# by prepared statements +CREATE TABLE t1 (a INT); +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +# Clean up +DROP TABLE t1; +# Test case 7: Check that the statements BEGIN/SAVEPOINT/ +# RELEASE SAVEPOINT is supported by prepared statements +# Set up environmentr for the test case +CREATE TABLE t1 (a INT); +BEGIN; +INSERT INTO t1 VALUES (1); +SAVEPOINT s1; +INSERT INTO t1 VALUES (2); +# Expected rows: '1' and '2' +SELECT * FROM t1; +a +1 +2 +# Rollback the last row inserted ('2') +ROLLBACK TO SAVEPOINT s1; +# Expected output from t1 after transaction was rolled back +# to the savepoint is '1'. If it is case then the statement SAVEPOINT +# was handled successfully with prepared statement +SELECT * FROM t1; +a +1 +RELEASE SAVEPOINT s1; +# Clean up +DROP TABLE t1; +# Test case 8: Check that the statements 'PURGE BINARY LOGS BEFORE' +# is supported by prepared statements +PURGE BINARY LOGS BEFORE '2020-11-17'; +# Check that the statements 'PURGE BINARY LOGS TO' is supported by +# prepared statements +PURGE BINARY LOGS TO 'mariadb-bin.000063'; +# Test case 9: Check that the statements 'HANDLER OPEN/HANDLER READ/ +# HANDLER CLOSE' are supported by prepared statements +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (1); +COMMIT; +HANDLER t1 OPEN; +HANDLER t1 READ FIRST; +a +1 +HANDLER t1 READ NEXT; +a +1 +HANDLER t1 CLOSE; +# Clean up +DROP TABLE t1; +# Test case 10: Check that the statements 'HELP' +# is supported by prepared statements +HELP `ALTER SERVER`; +name description example +ALTER SERVER Syntax +------ +ALTER SERVER server_name + OPTIONS (option [, option] ...) + +Description +----------- +Alters the server information for server_name, adjusting the +specified +options as per the CREATE SERVER command. The corresponding +fields in the mysql.servers table are updated accordingly. +This statement requires the SUPER privilege. + +Examples +-------- +ALTER SERVER s OPTIONS (USER 'sally'); + + + +URL: https://mariadb.com/kb/en/library/alter-server/ +# Test case 11: Check that the statements CREATE/ALTER/DROP PROCEDURE +# are supported by prepared statements +CREATE PROCEDURE p1() SET @a=1; +ALTER PROCEDURE p1 SQL SECURITY INVOKER; +DROP PROCEDURE p1; +# Test case 12: Check that the statement 'CALL' is supported +# by prepared statements. +CREATE PROCEDURE p1() SET @a=1; +CALL p1(); +# Check that the @a variable has been set +SELECT @a; +@a +1 +DROP PROCEDURE p1; +# Test case 13: Check that the statements PREPARE FROM/EXECUTE/ +# DEALLOCAT PREPARE can be executed as prepared statements. +PREPARE stmt_1 FROM 'SELECT 1'; +# Now execute the prepared statement with the name stmt_1 +# It is expected that output contains the single row '1' +EXECUTE stmt_1; +1 +1 +DEALLOCATE PREPARE stmt_1; +# Test case 14: Check that the statement 'CREATE VIEW' can be executed +# as a prepared statement. +# Create environment for the test case +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1); +COMMIT; +CREATE VIEW v1 AS SELECT * FROM t1; +# Query the view. Expected result is the row '1' +SELECT * FROM v1; +a +1 +# Clean up +DROP VIEW v1; +DROP TABLE t1; +# Test case 15: Check that the statements CREATE/DROP TRIGGER can be executed +# as prepared statements. +CREATE TABLE t1 (a INT); +CREATE TRIGGER trg1 BEFORE INSERT ON t1 FOR EACH ROW SET @a=1; +DROP TRIGGER trg1; +DROP TABLE t1; +# Test case 16: Check that XA related SQL statements can be executed in +# as prepared statements. +# Create the table t1 used by XA transaction. +CREATE TABLE t1 (a INT); +XA START 'xid1'; +INSERT INTO t1 VALUES (1); +XA END 'xid1'; +XA PREPARE 'xid1'; +XA RECOVER; +formatID gtrid_length bqual_length data +1 4 0 xid1 +XA COMMIT 'xid1'; +# Query the table t1 to check that it contains a record inserted by XA +# transaction just committed. +SELECT * FROM t1; +a +1 +# Check that XA ROLLBACK is supported by prepared statements +# First, clean up the table t1 that was filled by just +# committed XA transaction +TRUNCATE TABLE t1; +XA START 'xid1'; +INSERT INTO t1 VALUES (1); +XA END 'xid1'; +XA PREPARE 'xid1'; +XA RECOVER; +formatID gtrid_length bqual_length data +1 4 0 xid1 +XA ROLLBACK 'xid1'; +# Query the table t1 to check that it doesn't contain a record +# inserted by XA transaction just rollbacked. +SELECT * FROM t1; +a +# Clean up +DROP TABLE t1; +# Test case 17: Check that the statements CREATE SERVER/ALTER SERVER/ +# DROP SERVER can be executed +# as a prepared statement. +CREATE SERVER s FOREIGN DATA WRAPPER mysql OPTIONS (USER 'u1', HOST '127.0.0.1'); +ALTER SERVER s OPTIONS (USER 'u2'); +DROP SERVER s; +# Test case 18: Check that the statements CREATE EVENT/ALTER EVENT/ +# DROP EVENT can be executed as a prepared statement +# Create the event e1 that specifies time in past. Such event is created +# just for the sake of its existence and never will be triggered. +# Disable warnings temprorary in order to hide the following warnings +# generated in result of execution the 'CREATE EVENT' statement: +# "1544 | Event execution time is in the past. Event has been disabled" +# "1105 | Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it." +CREATE EVENT e1 ON SCHEDULE AT CURRENT_TIMESTAMP - INTERVAL 1 DAY ON COMPLETION PRESERVE DO SET @a=1; +ALTER EVENT e1 COMMENT 'New comment'; +DROP EVENT IF EXISTS e1; +# Test case 19: Check that the statement 'SHOW RELAYLOG EVENTS' can be +# executed as a prepared statement. +SHOW RELAYLOG EVENTS; +Log_name Pos Event_type Server_id End_log_pos Info +# Test case 20: Check the the statement 'EXECUTE IMMEDIATE' +# can be executed as a prepared statement +EXECUTE IMMEDIATE 'SELECT 1'; +1 +1 +# Test Test case 21: Check the statements 'BACKUP'/'BACKUP STAGE' +# can be executed as a prepared statement +CREATE TABLE t1 (a INT); +BACKUP LOCK t1; +BACKUP UNLOCK; +BACKUP STAGE START; +BACKUP STAGE BLOCK_COMMIT; +BACKUP STAGE END; +DROP TABLE t1; +# Test case 22: Check the the statement 'GET DIAGNOSTICS' +# can be executed as a prepared statement +# Query from non existent table to fill the diagnostics area with information +SELECT * FROM non_existent_table_1; +ERROR 42S02: Table 'test.non_existent_table_1' doesn't exist +GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE, @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT; +# Check that information from diagnostics area has been retrieved +SELECT @sqlstate, @errno, @text; +@sqlstate @errno @text +42S02 1146 Table 'test.non_existent_table_1' doesn't exist +# Clean up +# Test case 23: Check that the statements SIGNAL and RESIGNAL can be executed as +# a prepared statement +SIGNAL SQLSTATE '45000' SET MYSQL_ERRNO=30001, MESSAGE_TEXT='Hello, world!'; +ERROR 45000: Hello, world! +RESIGNAL SET MESSAGE_TEXT = 'New error message'; +ERROR 0K000: RESIGNAL when handler not active +# Test Test case 29: Check the statements 'CREATE/ALTER/DROP TABLEPSPACE' +# can be executed as a prepared statement +CREATE TABLESPACE ts1 ADD DATAFILE 'ts1.ibd' ENGINE=InnoDB; +ALTER TABLESPACE ts1 ADD DATAFILE 'ts1_1.ibd' ENGINE=InnoDB; +DROP TABLESPACE ts1 ENGINE=InnoDB; +SET default_storage_engine= @save_storage_engine; diff --git a/mysql-test/main/ps_missed_cmds_bin_prot.test b/mysql-test/main/ps_missed_cmds_bin_prot.test new file mode 100644 index 00000000000..10ce9ebd60a --- /dev/null +++ b/mysql-test/main/ps_missed_cmds_bin_prot.test @@ -0,0 +1,298 @@ +--echo # +--echo # MDEV-16708: Unsupported commands for prepared statements +--echo # + +if (`SELECT $PS_PROTOCOL = 0`) +{ + --skip Need ps-protocol +} + +--source include/have_innodb.inc + +SET @save_storage_engine= @@default_storage_engine; +SET default_storage_engine= InnoDB; + +--echo # Test case 1: Check that the statement 'LOAD DATA' is supported +--echo # by prepared statements + +--echo # First, set up environment for use by the statement 'LOAD DATA' +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1); +COMMIT; +SELECT * INTO OUTFILE 'load.data' FROM t1; + +LOAD DATA INFILE 'load.data' INTO TABLE t1; +SELECT * FROM t1; +--echo # Clean up +DROP TABLE t1; +--let $datadir= `select @@datadir` +--remove_file $datadir/test/load.data + +--echo # Test case 2: Check that the statements 'LOCK TABLE', 'UNLOCK TABLES' +--echo # are supported by prepared statements +CREATE TABLE t1 (a INT); + +LOCK TABLE t1 READ; +UNLOCK TABLE; + +LOCK TABLE t1 WRITE; +--echo # Clean up +UNLOCK TABLE; +DROP TABLE t1; + +--echo # Test case 3: Check that the statement 'USE' is supported by +--echo # prepared statements + +CREATE DATABASE mdev_16708_db; +USE mdev_16708_db; + +--echo # Check that the current database has been changed +SELECT DATABASE(); + +--echo # Clean up +USE test; +DROP DATABASE mdev_16708_db; + +--echo # Test case 4: Check that the statement 'ALTER DATABASE' is supported +--echo # by prepared statements +CREATE DATABASE mdev_16708_db; +ALTER DATABASE mdev_16708_db COMMENT 'New comment on database'; + +--echo # Clean up +DROP DATABASE mdev_16708_db; + +--echo # Test case 5: Check that the statements 'CREATE FUNCTION/ALTER FUNCTION/ +--echo # DROP FUNCTION' are supported by prepared statements +CREATE FUNCTION f1() RETURNS INT RETURN 1; + +ALTER FUNCTION f1 SQL SECURITY INVOKER; + +DROP FUNCTION f1; + +--echo # Test case 6: Check that the statements 'CHECK TABLE' is supported +--echo # by prepared statements +CREATE TABLE t1 (a INT); +CHECK TABLE t1; +--echo # Clean up +DROP TABLE t1; + +--echo # Test case 7: Check that the statements BEGIN/SAVEPOINT/ +--echo # RELEASE SAVEPOINT is supported by prepared statements + +--echo # Set up environmentr for the test case +CREATE TABLE t1 (a INT); + +BEGIN; + +INSERT INTO t1 VALUES (1); + +SAVEPOINT s1; + +INSERT INTO t1 VALUES (2); +--echo # Expected rows: '1' and '2' +SELECT * FROM t1; +--echo # Rollback the last row inserted ('2') +ROLLBACK TO SAVEPOINT s1; +--echo # Expected output from t1 after transaction was rolled back +--echo # to the savepoint is '1'. If it is case then the statement SAVEPOINT +--echo # was handled successfully with prepared statement +SELECT * FROM t1; + +RELEASE SAVEPOINT s1; + +--echo # Clean up +DROP TABLE t1; + +--echo # Test case 8: Check that the statements 'PURGE BINARY LOGS BEFORE' +--echo # is supported by prepared statements +PURGE BINARY LOGS BEFORE '2020-11-17'; + +--echo # Check that the statements 'PURGE BINARY LOGS TO' is supported by +--echo # prepared statements +PURGE BINARY LOGS TO 'mariadb-bin.000063'; + +--echo # Test case 9: Check that the statements 'HANDLER OPEN/HANDLER READ/ +--echo # HANDLER CLOSE' are supported by prepared statements +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (1); +COMMIT; + +HANDLER t1 OPEN; +HANDLER t1 READ FIRST; +HANDLER t1 READ NEXT; +HANDLER t1 CLOSE; + +--echo # Clean up +DROP TABLE t1; + +--echo # Test case 10: Check that the statements 'HELP' +--echo # is supported by prepared statements +HELP `ALTER SERVER`; + +--echo # Test case 11: Check that the statements CREATE/ALTER/DROP PROCEDURE +--echo # are supported by prepared statements +CREATE PROCEDURE p1() SET @a=1; +ALTER PROCEDURE p1 SQL SECURITY INVOKER; +DROP PROCEDURE p1; + +--echo # Test case 12: Check that the statement 'CALL' is supported +--echo # by prepared statements. + +CREATE PROCEDURE p1() SET @a=1; +CALL p1(); + +--echo # Check that the @a variable has been set +SELECT @a; +DROP PROCEDURE p1; + +--echo # Test case 13: Check that the statements PREPARE FROM/EXECUTE/ +--echo # DEALLOCAT PREPARE can be executed as prepared statements. +PREPARE stmt_1 FROM 'SELECT 1'; + +--echo # Now execute the prepared statement with the name stmt_1 +--echo # It is expected that output contains the single row '1' +EXECUTE stmt_1; + +DEALLOCATE PREPARE stmt_1; + +--echo # Test case 14: Check that the statement 'CREATE VIEW' can be executed +--echo # as a prepared statement. +--echo # Create environment for the test case +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1); +COMMIT; + +CREATE VIEW v1 AS SELECT * FROM t1; +--echo # Query the view. Expected result is the row '1' +SELECT * FROM v1; +--echo # Clean up +DROP VIEW v1; +DROP TABLE t1; + +--echo # Test case 15: Check that the statements CREATE/DROP TRIGGER can be executed +--echo # as prepared statements. +CREATE TABLE t1 (a INT); +CREATE TRIGGER trg1 BEFORE INSERT ON t1 FOR EACH ROW SET @a=1; + +DROP TRIGGER trg1; +DROP TABLE t1; + +--echo # Test case 16: Check that XA related SQL statements can be executed in +--echo # as prepared statements. +--echo # Create the table t1 used by XA transaction. +CREATE TABLE t1 (a INT); +XA START 'xid1'; +INSERT INTO t1 VALUES (1); +XA END 'xid1'; +XA PREPARE 'xid1'; +XA RECOVER; +XA COMMIT 'xid1'; +--echo # Query the table t1 to check that it contains a record inserted by XA +--echo # transaction just committed. +SELECT * FROM t1; + +--echo # Check that XA ROLLBACK is supported by prepared statements + +--echo # First, clean up the table t1 that was filled by just +--echo # committed XA transaction +TRUNCATE TABLE t1; +XA START 'xid1'; +INSERT INTO t1 VALUES (1); +XA END 'xid1'; +XA PREPARE 'xid1'; +XA RECOVER; +XA ROLLBACK 'xid1'; + +--echo # Query the table t1 to check that it doesn't contain a record +--echo # inserted by XA transaction just rollbacked. +SELECT * FROM t1; + +--echo # Clean up +DROP TABLE t1; + +--echo # Test case 17: Check that the statements CREATE SERVER/ALTER SERVER/ +--echo # DROP SERVER can be executed +--echo # as a prepared statement. + +CREATE SERVER s FOREIGN DATA WRAPPER mysql OPTIONS (USER 'u1', HOST '127.0.0.1'); +ALTER SERVER s OPTIONS (USER 'u2'); +DROP SERVER s; + +--echo # Test case 18: Check that the statements CREATE EVENT/ALTER EVENT/ +--echo # DROP EVENT can be executed as a prepared statement + +--echo # Create the event e1 that specifies time in past. Such event is created +--echo # just for the sake of its existence and never will be triggered. +--echo # Disable warnings temprorary in order to hide the following warnings +--echo # generated in result of execution the 'CREATE EVENT' statement: +--echo # "1544 | Event execution time is in the past. Event has been disabled" +--echo # "1105 | Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it." + +--disable_warnings + +CREATE EVENT e1 ON SCHEDULE AT CURRENT_TIMESTAMP - INTERVAL 1 DAY ON COMPLETION PRESERVE DO SET @a=1; + +ALTER EVENT e1 COMMENT 'New comment'; + +DROP EVENT IF EXISTS e1; + +--enable_warnings + +--echo # Test case 19: Check that the statement 'SHOW RELAYLOG EVENTS' can be +--echo # executed as a prepared statement. +SHOW RELAYLOG EVENTS; + +--echo # Test case 20: Check the the statement 'EXECUTE IMMEDIATE' +--echo # can be executed as a prepared statement + +EXECUTE IMMEDIATE 'SELECT 1'; + +--echo # Test Test case 21: Check the statements 'BACKUP'/'BACKUP STAGE' +--echo # can be executed as a prepared statement +CREATE TABLE t1 (a INT); +BACKUP LOCK t1; +BACKUP UNLOCK; + +BACKUP STAGE START; +BACKUP STAGE BLOCK_COMMIT; +BACKUP STAGE END; + +DROP TABLE t1; + +--echo # Test case 22: Check the the statement 'GET DIAGNOSTICS' +--echo # can be executed as a prepared statement + +--echo # Query from non existent table to fill the diagnostics area with information +--error ER_NO_SUCH_TABLE +SELECT * FROM non_existent_table_1; +GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE, @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT; +--echo # Check that information from diagnostics area has been retrieved +SELECT @sqlstate, @errno, @text; +--echo # Clean up + +--echo # Test case 23: Check that the statements SIGNAL and RESIGNAL can be executed as +--echo # a prepared statement + +--error 30001 +SIGNAL SQLSTATE '45000' SET MYSQL_ERRNO=30001, MESSAGE_TEXT='Hello, world!'; + +--error ER_RESIGNAL_WITHOUT_ACTIVE_HANDLER +RESIGNAL SET MESSAGE_TEXT = 'New error message'; + +--echo # Test Test case 29: Check the statements 'CREATE/ALTER/DROP TABLEPSPACE' +--echo # can be executed as a prepared statement + +# Since MariaDB supports for tablespaces only on syntax level disable warnings +# before run CREATE/ALTER/DROP TABLESPACE statements in order to exclude +# the following in result output +# Warning 1478 Table storage engine 'InnoDB' does not support the create option 'TABLESPACE +--disable_warnings + +CREATE TABLESPACE ts1 ADD DATAFILE 'ts1.ibd' ENGINE=InnoDB; +ALTER TABLESPACE ts1 ADD DATAFILE 'ts1_1.ibd' ENGINE=InnoDB; +DROP TABLESPACE ts1 ENGINE=InnoDB; + +--enable_warnings + +SET default_storage_engine= @save_storage_engine; diff --git a/mysql-test/main/query_cache.result b/mysql-test/main/query_cache.result index 33e41a760f2..3a81b648171 100644 --- a/mysql-test/main/query_cache.result +++ b/mysql-test/main/query_cache.result @@ -1098,7 +1098,7 @@ call p1()// a 1 2 -drop procedure p1; +drop procedure p1// create function f1() returns int begin Declare var1 int; @@ -1111,13 +1111,13 @@ create procedure `p1`() begin select a, f1() from t1; end// -SET @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators; -SET GLOBAL log_bin_trust_function_creators = 1; +SET @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators// +SET GLOBAL log_bin_trust_function_creators = 1// call p1()// a f1() 1 2 2 2 -SET GLOBAL log_bin_trust_function_creators = @old_log_bin_trust_function_creators; +SET GLOBAL log_bin_trust_function_creators = @old_log_bin_trust_function_creators// drop procedure p1// drop function f1// drop table t1// diff --git a/mysql-test/main/query_cache.test b/mysql-test/main/query_cache.test index 939bf738fce..e49387dcaf4 100644 --- a/mysql-test/main/query_cache.test +++ b/mysql-test/main/query_cache.test @@ -810,7 +810,7 @@ open c1; select * from t1; end// call p1()// -drop procedure p1; +drop procedure p1// create function f1() returns int begin @@ -822,10 +822,10 @@ create procedure `p1`() begin select a, f1() from t1; end// -SET @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators; -SET GLOBAL log_bin_trust_function_creators = 1; +SET @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators// +SET GLOBAL log_bin_trust_function_creators = 1// call p1()// -SET GLOBAL log_bin_trust_function_creators = @old_log_bin_trust_function_creators; +SET GLOBAL log_bin_trust_function_creators = @old_log_bin_trust_function_creators// drop procedure p1// drop function f1// diff --git a/mysql-test/main/signal.result b/mysql-test/main/signal.result index b5b479db017..6a7f1c1e750 100644 --- a/mysql-test/main/signal.result +++ b/mysql-test/main/signal.result @@ -561,9 +561,7 @@ ERROR 42000: Bad SQLSTATE: '00001' # PART 2: non preparable statements # prepare stmt from 'SIGNAL SQLSTATE \'23000\''; -ERROR HY000: This command is not supported in the prepared statement protocol yet prepare stmt from 'RESIGNAL SQLSTATE \'23000\''; -ERROR HY000: This command is not supported in the prepared statement protocol yet # # PART 3: runtime execution # diff --git a/mysql-test/main/signal.test b/mysql-test/main/signal.test index 22cfc080895..97cd4d9a5d0 100644 --- a/mysql-test/main/signal.test +++ b/mysql-test/main/signal.test @@ -669,10 +669,7 @@ delimiter ;$$ --echo # PART 2: non preparable statements --echo # ---error ER_UNSUPPORTED_PS prepare stmt from 'SIGNAL SQLSTATE \'23000\''; - ---error ER_UNSUPPORTED_PS prepare stmt from 'RESIGNAL SQLSTATE \'23000\''; --echo # diff --git a/mysql-test/main/sp-dynamic.result b/mysql-test/main/sp-dynamic.result index 9fa3bea1108..ad11763b523 100644 --- a/mysql-test/main/sp-dynamic.result +++ b/mysql-test/main/sp-dynamic.result @@ -64,9 +64,8 @@ execute stmt; deallocate prepare stmt; end| call p1()| -ERROR HY000: This command is not supported in the prepared statement protocol yet call p1()| -ERROR HY000: This command is not supported in the prepared statement protocol yet +ERROR 42000: PROCEDURE p2 already exists drop procedure p1| create procedure p1() begin @@ -75,9 +74,8 @@ execute stmt; deallocate prepare stmt; end| call p1()| -ERROR HY000: This command is not supported in the prepared statement protocol yet call p1()| -ERROR HY000: This command is not supported in the prepared statement protocol yet +ERROR 42000: PROCEDURE test.p2 does not exist drop procedure p1| create procedure p1() begin @@ -295,15 +293,15 @@ select * from t1| id stmt_text status 1 select 1 supported 2 flush tables supported -3 handler t1 open as ha not supported +3 handler t1 open as ha supported 4 analyze table t1 supported -5 check table t1 not supported +5 check table t1 supported 6 checksum table t1 supported -7 check table t1 not supported +7 check table t1 supported 8 optimize table t1 supported 9 repair table t1 supported 10 describe extended select * from t1 supported -11 help help not supported +11 help help supported 12 show databases supported 13 show tables supported 14 show table status supported @@ -316,7 +314,7 @@ id stmt_text status 21 call p1() supported 22 foo bar syntax error 23 create view v1 as select 1 supported -24 alter view v1 as select 2 not supported +24 alter view v1 as select 2 supported 25 drop view v1 supported 26 create table t2 (a int) supported 27 alter table t2 add (b int) supported diff --git a/mysql-test/main/sp-dynamic.test b/mysql-test/main/sp-dynamic.test index 3a467e26818..5749a83a27b 100644 --- a/mysql-test/main/sp-dynamic.test +++ b/mysql-test/main/sp-dynamic.test @@ -68,9 +68,8 @@ begin execute stmt; deallocate prepare stmt; end| ---error ER_UNSUPPORTED_PS call p1()| ---error ER_UNSUPPORTED_PS +--error ER_SP_ALREADY_EXISTS call p1()| drop procedure p1| create procedure p1() @@ -79,9 +78,8 @@ begin execute stmt; deallocate prepare stmt; end| ---error ER_UNSUPPORTED_PS call p1()| ---error ER_UNSUPPORTED_PS +--error ER_SP_DOES_NOT_EXIST call p1()| drop procedure p1| # diff --git a/mysql-test/main/sp-security.result b/mysql-test/main/sp-security.result index 2c48883a509..2571f9d8696 100644 --- a/mysql-test/main/sp-security.result +++ b/mysql-test/main/sp-security.result @@ -347,6 +347,7 @@ create function bug12812() returns char(2) begin return 'ok'; end; +| create user user_bug12812@localhost IDENTIFIED BY 'ABC'| connect test_user_12812,localhost,user_bug12812,ABC,test; SELECT test.bug12812()| diff --git a/mysql-test/main/sp-security.test b/mysql-test/main/sp-security.test index e7790bf703a..e11e8911b60 100644 --- a/mysql-test/main/sp-security.test +++ b/mysql-test/main/sp-security.test @@ -465,6 +465,7 @@ create function bug12812() returns char(2) begin return 'ok'; end; +| create user user_bug12812@localhost IDENTIFIED BY 'ABC'| --replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK connect (test_user_12812,localhost,user_bug12812,ABC,test)| diff --git a/sql/item.cc b/sql/item.cc index 90ab78cec0a..3cede11a415 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -5531,14 +5531,9 @@ Item_field::fix_outer_field(THD *thd, Field **from_field, Item **reference) */ Name_resolution_context *last_checked_context= context; Item **ref= (Item **) not_found_item; - SELECT_LEX *current_sel= thd->lex->current_select; Name_resolution_context *outer_context= 0; SELECT_LEX *select= 0; - /* Currently derived tables cannot be correlated */ - if ((current_sel->master_unit()->first_select()->get_linkage() != - DERIVED_TABLE_TYPE) && - current_sel->master_unit()->outer_select()) - outer_context= context->outer_context; + outer_context= context->outer_context; /* This assert is to ensure we have an outer contex when *from_field diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index c39fbf54f13..381f015ca96 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -1270,7 +1270,8 @@ Item_singlerow_subselect::select_transformer(JOIN *join) DBUG_ASSERT(join->thd == thd); SELECT_LEX *select_lex= join->select_lex; - Query_arena *arena= thd->stmt_arena; + Query_arena *arena, backup; + arena= thd->activate_stmt_arena_if_needed(&backup); if (!select_lex->master_unit()->is_unit_op() && !select_lex->table_list.elements && @@ -1286,12 +1287,7 @@ Item_singlerow_subselect::select_transformer(JOIN *join) !(select_lex->item_list.head()->type() == FIELD_ITEM || select_lex->item_list.head()->type() == REF_ITEM) && !join->conds && !join->having && - /* - switch off this optimization for prepare statement, - because we do not rollback this changes - TODO: make rollback for it, or special name resolving mode in 5.0. - */ - !arena->is_stmt_prepare_or_first_sp_execute() + thd->stmt_arena->state != Query_arena::STMT_INITIALIZED_FOR_SP ) { have_to_be_excluded= 1; @@ -1310,6 +1306,8 @@ Item_singlerow_subselect::select_transformer(JOIN *join) substitution->fix_after_pullout(select_lex->outer_select(), &substitution, TRUE); } + if (arena) + thd->restore_active_arena(arena, &backup); DBUG_RETURN(false); } diff --git a/sql/protocol.h b/sql/protocol.h index 0a309ee75be..f095ad68a34 100644 --- a/sql/protocol.h +++ b/sql/protocol.h @@ -188,10 +188,6 @@ public: bool net_send_error(THD *thd, uint sql_errno, const char *err, const char* sqlstate); void end_statement(); - - friend int send_answer_1(Protocol *protocol, String *s1, String *s2, - String *s3); - friend int send_header_2(Protocol *protocol, bool for_category); }; diff --git a/sql/set_var.cc b/sql/set_var.cc index 8e2e8b12a06..724225f1058 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -825,6 +825,11 @@ int set_var::check(THD *thd) */ int set_var::light_check(THD *thd) { + if (var->is_readonly()) + { + my_error(ER_INCORRECT_GLOBAL_LOCAL_VAR, MYF(0), var->name.str, "read only"); + return -1; + } if (var->check_type(type)) { int err= type == OPT_GLOBAL ? ER_LOCAL_VARIABLE : ER_GLOBAL_VARIABLE; diff --git a/sql/sql_admin.cc b/sql/sql_admin.cc index aa66291929c..1c32e9d57cc 100644 --- a/sql/sql_admin.cc +++ b/sql/sql_admin.cc @@ -489,6 +489,38 @@ static bool wsrep_toi_replication(THD *thd, TABLE_LIST *tables) } #endif /* WITH_WSREP */ + +/** + Collect field names of result set that will be sent to a client + + @param thd Thread data object + @param[out] fields List of fields whose metadata should be collected for + sending to client +*/ + +void fill_check_table_metadata_fields(THD *thd, List* fields) +{ + Item *item; + + item= new (thd->mem_root) Item_empty_string(thd, "Table", NAME_CHAR_LEN * 2); + item->set_maybe_null(); + fields->push_back(item, thd->mem_root); + + item= new (thd->mem_root) Item_empty_string(thd, "Op", 10); + item->set_maybe_null(); + fields->push_back(item, thd->mem_root); + + item= new (thd->mem_root) Item_empty_string(thd, "Msg_type", 10); + item->set_maybe_null(); + fields->push_back(item, thd->mem_root); + + item= new (thd->mem_root) Item_empty_string(thd, "Msg_text", + SQL_ADMIN_MSG_TEXT_SIZE); + item->set_maybe_null(); + fields->push_back(item, thd->mem_root); +} + + /* RETURN VALUES FALSE Message sent to net (admin operation went ok) @@ -512,7 +544,6 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, { TABLE_LIST *table; List field_list; - Item *item; Protocol *protocol= thd->protocol; LEX *lex= thd->lex; int result_code; @@ -524,21 +555,8 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, DBUG_ENTER("mysql_admin_table"); DBUG_PRINT("enter", ("extra_open_options: %u", extra_open_options)); - field_list.push_back(item= new (thd->mem_root) - Item_empty_string(thd, "Table", - NAME_CHAR_LEN * 2), thd->mem_root); - item->set_maybe_null(); - field_list.push_back(item= new (thd->mem_root) - Item_empty_string(thd, "Op", 10), thd->mem_root); - item->set_maybe_null(); - field_list.push_back(item= new (thd->mem_root) - Item_empty_string(thd, "Msg_type", 10), thd->mem_root); - item->set_maybe_null(); - field_list.push_back(item= new (thd->mem_root) - Item_empty_string(thd, "Msg_text", - SQL_ADMIN_MSG_TEXT_SIZE), - thd->mem_root); - item->set_maybe_null(); + fill_check_table_metadata_fields(thd, &field_list); + if (protocol->send_result_set_metadata(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) DBUG_RETURN(TRUE); diff --git a/sql/sql_admin.h b/sql/sql_admin.h index d31726d32a4..0c7f1c3cee5 100644 --- a/sql/sql_admin.h +++ b/sql/sql_admin.h @@ -24,7 +24,7 @@ bool mysql_assign_to_keycache(THD* thd, TABLE_LIST* table_list, bool mysql_preload_keys(THD* thd, TABLE_LIST* table_list); int reassign_keycache_tables(THD* thd, KEY_CACHE *src_cache, KEY_CACHE *dst_cache); - +void fill_check_table_metadata_fields(THD *thd, List* fields); /** Sql_cmd_analyze_table represents the ANALYZE TABLE statement. */ diff --git a/sql/sql_help.cc b/sql/sql_help.cc index ce29846e2f8..f9932f11798 100644 --- a/sql/sql_help.cc +++ b/sql/sql_help.cc @@ -430,6 +430,46 @@ void get_all_items_for_category(THD *thd, TABLE *items, Field *pfname, DBUG_VOID_RETURN; } + +/** + Collect field names of HELP header that will be sent to a client + + @param thd Thread data object + @param[out] field_list List of fields whose metadata should be collected for + sending to client +*/ + +static void fill_answer_1_fields(THD *thd, List *field_list) +{ + MEM_ROOT *mem_root= thd->mem_root; + + field_list->push_back(new (mem_root) Item_empty_string(thd, "name", 64), + mem_root); + field_list->push_back(new (mem_root) Item_empty_string(thd, "description", + 1000), + mem_root); + field_list->push_back(new (mem_root) Item_empty_string(thd, "example", 1000), + mem_root); +} + + +/** + Send metadata of an answer on help request to a client + + @param protocol protocol for sending +*/ + +static bool send_answer_1_metadata(Protocol *protocol) +{ + List field_list; + + fill_answer_1_fields(protocol->thd, &field_list); + return protocol->send_result_set_metadata(&field_list, + Protocol::SEND_NUM_ROWS | + Protocol::SEND_EOF); +} + + /* Send to client answer for help request @@ -455,22 +495,11 @@ void get_all_items_for_category(THD *thd, TABLE *items, Field *pfname, 0 Successeful send */ -int send_answer_1(Protocol *protocol, String *s1, String *s2, String *s3) +static int send_answer_1(Protocol *protocol, String *s1, String *s2, String *s3) { - THD *thd= protocol->thd; - MEM_ROOT *mem_root= thd->mem_root; DBUG_ENTER("send_answer_1"); - List field_list; - field_list.push_back(new (mem_root) Item_empty_string(thd, "name", 64), - mem_root); - field_list.push_back(new (mem_root) Item_empty_string(thd, "description", 1000), - mem_root); - field_list.push_back(new (mem_root) Item_empty_string(thd, "example", 1000), - mem_root); - - if (protocol->send_result_set_metadata(&field_list, - Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) + if (send_answer_1_metadata(protocol)) DBUG_RETURN(1); protocol->prepare_for_resend(); @@ -483,13 +512,39 @@ int send_answer_1(Protocol *protocol, String *s1, String *s2, String *s3) } +/** + Collect field names of HELP header that will be sent to a client + + @param thd Thread data object + @param[out] field_list List of fields whose metadata should be collected for + sending to client + @param for_category need column 'source_category_name' +*/ + +static void fill_header_2_fields(THD *thd, List *field_list, + bool for_category) +{ + MEM_ROOT *mem_root= thd->mem_root; + if (for_category) + field_list->push_back(new (mem_root) + Item_empty_string(thd, "source_category_name", 64), + mem_root); + field_list->push_back(new (mem_root) + Item_empty_string(thd, "name", 64), + mem_root); + field_list->push_back(new (mem_root) + Item_empty_string(thd, "is_it_category", 1), + mem_root); +} + + /* Send to client help header SYNOPSIS send_header_2() protocol - protocol for sending - is_it_category - need column 'source_category_name' + for_category - need column 'source_category_name' IMPLEMENTATION +- -+ @@ -504,22 +559,12 @@ int send_answer_1(Protocol *protocol, String *s1, String *s2, String *s3) result of protocol->send_result_set_metadata */ -int send_header_2(Protocol *protocol, bool for_category) +static int send_header_2(Protocol *protocol, bool for_category) { - THD *thd= protocol->thd; - MEM_ROOT *mem_root= thd->mem_root; DBUG_ENTER("send_header_2"); List field_list; - if (for_category) - field_list.push_back(new (mem_root) - Item_empty_string(thd, "source_category_name", 64), - mem_root); - field_list.push_back(new (mem_root) - Item_empty_string(thd, "name", 64), - mem_root); - field_list.push_back(new (mem_root) - Item_empty_string(thd, "is_it_category", 1), - mem_root); + + fill_header_2_fields(protocol->thd, &field_list, for_category); DBUG_RETURN(protocol->send_result_set_metadata(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)); @@ -639,7 +684,6 @@ SQL_SELECT *prepare_simple_select(THD *thd, Item *cond, thd Thread handler mask mask for compare with name mlen length of mask - tables list of tables, used in WHERE table goal table pfname field "name" in table @@ -650,8 +694,7 @@ SQL_SELECT *prepare_simple_select(THD *thd, Item *cond, */ SQL_SELECT *prepare_select_for_name(THD *thd, const char *mask, size_t mlen, - TABLE_LIST *tables, TABLE *table, - Field *pfname, int *error) + TABLE *table, Field *pfname, int *error) { MEM_ROOT *mem_root= thd->mem_root; Item *cond= new (mem_root) @@ -668,6 +711,205 @@ SQL_SELECT *prepare_select_for_name(THD *thd, const char *mask, size_t mlen, } +/** + Initialize the TABLE_LIST with tables used in HELP statement handling. + + @param thd Thread handler + @param tables Array of four TABLE_LIST objects to initialize with data + about the tables help_topic, help_category, help_relation, + help_keyword +*/ + +static void initialize_tables_for_help_command(THD *thd, TABLE_LIST *tables) +{ + LEX_CSTRING MYSQL_HELP_TOPIC_NAME= {STRING_WITH_LEN("help_topic") }; + LEX_CSTRING MYSQL_HELP_CATEGORY_NAME= {STRING_WITH_LEN("help_category") }; + LEX_CSTRING MYSQL_HELP_RELATION_NAME= {STRING_WITH_LEN("help_relation") }; + LEX_CSTRING MYSQL_HELP_KEYWORD_NAME= {STRING_WITH_LEN("help_keyword") }; + + tables[0].init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_HELP_TOPIC_NAME, 0, + TL_READ); + tables[1].init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_HELP_CATEGORY_NAME, 0, + TL_READ); + tables[2].init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_HELP_RELATION_NAME, 0, + TL_READ); + tables[3].init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_HELP_KEYWORD_NAME, 0, + TL_READ); + tables[0].next_global= tables[0].next_local= + tables[0].next_name_resolution_table= &tables[1]; + tables[1].next_global= tables[1].next_local= + tables[1].next_name_resolution_table= &tables[2]; + tables[2].next_global= tables[2].next_local= + tables[2].next_name_resolution_table= &tables[3]; +} + + +/** + Setup tables and fields for query. + + @param thd Thread handler + @param first_select_lex SELECT_LEX of the parsed statement + @param tables Array of tables used in handling of the HELP + statement + @param used_fields Array of fields used in handling of the HELP + statement + + @return false on success, else true. +*/ + +template +static bool init_items_for_help_command(THD *thd, + SELECT_LEX *first_select_lex, + TABLE_LIST (&tables)[M], + st_find_field (& used_fields)[N]) +{ + List leaves; + + /* + Initialize tables and fields to be usable from items. + tables do not contain VIEWs => we can pass 0 as conds + */ + first_select_lex->context.table_list= + first_select_lex->context.first_name_resolution_table= + &tables[0]; + + if (setup_tables(thd, &first_select_lex->context, + &first_select_lex->top_join_list, + &tables[0], leaves, false, false)) + return true; + + memcpy((char*) used_fields, (char*) init_used_fields, + sizeof(used_fields[0]) * N); + if (init_fields(thd, &tables[0], used_fields, N)) + return true; + + for (size_t i= 0; i < M; i++) + tables[i].table->file->init_table_handle_for_HANDLER(); + + return false; +} + + +/** + Prepare (in the sense of prepared statement) the HELP statement. + + @param thd Thread handler + @param mask string value passed to the HELP statement + @oaram[out] fields fields for result set metadata + + @return false on success, else true. +*/ + +bool mysqld_help_prepare(THD *thd, const char *mask, List *fields) +{ + TABLE_LIST tables[4]; + st_find_field used_fields[array_elements(init_used_fields)]; + SQL_SELECT *select; + + List topics_list; + + Sql_mode_instant_remove sms(thd, MODE_PAD_CHAR_TO_FULL_LENGTH); + initialize_tables_for_help_command(thd, tables); + + /* + HELP must be available under LOCK TABLES. + Reset and backup the current open tables state to + make it possible. + */ + start_new_trans new_trans(thd); + + if (open_system_tables_for_read(thd, tables)) + return true; + + auto cleanup_and_return= [&](bool ret) + { + thd->commit_whole_transaction_and_close_tables(); + new_trans.restore_old_transaction(); + return ret; + }; + + if (init_items_for_help_command(thd, thd->lex->first_select_lex(), + tables, used_fields)) + return cleanup_and_return(false); + + size_t mlen= strlen(mask); + int error; + + /* + Prepare the query 'SELECT * FROM help_topic WHERE name LIKE mask' + for execution + */ + if (!(select= + prepare_select_for_name(thd,mask, mlen, tables[0].table, + used_fields[help_topic_name].field, &error))) + return cleanup_and_return(true); + + String name, description, example; + /* + Run the query 'SELECT * FROM help_topic WHERE name LIKE mask' + */ + int count_topics= search_topics(thd, tables[0].table, used_fields, + select, &topics_list, + &name, &description, &example); + delete select; + + if (thd->is_error()) + return cleanup_and_return(true); + + if (count_topics == 0) + { + int UNINIT_VAR(key_id); + /* + Prepare the query 'SELECT * FROM help_keyword WHERE name LIKE mask' + for execution + */ + if (!(select= + prepare_select_for_name(thd, mask, mlen, tables[3].table, + used_fields[help_keyword_name].field, + &error))) + return cleanup_and_return(true); + + /* + Run the query 'SELECT * FROM help_keyword WHERE name LIKE mask' + */ + count_topics= search_keyword(thd,tables[3].table, used_fields, select, + &key_id); + delete select; + count_topics= (count_topics != 1) ? 0 : + get_topics_for_keyword(thd, tables[0].table, tables[2].table, + used_fields, key_id, &topics_list, &name, + &description, &example); + + } + + if (count_topics == 0) + { + if (!(select= + prepare_select_for_name(thd, mask, mlen, tables[1].table, + used_fields[help_category_name].field, + &error))) + return cleanup_and_return(true); + + List categories_list; + int16 category_id; + int count_categories= search_categories(thd, tables[1].table, used_fields, + select, + &categories_list,&category_id); + delete select; + if (count_categories == 1) + fill_header_2_fields(thd, fields, true); + else + fill_header_2_fields(thd, fields, false); + } + else if (count_topics == 1) + fill_answer_1_fields(thd, fields); + else + fill_header_2_fields(thd, fields, false); + + return cleanup_and_return(false); +} + + /* Server-side function 'help' @@ -685,30 +927,15 @@ static bool mysqld_help_internal(THD *thd, const char *mask) Protocol *protocol= thd->protocol; SQL_SELECT *select; st_find_field used_fields[array_elements(init_used_fields)]; - List leaves; TABLE_LIST tables[4]; List topics_list, categories_list, subcategories_list; String name, description, example; int count_topics, count_categories, error; size_t mlen= strlen(mask); - size_t i; MEM_ROOT *mem_root= thd->mem_root; - LEX_CSTRING MYSQL_HELP_TOPIC_NAME= {STRING_WITH_LEN("help_topic") }; - LEX_CSTRING MYSQL_HELP_CATEGORY_NAME= {STRING_WITH_LEN("help_category") }; - LEX_CSTRING MYSQL_HELP_RELATION_NAME= {STRING_WITH_LEN("help_relation") }; - LEX_CSTRING MYSQL_HELP_KEYWORD_NAME= {STRING_WITH_LEN("help_keyword") }; DBUG_ENTER("mysqld_help"); - tables[0].init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_HELP_TOPIC_NAME, 0, TL_READ); - tables[1].init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_HELP_CATEGORY_NAME, 0, TL_READ); - tables[2].init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_HELP_RELATION_NAME, 0, TL_READ); - tables[3].init_one_table(&MYSQL_SCHEMA_NAME, &MYSQL_HELP_KEYWORD_NAME, 0, TL_READ); - tables[0].next_global= tables[0].next_local= - tables[0].next_name_resolution_table= &tables[1]; - tables[1].next_global= tables[1].next_local= - tables[1].next_name_resolution_table= &tables[2]; - tables[2].next_global= tables[2].next_local= - tables[2].next_name_resolution_table= &tables[3]; + initialize_tables_for_help_command(thd, tables); /* HELP must be available under LOCK TABLES. @@ -720,25 +947,12 @@ static bool mysqld_help_internal(THD *thd, const char *mask) if (open_system_tables_for_read(thd, tables)) goto error2; - /* - Init tables and fields to be usable from items - tables do not contain VIEWs => we can pass 0 as conds - */ - thd->lex->first_select_lex()->context.table_list= - thd->lex->first_select_lex()->context.first_name_resolution_table= - &tables[0]; - if (setup_tables(thd, &thd->lex->first_select_lex()->context, - &thd->lex->first_select_lex()->top_join_list, - tables, leaves, FALSE, FALSE)) + if (init_items_for_help_command(thd, thd->lex->first_select_lex(), + tables, used_fields)) goto error; - memcpy((char*) used_fields, (char*) init_used_fields, sizeof(used_fields)); - if (init_fields(thd, tables, used_fields, array_elements(used_fields))) - goto error; - for (i=0; ifile->init_table_handle_for_HANDLER(); if (!(select= - prepare_select_for_name(thd,mask,mlen,tables,tables[0].table, + prepare_select_for_name(thd,mask,mlen,tables[0].table, used_fields[help_topic_name].field,&error))) goto error; @@ -754,7 +968,7 @@ static bool mysqld_help_internal(THD *thd, const char *mask) { int UNINIT_VAR(key_id); if (!(select= - prepare_select_for_name(thd,mask,mlen,tables,tables[3].table, + prepare_select_for_name(thd,mask,mlen,tables[3].table, used_fields[help_keyword_name].field, &error))) goto error; @@ -773,7 +987,7 @@ static bool mysqld_help_internal(THD *thd, const char *mask) int16 category_id; Field *cat_cat_id= used_fields[help_category_parent_category_id].field; if (!(select= - prepare_select_for_name(thd,mask,mlen,tables,tables[1].table, + prepare_select_for_name(thd,mask,mlen,tables[1].table, used_fields[help_category_name].field, &error))) goto error; @@ -841,7 +1055,7 @@ static bool mysqld_help_internal(THD *thd, const char *mask) send_variant_2_list(mem_root,protocol, &topics_list, "N", 0)) goto error; if (!(select= - prepare_select_for_name(thd,mask,mlen,tables,tables[1].table, + prepare_select_for_name(thd,mask,mlen,tables[1].table, used_fields[help_category_name].field,&error))) goto error; search_categories(thd, tables[1].table, used_fields, diff --git a/sql/sql_help.h b/sql/sql_help.h index cb3314b756c..b0117649f03 100644 --- a/sql/sql_help.h +++ b/sql/sql_help.h @@ -25,4 +25,6 @@ class THD; bool mysqld_help (THD *thd, const char *text); +bool mysqld_help_prepare(THD *thd, const char *text, List *fields); + #endif /* SQL_HELP_INCLUDED */ diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 45e5f2381bd..6df1996409c 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -869,7 +869,7 @@ public: // Ensures that at least all members used during cleanup() are initialized. st_select_lex_unit() : union_result(NULL), table(NULL), result(NULL), fake_select_lex(NULL), - cleaned(false), bag_set_op_optimized(false), + last_procedure(NULL),cleaned(false), bag_set_op_optimized(false), have_except_all_or_intersect_all(false) { } diff --git a/sql/sql_load.cc b/sql/sql_load.cc index 49de7f73cab..2f1ee0b11bd 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -44,6 +44,8 @@ #include "wsrep_mysqld.h" +#include "scope.h" // scope_exit + extern "C" int _my_b_net_read(IO_CACHE *info, uchar *Buffer, size_t Count); class XML_TAG { @@ -444,6 +446,12 @@ int mysql_load(THD *thd, const sql_exchange *ex, TABLE_LIST *table_list, if (check_duplic_insert_without_overlaps(thd, table, handle_duplicates) != 0) DBUG_RETURN(true); + auto scope_cleaner = make_scope_exit( + [&fields_vars]() { + fields_vars.empty(); + } + ); + if (!fields_vars.elements) { Field_iterator_table_ref field_iterator; @@ -471,6 +479,7 @@ int mysql_load(THD *thd, const sql_exchange *ex, TABLE_LIST *table_list, } else { // Part field list + scope_cleaner.release(); /* TODO: use this conds for 'WITH CHECK OPTIONS' */ if (setup_fields(thd, Ref_ptr_array(), fields_vars, MARK_COLUMNS_WRITE, 0, NULL, 0) || diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index c99d3fb3e75..9fc64f891d6 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -3432,7 +3432,7 @@ bool run_set_statement_if_requested(THD *thd, LEX *lex) */ int -mysql_execute_command(THD *thd) +mysql_execute_command(THD *thd, bool is_called_from_prepared_stmt) { int res= 0; int up_result= 0; @@ -5259,7 +5259,7 @@ mysql_execute_command(THD *thd) } while (0); /* Don't do it, if we are inside a SP */ - if (!thd->spcont) + if (!thd->spcont && !is_called_from_prepared_stmt) { sp_head::destroy(lex->sphead); lex->sphead= NULL; diff --git a/sql/sql_parse.h b/sql/sql_parse.h index eddaa9d87e1..ebe3fe97114 100644 --- a/sql/sql_parse.h +++ b/sql/sql_parse.h @@ -100,7 +100,7 @@ bool multi_delete_set_locks_and_link_aux_tables(LEX *lex); void create_table_set_open_action_and_adjust_tables(LEX *lex); int bootstrap(MYSQL_FILE *file); bool run_set_statement_if_requested(THD *thd, LEX *lex); -int mysql_execute_command(THD *thd); +int mysql_execute_command(THD *thd, bool is_called_from_prepared_stmt=false); enum dispatch_command_return { DISPATCH_COMMAND_SUCCESS=0, diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 2b6cbce98e1..1510844a7e7 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -89,6 +89,7 @@ When one supplies long data for a placeholder: #include "unireg.h" #include "sql_class.h" // set_var.h: THD #include "set_var.h" +#include "sql_admin.h" // fill_check_table_metadata_fields #include "sql_prepare.h" #include "sql_parse.h" // insert_precheck, update_precheck, delete_precheck #include "sql_base.h" // open_normal_and_derived_tables @@ -105,6 +106,8 @@ When one supplies long data for a placeholder: #include "sql_cursor.h" #include "sql_show.h" #include "sql_repl.h" +#include "sql_help.h" // mysqld_help_prepare +#include "sql_table.h" // fill_checksum_table_metadata_fields #include "slave.h" #include "sp_head.h" #include "sp.h" @@ -129,6 +132,7 @@ static const uint PARAMETER_FLAG_UNSIGNED= 128U << 8; #include "wsrep_mysqld.h" #include "wsrep_trans_observer.h" #endif /* WITH_WSREP */ +#include "xa.h" // xa_recover_get_fields /** A result class used to send cursor rows using the binary protocol. @@ -179,6 +183,7 @@ public: my_bool iterations; my_bool start_param; my_bool read_types; + #ifndef EMBEDDED_LIBRARY bool (*set_params)(Prepared_statement *st, uchar *data, uchar *data_end, uchar *read_pos, String *expanded_query); @@ -1255,11 +1260,17 @@ insert_params_from_actual_params_with_log(Prepared_statement *stmt, DBUG_RETURN(0); } -/** + +/* Validate INSERT statement. @param stmt prepared statement - @param tables global/local table list + @param table_list global/local table list + @param fields list of the table's fields to insert values + @param values_list values to be inserted into the table + @param update_fields the update fields. + @param update_values the update values. + @param duplic a way to handle duplicates @retval FALSE success @@ -1267,29 +1278,18 @@ insert_params_from_actual_params_with_log(Prepared_statement *stmt, TRUE error, error message is set in THD */ -static bool mysql_test_insert(Prepared_statement *stmt, - TABLE_LIST *table_list, - List &fields, - List &values_list, - List &update_fields, - List &update_values, - enum_duplicates duplic) +static bool mysql_test_insert_common(Prepared_statement *stmt, + TABLE_LIST *table_list, + List &fields, + List &values_list, + List &update_fields, + List &update_values, + enum_duplicates duplic) { THD *thd= stmt->thd; List_iterator_fast its(values_list); List_item *values; - DBUG_ENTER("mysql_test_insert"); - - /* - Since INSERT DELAYED doesn't support temporary tables, we could - not pre-open temporary tables for SQLCOM_INSERT / SQLCOM_REPLACE. - Open them here instead. - */ - if (table_list->lock_type != TL_WRITE_DELAYED) - { - if (thd->open_temporary_tables(table_list)) - goto error; - } + DBUG_ENTER("mysql_test_insert_common"); if (insert_precheck(thd, table_list)) goto error; @@ -1356,6 +1356,44 @@ error: } +/** + Open temporary tables if required and validate INSERT statement. + + @param stmt prepared statement + @param tables global/local table list + + @retval + FALSE success + @retval + TRUE error, error message is set in THD +*/ + +static bool mysql_test_insert(Prepared_statement *stmt, + TABLE_LIST *table_list, + List &fields, + List &values_list, + List &update_fields, + List &update_values, + enum_duplicates duplic) +{ + THD *thd= stmt->thd; + + /* + Since INSERT DELAYED doesn't support temporary tables, we could + not pre-open temporary tables for SQLCOM_INSERT / SQLCOM_REPLACE. + Open them here instead. + */ + if (table_list->lock_type != TL_WRITE_DELAYED) + { + if (thd->open_temporary_tables(table_list)) + return true; + } + + return mysql_test_insert_common(stmt, table_list, fields, values_list, + update_fields, update_values, duplic); +} + + /** Validate UPDATE statement. @@ -2273,6 +2311,83 @@ static int mysql_test_handler_read(Prepared_statement *stmt, } +/** + Send metadata to a client on PREPARE phase of XA RECOVER statement + processing + + @param stmt prepared statement + + @return 0 on success, 1 on failure, 2 in case metadata was already sent +*/ + +static int mysql_test_xa_recover(Prepared_statement *stmt) +{ + THD *thd= stmt->thd; + List field_list; + + xa_recover_get_fields(thd, &field_list, nullptr); + return send_stmt_metadata(thd, stmt, &field_list); +} + + +/** + Send metadata to a client on PREPARE phase of HELP statement processing + + @param stmt prepared statement + + @return 0 on success, 1 on failure, 2 in case metadata was already sent +*/ + +static int mysql_test_help(Prepared_statement *stmt) +{ + THD *thd= stmt->thd; + List fields; + + if (mysqld_help_prepare(thd, stmt->lex->help_arg, &fields)) + return 1; + + return send_stmt_metadata(thd, stmt, &fields); +} + + +/** + Send metadata to a client on PREPARE phase of admin related statements + processing + + @param stmt prepared statement + + @return 0 on success, 1 on failure, 2 in case metadata was already sent +*/ + +static int mysql_test_admin_table(Prepared_statement *stmt) +{ + THD *thd= stmt->thd; + List fields; + + fill_check_table_metadata_fields(thd, &fields); + return send_stmt_metadata(thd, stmt, &fields); +} + + +/** + Send metadata to a client on PREPARE phase of CHECKSUM TABLE statement + processing + + @param stmt prepared statement + + @return 0 on success, 1 on failure, 2 in case metadata was already sent +*/ + +static int mysql_test_checksum_table(Prepared_statement *stmt) +{ + THD *thd= stmt->thd; + List fields; + + fill_checksum_table_metadata_fields(thd, &fields); + return send_stmt_metadata(thd, stmt, &fields); +} + + /** Perform semantic analysis of the parsed tree and send a response packet to the client. @@ -2347,6 +2462,13 @@ static bool check_prepared_statement(Prepared_statement *stmt) lex->duplicates); break; + case SQLCOM_LOAD: + res= mysql_test_insert_common(stmt, tables, lex->field_list, + lex->many_values, + lex->update_list, lex->value_list, + lex->duplicates); + break; + case SQLCOM_UPDATE: res= mysql_test_update(stmt, tables); /* mysql_test_update returns 2 if we need to switch to multi-update */ @@ -2483,11 +2605,6 @@ static bool check_prepared_statement(Prepared_statement *stmt) } break; case SQLCOM_CREATE_VIEW: - if (lex->create_view->mode == VIEW_ALTER) - { - my_message(ER_UNSUPPORTED_PS, ER_THD(thd, ER_UNSUPPORTED_PS), MYF(0)); - goto error; - } res= mysql_test_create_view(stmt); break; case SQLCOM_DO: @@ -2515,6 +2632,38 @@ static bool check_prepared_statement(Prepared_statement *stmt) /* Statement and field info has already been sent */ DBUG_RETURN(res == 1 ? TRUE : FALSE); + case SQLCOM_XA_RECOVER: + res= mysql_test_xa_recover(stmt); + if (res == 2) + /* Statement and field info has already been sent */ + DBUG_RETURN(false); + break; + + case SQLCOM_HELP: + res= mysql_test_help(stmt); + if (res == 2) + /* Statement and field info has already been sent */ + DBUG_RETURN(false); + break; + + case SQLCOM_ANALYZE: + case SQLCOM_ASSIGN_TO_KEYCACHE: + case SQLCOM_CHECK: + case SQLCOM_OPTIMIZE: + case SQLCOM_PRELOAD_KEYS: + case SQLCOM_REPAIR: + res= mysql_test_admin_table(stmt); + if (res == 2) + /* Statement and field info has already been sent */ + DBUG_RETURN(false); + break; + + case SQLCOM_CHECKSUM: + res= mysql_test_checksum_table(stmt); + if (res == 2) + /* Statement and field info has already been sent */ + DBUG_RETURN(false); + break; /* Note that we don't need to have cases in this list if they are marked with CF_STATUS_COMMAND in sql_command_flags @@ -2532,9 +2681,6 @@ static bool check_prepared_statement(Prepared_statement *stmt) case SQLCOM_ROLLBACK_TO_SAVEPOINT: case SQLCOM_TRUNCATE: case SQLCOM_DROP_VIEW: - case SQLCOM_REPAIR: - case SQLCOM_ANALYZE: - case SQLCOM_OPTIMIZE: case SQLCOM_CHANGE_MASTER: case SQLCOM_RESET: case SQLCOM_FLUSH: @@ -2547,15 +2693,12 @@ static bool check_prepared_statement(Prepared_statement *stmt) case SQLCOM_CREATE_DB: case SQLCOM_DROP_DB: case SQLCOM_ALTER_DB_UPGRADE: - case SQLCOM_CHECKSUM: case SQLCOM_CREATE_USER: case SQLCOM_ALTER_USER: case SQLCOM_RENAME_USER: case SQLCOM_DROP_USER: case SQLCOM_CREATE_ROLE: case SQLCOM_DROP_ROLE: - case SQLCOM_ASSIGN_TO_KEYCACHE: - case SQLCOM_PRELOAD_KEYS: case SQLCOM_GRANT: case SQLCOM_GRANT_ROLE: case SQLCOM_REVOKE: @@ -2564,22 +2707,10 @@ static bool check_prepared_statement(Prepared_statement *stmt) case SQLCOM_KILL: case SQLCOM_COMPOUND: case SQLCOM_SHUTDOWN: - break; - case SQLCOM_PREPARE: case SQLCOM_EXECUTE: case SQLCOM_DEALLOCATE_PREPARE: default: - /* - Trivial check of all status commands. This is easier than having - things in the above case list, as it's less chance for mistakes. - */ - if (!(sql_command_flags[sql_command] & CF_STATUS_COMMAND)) - { - /* All other statements are not supported yet. */ - my_message(ER_UNSUPPORTED_PS, ER_THD(thd, ER_UNSUPPORTED_PS), MYF(0)); - goto error; - } break; } if (res == 0) @@ -3484,7 +3615,7 @@ static void mysql_stmt_execute_common(THD *thd, SQLCOM_EXECUTE implementation. Execute prepared statement using parameter values from - lex->prepared_stmt_params and send result to the client using + lex->prepared_stmt.params() and send result to the client using text protocol. This is called from mysql_execute_command and therefore should behave like an ordinary query (e.g. not change global THD data, such as warning count, server status, etc). @@ -5042,7 +5173,7 @@ bool Prepared_statement::execute(String *expanded_query, bool open_cursor) MYSQL_QUERY_EXEC_START(thd->query(), thd->thread_id, thd->get_db(), &thd->security_ctx->priv_user[0], (char *) thd->security_ctx->host_or_ip, 1); - error= mysql_execute_command(thd); + error= mysql_execute_command(thd, true); MYSQL_QUERY_EXEC_DONE(error); } else @@ -6147,5 +6278,3 @@ extern "C" int execute_sql_command(const char *command, } #endif /*!EMBEDDED_LIBRARY*/ - - diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 16ac5e06809..66baff2efc1 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -11267,12 +11267,35 @@ bool mysql_recreate_table(THD *thd, TABLE_LIST *table_list, bool table_copy) } +/** + Collect field names of result set that will be sent to a client in result of + handling the CHECKSUM TABLE statement. + + @param thd Thread data object + @param[out] fields List of fields whose metadata should be collected for + sending to client + */ + +void fill_checksum_table_metadata_fields(THD *thd, List *fields) +{ + Item *item; + + item= new (thd->mem_root) Item_empty_string(thd, "Table", NAME_LEN*2); + item->set_maybe_null(); + fields->push_back(item, thd->mem_root); + + item= new (thd->mem_root) Item_int(thd, "Checksum", (longlong) 1, + MY_INT64_NUM_DECIMAL_DIGITS); + item->set_maybe_null(); + fields->push_back(item, thd->mem_root); +} + + bool mysql_checksum_table(THD *thd, TABLE_LIST *tables, HA_CHECK_OPT *check_opt) { TABLE_LIST *table; List field_list; - Item *item; Protocol *protocol= thd->protocol; DBUG_ENTER("mysql_checksum_table"); @@ -11282,15 +11305,8 @@ bool mysql_checksum_table(THD *thd, TABLE_LIST *tables, */ DBUG_ASSERT(! thd->in_sub_stmt); - field_list.push_back(item= new (thd->mem_root) - Item_empty_string(thd, "Table", NAME_LEN*2), - thd->mem_root); - item->set_maybe_null(); - field_list.push_back(item= new (thd->mem_root) - Item_int(thd, "Checksum", (longlong) 1, - MY_INT64_NUM_DECIMAL_DIGITS), - thd->mem_root); - item->set_maybe_null(); + fill_checksum_table_metadata_fields(thd, &field_list); + if (protocol->send_result_set_metadata(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) DBUG_RETURN(TRUE); diff --git a/sql/sql_table.h b/sql/sql_table.h index 81894999aac..aacb6c99f15 100644 --- a/sql/sql_table.h +++ b/sql/sql_table.h @@ -176,6 +176,8 @@ bool mysql_rename_table(handlerton *base, const LEX_CSTRING *old_db, bool mysql_backup_table(THD* thd, TABLE_LIST* table_list); bool mysql_restore_table(THD* thd, TABLE_LIST* table_list); +template class List; +void fill_checksum_table_metadata_fields(THD *thd, List *fields); bool mysql_checksum_table(THD* thd, TABLE_LIST* table_list, HA_CHECK_OPT* check_opt); bool mysql_rm_table(THD *thd,TABLE_LIST *tables, bool if_exists, @@ -204,7 +206,6 @@ int write_bin_log(THD *thd, bool clear_error, int write_bin_log_with_if_exists(THD *thd, bool clear_error, bool is_trans, bool add_if_exists); -template class List; void promote_first_timestamp_column(List *column_definitions); /* diff --git a/sql/xa.cc b/sql/xa.cc index e0defcb92ed..af7c7388c57 100644 --- a/sql/xa.cc +++ b/sql/xa.cc @@ -1001,23 +1001,29 @@ static my_bool xa_recover_callback_verbose(XID_cache_element *xs, } -bool mysql_xa_recover(THD *thd) -{ - List field_list; - Protocol *protocol= thd->protocol; - MEM_ROOT *mem_root= thd->mem_root; - my_hash_walk_action action; - DBUG_ENTER("mysql_xa_recover"); +/** + Collect field names of result set that will be sent to a client in result of + handling XA RECOVER statement. - field_list.push_back(new (mem_root) - Item_int(thd, "formatID", 0, - MY_INT32_NUM_DECIMAL_DIGITS), mem_root); - field_list.push_back(new (mem_root) - Item_int(thd, "gtrid_length", 0, - MY_INT32_NUM_DECIMAL_DIGITS), mem_root); - field_list.push_back(new (mem_root) - Item_int(thd, "bqual_length", 0, - MY_INT32_NUM_DECIMAL_DIGITS), mem_root); + @param thd Thread data object + @param[out] fields List of fields whose metadata should be collected for + sending to client +*/ + +void xa_recover_get_fields(THD *thd, List *field_list, + my_hash_walk_action *action) +{ + MEM_ROOT *mem_root= thd->mem_root; + + field_list->push_back(new (mem_root) + Item_int(thd, "formatID", 0, + MY_INT32_NUM_DECIMAL_DIGITS), mem_root); + field_list->push_back(new (mem_root) + Item_int(thd, "gtrid_length", 0, + MY_INT32_NUM_DECIMAL_DIGITS), mem_root); + field_list->push_back(new (mem_root) + Item_int(thd, "bqual_length", 0, + MY_INT32_NUM_DECIMAL_DIGITS), mem_root); { uint len; CHARSET_INFO *cs; @@ -1026,18 +1032,30 @@ bool mysql_xa_recover(THD *thd) { len= SQL_XIDSIZE; cs= &my_charset_utf8mb3_general_ci; - action= (my_hash_walk_action) xa_recover_callback_verbose; + if (action) + *action= (my_hash_walk_action) xa_recover_callback_verbose; } else { len= XIDDATASIZE; cs= &my_charset_bin; - action= (my_hash_walk_action) xa_recover_callback_short; + if (action) + *action= (my_hash_walk_action) xa_recover_callback_short; } - field_list.push_back(new (mem_root) - Item_empty_string(thd, "data", len, cs), mem_root); + field_list->push_back(new (mem_root) + Item_empty_string(thd, "data", len, cs), mem_root); } +} + +bool mysql_xa_recover(THD *thd) +{ + List field_list; + Protocol *protocol= thd->protocol; + my_hash_walk_action action; + DBUG_ENTER("mysql_xa_recover"); + + xa_recover_get_fields(thd, &field_list, &action); if (protocol->send_result_set_metadata(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) diff --git a/sql/xa.h b/sql/xa.h index 0b2d0696642..a9b06e427c6 100644 --- a/sql/xa.h +++ b/sql/xa.h @@ -53,4 +53,7 @@ bool trans_xa_rollback(THD *thd); bool trans_xa_detach(THD *thd); bool mysql_xa_recover(THD *thd); +void xa_recover_get_fields(THD *thd, List *field_list, + my_hash_walk_action *action); + #endif /* XA_INCLUDED */ From d5836a627746f928a8c6127503c1a0f11d8b4726 Mon Sep 17 00:00:00 2001 From: Dmitry Shulga Date: Thu, 22 Apr 2021 23:21:54 +0700 Subject: [PATCH 104/251] MDEV-16708: Unsupported commands for prepared statements Extended a set of commands that can be executed as prepared statements by a user with expired password --- sql/sql_prepare.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 1510844a7e7..2ef389011a2 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -4380,7 +4380,10 @@ bool Prepared_statement::prepare(const char *packet, uint packet_len) init_param_array(this)); if (thd->security_ctx->password_expired && - lex->sql_command != SQLCOM_SET_OPTION) + lex->sql_command != SQLCOM_SET_OPTION && + lex->sql_command != SQLCOM_PREPARE && + lex->sql_command != SQLCOM_EXECUTE && + lex->sql_command != SQLCOM_DEALLOCATE_PREPARE) { thd->restore_backup_statement(this, &stmt_backup); thd->restore_active_arena(this, &stmt_backup); From 327402291a8239579f8c80297bb01676d25ab25d Mon Sep 17 00:00:00 2001 From: Dmitry Shulga Date: Thu, 22 Apr 2021 23:57:49 +0700 Subject: [PATCH 105/251] MDEV-16708: Unsupported commands for prepared statements Extended a set of commands that can be executed via binary protocol by a user with expired password --- sql/sql_parse.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 9fc64f891d6..b1e7a12adac 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1672,7 +1672,8 @@ dispatch_command_return dispatch_command(enum enum_server_command command, THD * command != COM_PING && command != COM_QUIT && command != COM_STMT_PREPARE && - command != COM_STMT_EXECUTE)) + command != COM_STMT_EXECUTE && + command != COM_STMT_CLOSE)) { my_error(ER_MUST_CHANGE_PASSWORD, MYF(0)); goto dispatch_end; From 7586eead5d5f323d9d95b73c21de51e6b992d8c7 Mon Sep 17 00:00:00 2001 From: Dmitry Shulga Date: Mon, 26 Apr 2021 10:47:10 +0700 Subject: [PATCH 106/251] MDEV-16708: Unsupported commands for prepared statements Disable running of the statements PREPARE FROM/EXECUTE/EXECUTE IMMEDIATE/DEALLOCATE in PS mode. Adjust tests main.ps, main.ps_1general --- client/mysqltest.cc | 32 +++++++++- mysql-test/main/ps.result | 12 ++-- mysql-test/main/ps.test | 8 ++- mysql-test/main/ps_1general.result | 3 + mysql-test/main/ps_1general.test | 3 + mysql-test/main/ps_missed_cmds.result | 87 ++++---------------------- mysql-test/main/ps_missed_cmds.test | 88 ++++----------------------- sql/sql_prepare.cc | 48 ++------------- 8 files changed, 80 insertions(+), 201 deletions(-) diff --git a/client/mysqltest.cc b/client/mysqltest.cc index fb36c4b075d..0f052397d4f 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -258,6 +258,7 @@ static const char *opt_suite_dir, *opt_overlay_dir; static size_t suite_dir_len, overlay_dir_len; /* Precompiled re's */ +static regex_t ps_re; /* the query can be run using PS protocol */ static regex_t sp_re; /* the query can be run as a SP */ static regex_t view_re; /* the query can be run as a view*/ @@ -8721,7 +8722,14 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags) statement already and we can't do it twice */ if (ps_protocol_enabled && - complete_query) + complete_query && + /* + Check that a statement is not one of PREPARE FROM, EXECUTE, + DEALLOCATE PREPARE (possibly prefixed with the 'SET STATEMENT ... FOR' + clause. These statement shouldn't be run using prepared statement C API. + All other statements can be run using prepared statement C API. + */ + !match_re(&ps_re, query)) run_query_stmt(cn, command, query, query_len, ds, &ds_warnings); else run_query_normal(cn, command, flags, query, query_len, @@ -8794,6 +8802,26 @@ void init_re_comp(regex_t *re, const char* str) void init_re(void) { + /* + * Prior to the task MDEV-16708 a value of the string ps_re_str contained + * a regular expression to match statements that SHOULD BE run in PS mode. + * The task MDEV-16708 modifies interpretation of this regular expression + * and now it is used for matching statements that SHOULDN'T be run in + * PS mode. These statement are PREPARE FROM, EXECUTE, DEALLOCATE PREPARE + * possibly prefixed with the clause SET STATEMENT ... FOR + */ + const char *ps_re_str = + "^(" + "[[:space:]]*PREPARE[[:space:]]|" + "[[:space:]]*EXECUTE[[:space:]]|" + "[[:space:]]*DEALLOCATE[[:space:]]+PREPARE[[:space:]]|" + "[[:space:]]*DROP[[:space:]]+PREPARE[[:space:]]|" + "(SET[[:space:]]+STATEMENT[[:space:]]+.+[[:space:]]+FOR[[:space:]]+)?" + "EXECUTE[[:space:]]+|" + "(SET[[:space:]]+STATEMENT[[:space:]]+.+[[:space:]]+FOR[[:space:]]+)?" + "PREPARE[[:space:]]+" + ")"; + /* Filter for queries that can be run using the Stored procedures @@ -8858,6 +8886,7 @@ void init_re(void) "^(" "[[:space:]]*SELECT[[:space:]])"; + init_re_comp(&ps_re, ps_re_str); init_re_comp(&sp_re, sp_re_str); init_re_comp(&view_re, view_re_str); } @@ -8893,6 +8922,7 @@ int match_re(regex_t *re, char *str) void free_re(void) { + regfree(&ps_re); regfree(&sp_re); regfree(&view_re); } diff --git a/mysql-test/main/ps.result b/mysql-test/main/ps.result index 70ea6870368..eb17def9a4b 100644 --- a/mysql-test/main/ps.result +++ b/mysql-test/main/ps.result @@ -28,9 +28,11 @@ ERROR HY000: Unknown prepared statement handler (no_such_statement) given to DEA execute stmt1; ERROR HY000: Incorrect arguments to EXECUTE prepare stmt2 from 'prepare nested_stmt from "select 1"'; +ERROR HY000: This command is not supported in the prepared statement protocol yet prepare stmt2 from 'execute stmt1'; +ERROR HY000: This command is not supported in the prepared statement protocol yet prepare stmt2 from 'deallocate prepare z'; -deallocate prepare stmt2; +ERROR HY000: This command is not supported in the prepared statement protocol yet prepare stmt3 from 'insert into t1 values (?,?)'; set @arg1=5, @arg2='five'; execute stmt3 using @arg1, @arg2; @@ -4719,13 +4721,13 @@ ERROR HY000: Incorrect arguments to EXECUTE EXECUTE IMMEDIATE 'SELECT ?'; ERROR HY000: Incorrect arguments to EXECUTE EXECUTE IMMEDIATE 'EXECUTE IMMEDIATE "SELECT 1"'; -1 -1 +ERROR HY000: This command is not supported in the prepared statement protocol yet EXECUTE IMMEDIATE 'PREPARE stmt FROM "SELECT 1"'; +ERROR HY000: This command is not supported in the prepared statement protocol yet EXECUTE IMMEDIATE 'EXECUTE stmt'; -1 -1 +ERROR HY000: This command is not supported in the prepared statement protocol yet EXECUTE IMMEDIATE 'DEALLOCATE PREPARE stmt'; +ERROR HY000: This command is not supported in the prepared statement protocol yet EXECUTE IMMEDIATE 'SELECT ?' USING _latin1'a'=_latin2'a'; ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2_general_ci,COERCIBLE) for operation '=' EXECUTE IMMEDIATE 'SELECT ?' USING ROW(1,2); diff --git a/mysql-test/main/ps.test b/mysql-test/main/ps.test index 5933aea4a03..e5285022efd 100644 --- a/mysql-test/main/ps.test +++ b/mysql-test/main/ps.test @@ -38,10 +38,12 @@ deallocate prepare no_such_statement; execute stmt1; # Nesting ps commands is now allowed: +--error ER_UNSUPPORTED_PS prepare stmt2 from 'prepare nested_stmt from "select 1"'; +--error ER_UNSUPPORTED_PS prepare stmt2 from 'execute stmt1'; +--error ER_UNSUPPORTED_PS prepare stmt2 from 'deallocate prepare z'; -deallocate prepare stmt2; # PS insert prepare stmt3 from 'insert into t1 values (?,?)'; @@ -4193,12 +4195,16 @@ EXECUTE IMMEDIATE 'SELECT 1' USING @a; --error ER_WRONG_ARGUMENTS EXECUTE IMMEDIATE 'SELECT ?'; +--error ER_UNSUPPORTED_PS EXECUTE IMMEDIATE 'EXECUTE IMMEDIATE "SELECT 1"'; +--error ER_UNSUPPORTED_PS EXECUTE IMMEDIATE 'PREPARE stmt FROM "SELECT 1"'; +--error ER_UNSUPPORTED_PS EXECUTE IMMEDIATE 'EXECUTE stmt'; +--error ER_UNSUPPORTED_PS EXECUTE IMMEDIATE 'DEALLOCATE PREPARE stmt'; --error ER_CANT_AGGREGATE_2COLLATIONS diff --git a/mysql-test/main/ps_1general.result b/mysql-test/main/ps_1general.result index c42b3d07bbc..05a40f54a52 100644 --- a/mysql-test/main/ps_1general.result +++ b/mysql-test/main/ps_1general.result @@ -381,8 +381,11 @@ drop table t5 ; deallocate prepare stmt_do ; deallocate prepare stmt_set ; prepare stmt1 from ' prepare stmt2 from '' select 1 '' ' ; +ERROR HY000: This command is not supported in the prepared statement protocol yet prepare stmt1 from ' execute stmt2 ' ; +ERROR HY000: This command is not supported in the prepared statement protocol yet prepare stmt1 from ' deallocate prepare never_prepared ' ; +ERROR HY000: This command is not supported in the prepared statement protocol yet prepare stmt1 from 'alter view v1 as select 2'; prepare stmt4 from ' use test ' ; prepare stmt3 from ' create database mysqltest '; diff --git a/mysql-test/main/ps_1general.test b/mysql-test/main/ps_1general.test index f98c05a69fb..b0f408e3bcf 100644 --- a/mysql-test/main/ps_1general.test +++ b/mysql-test/main/ps_1general.test @@ -406,8 +406,11 @@ deallocate prepare stmt_do ; deallocate prepare stmt_set ; ## nonsense like prepare of prepare,execute or deallocate +--error ER_UNSUPPORTED_PS prepare stmt1 from ' prepare stmt2 from '' select 1 '' ' ; +--error ER_UNSUPPORTED_PS prepare stmt1 from ' execute stmt2 ' ; +--error ER_UNSUPPORTED_PS prepare stmt1 from ' deallocate prepare never_prepared ' ; prepare stmt1 from 'alter view v1 as select 2'; diff --git a/mysql-test/main/ps_missed_cmds.result b/mysql-test/main/ps_missed_cmds.result index f16cae445fb..e016226bb17 100644 --- a/mysql-test/main/ps_missed_cmds.result +++ b/mysql-test/main/ps_missed_cmds.result @@ -546,59 +546,7 @@ EXECUTE stmt_1; # Clean up DEALLOCATE PREPARE stmt_1; DROP PROCEDURE p1; -# Test case 15: Check that the 'PREPARE FROM' statement can be executed -# as a prepared statement. -PREPARE stmt_1 FROM 'PREPARE stmt_2 FROM "SELECT 1"'; -EXECUTE stmt_1; -# Execute the same prepared statement the second time to check that -# no internal structures used for handling the 'PREPARE' statement -# were damaged. -EXECUTE stmt_1; -# Now execute the prepared statement with the name stmt_2 -# It is expected that output contains the single row '1' -EXECUTE stmt_2; -1 -1 -# Clean up -DEALLOCATE PREPARE stmt_1; -DEALLOCATE PREPARE stmt_2; -# Test case 16: Check that the 'EXECUTE' statement can be executed -# as a prepared statement. -PREPARE stmt_1 FROM 'SELECT 1'; -PREPARE stmt_2 FROM 'EXECUTE stmt_1'; -# Execute the statement stmt_2. Expected result is output of one row '1' -EXECUTE stmt_2; -1 -1 -# Execute the same prepared statement the second time to check that -# no internal structures used for handling the 'EXECUTE' statement -# were damaged. -EXECUTE stmt_2; -1 -1 -# Clean up -DEALLOCATE PREPARE stmt_1; -DEALLOCATE PREPARE stmt_2; -# Test case 17: Check that the statement 'DEALLOCATE PREPARE' -# can be executed as a prepared statement. -PREPARE stmt_1 FROM 'SELECT 1'; -PREPARE stmt_2 FROM 'DEALLOCATE PREPARE stmt_1'; -# After the prepared statement 'stmt_2' be executed -# the prepared statement stmt_1 will be deallocated. -EXECUTE stmt_2; -# Execute the same prepared statement the second time to check that -# no internal structures used for handling the 'DEALLOCATE PREPARE' -# statement were damaged. This time invocation results in the error -# ER_UNKNOWN_STMT_HANDLER since the prepared statement stmt_1 -# has just been released. So, just ignore this error. -EXECUTE stmt_2; -ERROR HY000: Unknown prepared statement handler (stmt_1) given to DEALLOCATE PREPARE -# Check that the stmt_1 doesn't no longer exist -EXECUTE stmt_1; -ERROR HY000: Unknown prepared statement handler (stmt_1) given to EXECUTE -# Clean up -DEALLOCATE PREPARE stmt_2; -# Test case 18: Check that the 'CREATE VIEW' statement can be executed +# Test case 15: Check that the 'CREATE VIEW' statement can be executed # as a prepared statement. # Create environment for the test case CREATE TABLE t1 (a INT); @@ -617,7 +565,7 @@ ERROR 42S01: Table 'v1' already exists DEALLOCATE PREPARE stmt_1; DROP VIEW v1; DROP TABLE t1; -# Test case 19: Check that the 'CREATE TRIGGER' statement can be executed +# Test case 16: Check that the 'CREATE TRIGGER' statement can be executed # as a prepared statement. CREATE TABLE t1 (a INT); PREPARE stmt_1 FROM 'CREATE TRIGGER trg1 BEFORE INSERT ON t1 FOR EACH ROW SET @a=1'; @@ -629,10 +577,10 @@ EXECUTE stmt_1; # already exist. It is expected behaviour. EXECUTE stmt_1; ERROR HY000: Trigger 'test.trg1' already exists -# Test case 20: Check that the 'DROP TRIGGER' statement can be executed +# Test case 17: Check that the 'DROP TRIGGER' statement can be executed # as a prepared statement. # This test relies on presence of the trigger trg1 created by -# the test case 19. +# the test case 16. PREPARE stmt_1 FROM 'DROP TRIGGER trg1'; EXECUTE stmt_1; # Execute the same prepared statement the second time to check that @@ -644,7 +592,7 @@ ERROR HY000: Trigger does not exist # Clean up DEALLOCATE PREPARE stmt_1; DROP TABLE t1; -# Test case 21: Check that XA related SQL statements can be executed +# Test case 18: Check that XA related SQL statements can be executed # as prepared statements. # Create the table t1 used by XA transaction. CREATE TABLE t1 (a INT); @@ -734,7 +682,7 @@ DEALLOCATE PREPARE stmt_3; DEALLOCATE PREPARE stmt_4; DEALLOCATE PREPARE stmt_5; DEALLOCATE PREPARE stmt_6; -# Test case 22: Check that the CREATE SERVER/ALTER SERVER/DROP SERVER +# Test case 19: Check that the CREATE SERVER/ALTER SERVER/DROP SERVER # statements can be executed as prepared statements. PREPARE stmt_1 FROM "CREATE SERVER s FOREIGN DATA WRAPPER mysql OPTIONS (USER 'u1', HOST '127.0.0.1')"; PREPARE stmt_2 FROM "ALTER SERVER s OPTIONS (USER 'u2')"; @@ -764,7 +712,7 @@ ERROR HY000: The foreign server name you are trying to reference does not exist. DEALLOCATE PREPARE stmt_1; DEALLOCATE PREPARE stmt_2; DEALLOCATE PREPARE stmt_3; -# Test case 23: Check that the CREATE EVENT/ALTER EVENT/DROP EVENT +# Test case 20: Check that the CREATE EVENT/ALTER EVENT/DROP EVENT # statements can be executed as a prepared statement PREPARE stmt_1 FROM "CREATE EVENT e1 ON SCHEDULE AT CURRENT_TIMESTAMP - INTERVAL 1 DAY ON COMPLETION PRESERVE DO SET @a=1"; PREPARE stmt_2 FROM "ALTER EVENT e1 COMMENT 'New comment'"; @@ -802,7 +750,7 @@ ERROR HY000: Unknown event 'e1' DEALLOCATE PREPARE stmt_1; DEALLOCATE PREPARE stmt_2; DEALLOCATE PREPARE stmt_3; -# Test case 24: Check that the SIGNAL and RESIGNAL statements +# Test case 21: Check that the SIGNAL and RESIGNAL statements # can be executed as a prepared statement PREPARE stmt_1 FROM "SIGNAL SQLSTATE '45000' SET MYSQL_ERRNO=30001, MESSAGE_TEXT='Hello, world!'"; EXECUTE stmt_1; @@ -822,7 +770,7 @@ EXECUTE stmt_1; ERROR 0K000: RESIGNAL when handler not active # Clean up DEALLOCATE PREPARE stmt_1; -# Test case 25: Check that the 'SHOW RELAYLOG EVENTS' statement can be +# Test case 22: Check that the 'SHOW RELAYLOG EVENTS' statement can be # executed as a prepared statement. PREPARE stmt_1 FROM 'SHOW RELAYLOG EVENTS'; EXECUTE stmt_1; @@ -834,7 +782,7 @@ EXECUTE stmt_1; Log_name Pos Event_type Server_id End_log_pos Info # Clean up DEALLOCATE PREPARE stmt_1; -# Test case 26: Check the 'GET DIAGNOSTICS' statement +# Test case 23: Check the 'GET DIAGNOSTICS' statement # can be executed as a prepared statement PREPARE stmt_1 FROM 'GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE, @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT'; # Query from non existent table to fill the diagnostics area @@ -854,18 +802,7 @@ ERROR 42S02: Table 'test.non_existent_table_1' doesn't exist EXECUTE stmt_1; # Clean up DEALLOCATE PREPARE stmt_1; -# Test case 27: Check the the statement 'EXECUTE IMMEDIATE' -# can be executed as a prepared statement -PREPARE stmt_1 FROM "EXECUTE IMMEDIATE 'SELECT 1'"; -EXECUTE stmt_1; -1 -1 -# Execute the same prepared statement the second time to check that -# no internal structures used for handling the 'EXECUTE IMMEDIATE' -# statement were damaged. -# Clean up -DEALLOCATE PREPARE stmt_1; -# Test Test case 28: Check the statements 'BACKUP'/'BACKUP UNLOCK' +# Test case 24: Check the statements 'BACKUP'/'BACKUP UNLOCK' # can be executed as a prepared statement CREATE TABLE t1 (a INT); PREPARE stmt_1 FROM 'BACKUP LOCK t1'; @@ -884,7 +821,7 @@ EXECUTE stmt_2; DROP TABLE t1; DEALLOCATE PREPARE stmt_1; DEALLOCATE PREPARE stmt_2; -# Test Test case 29: Check the statements 'CREATE/ALTER/DROP TABLEPSPACE' +# Test Test case 25: Check the statements 'CREATE/ALTER/DROP TABLEPSPACE' # can be executed as a prepared statement PREPARE stmt_1 FROM "CREATE TABLESPACE ts1 ADD DATAFILE 'ts1.ibd' ENGINE=InnoDB"; PREPARE stmt_2 FROM "ALTER TABLESPACE ts1 ADD DATAFILE 'ts1_1.ibd' ENGINE=InnoDB"; diff --git a/mysql-test/main/ps_missed_cmds.test b/mysql-test/main/ps_missed_cmds.test index b621ef6d611..3aa14d5cce1 100644 --- a/mysql-test/main/ps_missed_cmds.test +++ b/mysql-test/main/ps_missed_cmds.test @@ -327,59 +327,7 @@ EXECUTE stmt_1; DEALLOCATE PREPARE stmt_1; DROP PROCEDURE p1; ---echo # Test case 15: Check that the 'PREPARE FROM' statement can be executed ---echo # as a prepared statement. -PREPARE stmt_1 FROM 'PREPARE stmt_2 FROM "SELECT 1"'; -EXECUTE stmt_1; ---echo # Execute the same prepared statement the second time to check that ---echo # no internal structures used for handling the 'PREPARE' statement ---echo # were damaged. -EXECUTE stmt_1; ---echo # Now execute the prepared statement with the name stmt_2 ---echo # It is expected that output contains the single row '1' -EXECUTE stmt_2; ---echo # Clean up -DEALLOCATE PREPARE stmt_1; -DEALLOCATE PREPARE stmt_2; - ---echo # Test case 16: Check that the 'EXECUTE' statement can be executed ---echo # as a prepared statement. -PREPARE stmt_1 FROM 'SELECT 1'; -PREPARE stmt_2 FROM 'EXECUTE stmt_1'; ---echo # Execute the statement stmt_2. Expected result is output of one row '1' -EXECUTE stmt_2; ---echo # Execute the same prepared statement the second time to check that ---echo # no internal structures used for handling the 'EXECUTE' statement ---echo # were damaged. -EXECUTE stmt_2; - ---echo # Clean up -DEALLOCATE PREPARE stmt_1; -DEALLOCATE PREPARE stmt_2; - ---echo # Test case 17: Check that the statement 'DEALLOCATE PREPARE' ---echo # can be executed as a prepared statement. -PREPARE stmt_1 FROM 'SELECT 1'; -PREPARE stmt_2 FROM 'DEALLOCATE PREPARE stmt_1'; ---echo # After the prepared statement 'stmt_2' be executed ---echo # the prepared statement stmt_1 will be deallocated. -EXECUTE stmt_2; ---echo # Execute the same prepared statement the second time to check that ---echo # no internal structures used for handling the 'DEALLOCATE PREPARE' ---echo # statement were damaged. This time invocation results in the error ---echo # ER_UNKNOWN_STMT_HANDLER since the prepared statement stmt_1 ---echo # has just been released. So, just ignore this error. ---error ER_UNKNOWN_STMT_HANDLER -EXECUTE stmt_2; - ---echo # Check that the stmt_1 doesn't no longer exist ---error ER_UNKNOWN_STMT_HANDLER -EXECUTE stmt_1; - ---echo # Clean up -DEALLOCATE PREPARE stmt_2; - ---echo # Test case 18: Check that the 'CREATE VIEW' statement can be executed +--echo # Test case 15: Check that the 'CREATE VIEW' statement can be executed --echo # as a prepared statement. --echo # Create environment for the test case CREATE TABLE t1 (a INT); @@ -403,7 +351,7 @@ DEALLOCATE PREPARE stmt_1; DROP VIEW v1; DROP TABLE t1; ---echo # Test case 19: Check that the 'CREATE TRIGGER' statement can be executed +--echo # Test case 16: Check that the 'CREATE TRIGGER' statement can be executed --echo # as a prepared statement. CREATE TABLE t1 (a INT); PREPARE stmt_1 FROM 'CREATE TRIGGER trg1 BEFORE INSERT ON t1 FOR EACH ROW SET @a=1'; @@ -416,10 +364,10 @@ EXECUTE stmt_1; --error ER_TRG_ALREADY_EXISTS EXECUTE stmt_1; ---echo # Test case 20: Check that the 'DROP TRIGGER' statement can be executed +--echo # Test case 17: Check that the 'DROP TRIGGER' statement can be executed --echo # as a prepared statement. --echo # This test relies on presence of the trigger trg1 created by ---echo # the test case 19. +--echo # the test case 16. PREPARE stmt_1 FROM 'DROP TRIGGER trg1'; EXECUTE stmt_1; --echo # Execute the same prepared statement the second time to check that @@ -433,7 +381,7 @@ EXECUTE stmt_1; DEALLOCATE PREPARE stmt_1; DROP TABLE t1; ---echo # Test case 21: Check that XA related SQL statements can be executed +--echo # Test case 18: Check that XA related SQL statements can be executed --echo # as prepared statements. --echo # Create the table t1 used by XA transaction. CREATE TABLE t1 (a INT); @@ -533,7 +481,7 @@ DEALLOCATE PREPARE stmt_4; DEALLOCATE PREPARE stmt_5; DEALLOCATE PREPARE stmt_6; ---echo # Test case 22: Check that the CREATE SERVER/ALTER SERVER/DROP SERVER +--echo # Test case 19: Check that the CREATE SERVER/ALTER SERVER/DROP SERVER --echo # statements can be executed as prepared statements. PREPARE stmt_1 FROM "CREATE SERVER s FOREIGN DATA WRAPPER mysql OPTIONS (USER 'u1', HOST '127.0.0.1')"; @@ -569,7 +517,7 @@ DEALLOCATE PREPARE stmt_1; DEALLOCATE PREPARE stmt_2; DEALLOCATE PREPARE stmt_3; ---echo # Test case 23: Check that the CREATE EVENT/ALTER EVENT/DROP EVENT +--echo # Test case 20: Check that the CREATE EVENT/ALTER EVENT/DROP EVENT --echo # statements can be executed as a prepared statement PREPARE stmt_1 FROM "CREATE EVENT e1 ON SCHEDULE AT CURRENT_TIMESTAMP - INTERVAL 1 DAY ON COMPLETION PRESERVE DO SET @a=1"; @@ -618,7 +566,7 @@ DEALLOCATE PREPARE stmt_1; DEALLOCATE PREPARE stmt_2; DEALLOCATE PREPARE stmt_3; ---echo # Test case 24: Check that the SIGNAL and RESIGNAL statements +--echo # Test case 21: Check that the SIGNAL and RESIGNAL statements --echo # can be executed as a prepared statement PREPARE stmt_1 FROM "SIGNAL SQLSTATE '45000' SET MYSQL_ERRNO=30001, MESSAGE_TEXT='Hello, world!'"; --error 30001 @@ -641,7 +589,7 @@ EXECUTE stmt_1; --echo # Clean up DEALLOCATE PREPARE stmt_1; ---echo # Test case 25: Check that the 'SHOW RELAYLOG EVENTS' statement can be +--echo # Test case 22: Check that the 'SHOW RELAYLOG EVENTS' statement can be --echo # executed as a prepared statement. PREPARE stmt_1 FROM 'SHOW RELAYLOG EVENTS'; EXECUTE stmt_1; @@ -652,7 +600,7 @@ EXECUTE stmt_1; --echo # Clean up DEALLOCATE PREPARE stmt_1; ---echo # Test case 26: Check the 'GET DIAGNOSTICS' statement +--echo # Test case 23: Check the 'GET DIAGNOSTICS' statement --echo # can be executed as a prepared statement PREPARE stmt_1 FROM 'GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE, @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT'; @@ -674,19 +622,7 @@ EXECUTE stmt_1; --echo # Clean up DEALLOCATE PREPARE stmt_1; ---echo # Test case 27: Check the the statement 'EXECUTE IMMEDIATE' ---echo # can be executed as a prepared statement - -PREPARE stmt_1 FROM "EXECUTE IMMEDIATE 'SELECT 1'"; -EXECUTE stmt_1; ---echo # Execute the same prepared statement the second time to check that ---echo # no internal structures used for handling the 'EXECUTE IMMEDIATE' ---echo # statement were damaged. - ---echo # Clean up -DEALLOCATE PREPARE stmt_1; - ---echo # Test Test case 28: Check the statements 'BACKUP'/'BACKUP UNLOCK' +--echo # Test case 24: Check the statements 'BACKUP'/'BACKUP UNLOCK' --echo # can be executed as a prepared statement CREATE TABLE t1 (a INT); PREPARE stmt_1 FROM 'BACKUP LOCK t1'; @@ -709,7 +645,7 @@ DROP TABLE t1; DEALLOCATE PREPARE stmt_1; DEALLOCATE PREPARE stmt_2; ---echo # Test Test case 29: Check the statements 'CREATE/ALTER/DROP TABLEPSPACE' +--echo # Test Test case 25: Check the statements 'CREATE/ALTER/DROP TABLEPSPACE' --echo # can be executed as a prepared statement PREPARE stmt_1 FROM "CREATE TABLESPACE ts1 ADD DATAFILE 'ts1.ibd' ENGINE=InnoDB"; diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 2ef389011a2..9409dc5dd02 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -2664,52 +2664,14 @@ static bool check_prepared_statement(Prepared_statement *stmt) /* Statement and field info has already been sent */ DBUG_RETURN(false); break; - /* - Note that we don't need to have cases in this list if they are - marked with CF_STATUS_COMMAND in sql_command_flags - */ - case SQLCOM_SHOW_EXPLAIN: - case SQLCOM_DROP_TABLE: - case SQLCOM_DROP_SEQUENCE: - case SQLCOM_RENAME_TABLE: - case SQLCOM_ALTER_TABLE: - case SQLCOM_ALTER_SEQUENCE: - case SQLCOM_COMMIT: - case SQLCOM_CREATE_INDEX: - case SQLCOM_DROP_INDEX: - case SQLCOM_ROLLBACK: - case SQLCOM_ROLLBACK_TO_SAVEPOINT: - case SQLCOM_TRUNCATE: - case SQLCOM_DROP_VIEW: - case SQLCOM_CHANGE_MASTER: - case SQLCOM_RESET: - case SQLCOM_FLUSH: - case SQLCOM_SLAVE_START: - case SQLCOM_SLAVE_STOP: - case SQLCOM_SLAVE_ALL_START: - case SQLCOM_SLAVE_ALL_STOP: - case SQLCOM_INSTALL_PLUGIN: - case SQLCOM_UNINSTALL_PLUGIN: - case SQLCOM_CREATE_DB: - case SQLCOM_DROP_DB: - case SQLCOM_ALTER_DB_UPGRADE: - case SQLCOM_CREATE_USER: - case SQLCOM_ALTER_USER: - case SQLCOM_RENAME_USER: - case SQLCOM_DROP_USER: - case SQLCOM_CREATE_ROLE: - case SQLCOM_DROP_ROLE: - case SQLCOM_GRANT: - case SQLCOM_GRANT_ROLE: - case SQLCOM_REVOKE: - case SQLCOM_REVOKE_ALL: - case SQLCOM_REVOKE_ROLE: - case SQLCOM_KILL: - case SQLCOM_COMPOUND: - case SQLCOM_SHUTDOWN: + case SQLCOM_PREPARE: case SQLCOM_EXECUTE: + case SQLCOM_EXECUTE_IMMEDIATE: case SQLCOM_DEALLOCATE_PREPARE: + my_message(ER_UNSUPPORTED_PS, ER_THD(thd, ER_UNSUPPORTED_PS), MYF(0)); + goto error; + default: break; } From aeca826c5fe9e6709bbdb7f89c12a8c4df31c84f Mon Sep 17 00:00:00 2001 From: Dmitry Shulga Date: Tue, 27 Apr 2021 16:49:17 +0700 Subject: [PATCH 107/251] MDEV-16708: Unsupported commands for prepared statements Write a log event to the general log before executing a statemment in PS mode This change fixes failure of the test main.log_tables when it is run in PS mode Updated the test main.events_logs_tests to query mysql.general_log for the command_type 'Query' and 'Execute' in order to have consistent test result both in case the test is run with --ps-protocol and without it --- mysql-test/main/events_logs_tests.result | 3 +- mysql-test/main/events_logs_tests.test | 3 +- mysql-test/main/log_tables.result | 18 ++++++------ mysql-test/main/log_tables.test | 3 +- sql/sql_prepare.cc | 37 ++++++++++++------------ 5 files changed, 34 insertions(+), 30 deletions(-) diff --git a/mysql-test/main/events_logs_tests.result b/mysql-test/main/events_logs_tests.result index ac4a43118da..d332767a9f1 100644 --- a/mysql-test/main/events_logs_tests.result +++ b/mysql-test/main/events_logs_tests.result @@ -11,7 +11,8 @@ test suite is run in normal mode or with --ps-protocol create procedure select_general_log() begin select user_host, argument from mysql.general_log -where argument like '%events_logs_test%'; +where argument like '%events_logs_test%' AND +(command_type = 'Query' OR command_type = 'Execute'); end| Check that general query log works, but sub-statements diff --git a/mysql-test/main/events_logs_tests.test b/mysql-test/main/events_logs_tests.test index c4ef133f46b..7cd664b30df 100644 --- a/mysql-test/main/events_logs_tests.test +++ b/mysql-test/main/events_logs_tests.test @@ -17,7 +17,8 @@ delimiter |; create procedure select_general_log() begin select user_host, argument from mysql.general_log - where argument like '%events_logs_test%'; + where argument like '%events_logs_test%' AND + (command_type = 'Query' OR command_type = 'Execute'); end| delimiter ;| --echo diff --git a/mysql-test/main/log_tables.result b/mysql-test/main/log_tables.result index 4642b1c6876..e20d3db2daf 100644 --- a/mysql-test/main/log_tables.result +++ b/mysql-test/main/log_tables.result @@ -792,10 +792,11 @@ set @lparam = "000 001 002 003 004 005 006 007 008 009" prepare long_query from "select ? as long_query"; execute long_query using @lparam; set global general_log = off; -select command_type, argument from mysql.general_log where thread_id = @thread_id; -command_type argument -Query set global general_log = on -Query set @lparam = "000 001 002 003 004 005 006 007 008 009" +select argument from mysql.general_log where thread_id = @thread_id +AND (command_type = 'Query' OR command_type= 'Execute'); +argument +set global general_log = on +set @lparam = "000 001 002 003 004 005 006 007 008 009" "010 011 012 013 014 015 016 017 018 019" "020 021 022 023 024 025 026 027 028 029" "030 031 032 033 034 035 036 037 038 039" @@ -895,11 +896,10 @@ Query set @lparam = "000 001 002 003 004 005 006 007 008 009" "970 971 972 973 974 975 976 977 978 979" "980 981 982 983 984 985 986 987 988 989" "990 991 992 993 994 995 996 997 998 999" -Query prepare long_query from "select ? as long_query" -Prepare select ? as long_query -Query execute long_query using @lparam -Execute select '000 001 002 003 004 005 006 007 008 009010 011 012 013 014 015 016 017 018 019020 021 022 023 024 025 026 027 028 029030 031 032 033 034 035 036 037 038 039040 041 042 043 044 045 046 047 048 049050 051 052 053 054 055 056 057 058 059060 061 062 063 064 065 066 067 068 069070 071 072 073 074 075 076 077 078 079080 081 082 083 084 085 086 087 088 089090 091 092 093 094 095 096 097 098 099100 101 102 103 104 105 106 107 108 109110 111 112 113 114 115 116 117 118 119120 121 122 123 124 125 126 127 128 129130 131 132 133 134 135 136 137 138 139140 141 142 143 144 145 146 147 148 149150 151 152 153 154 155 156 157 158 159160 161 162 163 164 165 166 167 168 169170 171 172 173 174 175 176 177 178 179180 181 182 183 184 185 186 187 188 189190 191 192 193 194 195 196 197 198 199200 201 202 203 204 205 206 207 208 209210 211 212 213 214 215 216 217 218 219220 221 222 223 224 225 226 227 228 229230 231 232 233 234 235 236 237 238 239240 241 242 243 244 245 246 247 248 249250 251 252 253 254 255 256 257 258 259260 261 262 263 264 265 266 267 268 269270 271 272 273 274 275 276 277 278 279280 281 282 283 284 285 286 287 288 289290 291 292 293 294 295 296 297 298 299300 301 302 303 304 305 306 307 308 309310 311 312 313 314 315 316 317 318 319320 321 322 323 324 325 326 327 328 329330 331 332 333 334 335 336 337 338 339340 341 342 343 344 345 346 347 348 349350 351 352 353 354 355 356 357 358 359360 361 362 363 364 365 366 367 368 369370 371 372 373 374 375 376 377 378 379380 381 382 383 384 385 386 387 388 389390 391 392 393 394 395 396 397 398 399400 401 402 403 404 405 406 407 408 409410 411 412 413 414 415 416 417 418 419420 421 422 423 424 425 426 427 428 429430 431 432 433 434 435 436 437 438 439440 441 442 443 444 445 446 447 448 449450 451 452 453 454 455 456 457 458 459460 461 462 463 464 465 466 467 468 469470 471 472 473 474 475 476 477 478 479480 481 482 483 484 485 486 487 488 489490 491 492 493 494 495 496 497 498 499500 501 502 503 504 505 506 507 508 509510 511 512 513 514 515 516 517 518 519520 521 522 523 524 525 526 527 528 529530 531 532 533 534 535 536 537 538 539540 541 542 543 544 545 546 547 548 549550 551 552 553 554 555 556 557 558 559560 561 562 563 564 565 566 567 568 569570 571 572 573 574 575 576 577 578 579580 581 582 583 584 585 586 587 588 589590 591 592 593 594 595 596 597 598 599600 601 602 603 604 605 606 607 608 609610 611 612 613 614 615 616 617 618 619620 621 622 623 624 625 626 627 628 629630 631 632 633 634 635 636 637 638 639640 641 642 643 644 645 646 647 648 649650 651 652 653 654 655 656 657 658 659660 661 662 663 664 665 666 667 668 669670 671 672 673 674 675 676 677 678 679680 681 682 683 684 685 686 687 688 689690 691 692 693 694 695 696 697 698 699700 701 702 703 704 705 706 707 708 709710 711 712 713 714 715 716 717 718 719720 721 722 723 724 725 726 727 728 729730 731 732 733 734 735 736 737 738 739740 741 742 743 744 745 746 747 748 749750 751 752 753 754 755 756 757 758 759760 761 762 763 764 765 766 767 768 769770 771 772 773 774 775 776 777 778 779780 781 782 783 784 785 786 787 788 789790 791 792 793 794 795 796 797 798 799800 801 802 803 804 805 806 807 808 809810 811 812 813 814 815 816 817 818 819820 821 822 823 824 825 826 827 828 829830 831 832 833 834 835 836 837 838 839840 841 842 843 844 845 846 847 848 849850 851 852 853 854 855 856 857 858 859860 861 862 863 864 865 866 867 868 869870 871 872 873 874 875 876 877 878 879880 881 882 883 884 885 886 887 888 889890 891 892 893 894 895 896 897 898 899900 901 902 903 904 905 906 907 908 909910 911 912 913 914 915 916 917 918 919920 921 922 923 924 925 926 927 928 929930 931 932 933 934 935 936 937 938 939940 941 942 943 944 945 946 947 948 949950 951 952 953 954 955 956 957 958 959960 961 962 963 964 965 966 967 968 969970 971 972 973 974 975 976 977 978 979980 981 982 983 984 985 986 987 988 989990 991 992 993 994 995 996 997 998 999' as long_query -Query set global general_log = off +prepare long_query from "select ? as long_query" +execute long_query using @lparam +select '000 001 002 003 004 005 006 007 008 009010 011 012 013 014 015 016 017 018 019020 021 022 023 024 025 026 027 028 029030 031 032 033 034 035 036 037 038 039040 041 042 043 044 045 046 047 048 049050 051 052 053 054 055 056 057 058 059060 061 062 063 064 065 066 067 068 069070 071 072 073 074 075 076 077 078 079080 081 082 083 084 085 086 087 088 089090 091 092 093 094 095 096 097 098 099100 101 102 103 104 105 106 107 108 109110 111 112 113 114 115 116 117 118 119120 121 122 123 124 125 126 127 128 129130 131 132 133 134 135 136 137 138 139140 141 142 143 144 145 146 147 148 149150 151 152 153 154 155 156 157 158 159160 161 162 163 164 165 166 167 168 169170 171 172 173 174 175 176 177 178 179180 181 182 183 184 185 186 187 188 189190 191 192 193 194 195 196 197 198 199200 201 202 203 204 205 206 207 208 209210 211 212 213 214 215 216 217 218 219220 221 222 223 224 225 226 227 228 229230 231 232 233 234 235 236 237 238 239240 241 242 243 244 245 246 247 248 249250 251 252 253 254 255 256 257 258 259260 261 262 263 264 265 266 267 268 269270 271 272 273 274 275 276 277 278 279280 281 282 283 284 285 286 287 288 289290 291 292 293 294 295 296 297 298 299300 301 302 303 304 305 306 307 308 309310 311 312 313 314 315 316 317 318 319320 321 322 323 324 325 326 327 328 329330 331 332 333 334 335 336 337 338 339340 341 342 343 344 345 346 347 348 349350 351 352 353 354 355 356 357 358 359360 361 362 363 364 365 366 367 368 369370 371 372 373 374 375 376 377 378 379380 381 382 383 384 385 386 387 388 389390 391 392 393 394 395 396 397 398 399400 401 402 403 404 405 406 407 408 409410 411 412 413 414 415 416 417 418 419420 421 422 423 424 425 426 427 428 429430 431 432 433 434 435 436 437 438 439440 441 442 443 444 445 446 447 448 449450 451 452 453 454 455 456 457 458 459460 461 462 463 464 465 466 467 468 469470 471 472 473 474 475 476 477 478 479480 481 482 483 484 485 486 487 488 489490 491 492 493 494 495 496 497 498 499500 501 502 503 504 505 506 507 508 509510 511 512 513 514 515 516 517 518 519520 521 522 523 524 525 526 527 528 529530 531 532 533 534 535 536 537 538 539540 541 542 543 544 545 546 547 548 549550 551 552 553 554 555 556 557 558 559560 561 562 563 564 565 566 567 568 569570 571 572 573 574 575 576 577 578 579580 581 582 583 584 585 586 587 588 589590 591 592 593 594 595 596 597 598 599600 601 602 603 604 605 606 607 608 609610 611 612 613 614 615 616 617 618 619620 621 622 623 624 625 626 627 628 629630 631 632 633 634 635 636 637 638 639640 641 642 643 644 645 646 647 648 649650 651 652 653 654 655 656 657 658 659660 661 662 663 664 665 666 667 668 669670 671 672 673 674 675 676 677 678 679680 681 682 683 684 685 686 687 688 689690 691 692 693 694 695 696 697 698 699700 701 702 703 704 705 706 707 708 709710 711 712 713 714 715 716 717 718 719720 721 722 723 724 725 726 727 728 729730 731 732 733 734 735 736 737 738 739740 741 742 743 744 745 746 747 748 749750 751 752 753 754 755 756 757 758 759760 761 762 763 764 765 766 767 768 769770 771 772 773 774 775 776 777 778 779780 781 782 783 784 785 786 787 788 789790 791 792 793 794 795 796 797 798 799800 801 802 803 804 805 806 807 808 809810 811 812 813 814 815 816 817 818 819820 821 822 823 824 825 826 827 828 829830 831 832 833 834 835 836 837 838 839840 841 842 843 844 845 846 847 848 849850 851 852 853 854 855 856 857 858 859860 861 862 863 864 865 866 867 868 869870 871 872 873 874 875 876 877 878 879880 881 882 883 884 885 886 887 888 889890 891 892 893 894 895 896 897 898 899900 901 902 903 904 905 906 907 908 909910 911 912 913 914 915 916 917 918 919920 921 922 923 924 925 926 927 928 929930 931 932 933 934 935 936 937 938 939940 941 942 943 944 945 946 947 948 949950 951 952 953 954 955 956 957 958 959960 961 962 963 964 965 966 967 968 969970 971 972 973 974 975 976 977 978 979980 981 982 983 984 985 986 987 988 989990 991 992 993 994 995 996 997 998 999' as long_query +set global general_log = off deallocate prepare long_query; set global general_log = @old_general_log; DROP TABLE IF EXISTS log_count; diff --git a/mysql-test/main/log_tables.test b/mysql-test/main/log_tables.test index 537bd843af8..22db93bd1ed 100644 --- a/mysql-test/main/log_tables.test +++ b/mysql-test/main/log_tables.test @@ -988,7 +988,8 @@ prepare long_query from "select ? as long_query"; execute long_query using @lparam; --enable_result_log set global general_log = off; -select command_type, argument from mysql.general_log where thread_id = @thread_id; +select argument from mysql.general_log where thread_id = @thread_id +AND (command_type = 'Query' OR command_type= 'Execute'); deallocate prepare long_query; set global general_log = @old_general_log; diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 9409dc5dd02..b09dd4dc381 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -5123,6 +5123,25 @@ bool Prepared_statement::execute(String *expanded_query, bool open_cursor) /* Go! */ + /* + Log COM_EXECUTE to the general log. Note, that in case of SQL + prepared statements this causes two records to be output: + + Query EXECUTE + Execute + + This is considered user-friendly, since in the + second log entry we output values of parameter markers. + + Do not print anything if this is an SQL prepared statement and + we're inside a stored procedure (also called Dynamic SQL) -- + sub-statements inside stored procedures are not logged into + the general log. + */ + + if (thd->spcont == nullptr) + general_log_write(thd, COM_STMT_EXECUTE, thd->query(), thd->query_length()); + if (open_cursor) error= mysql_open_cursor(thd, &result, &cursor); else @@ -5208,24 +5227,6 @@ bool Prepared_statement::execute(String *expanded_query, bool open_cursor) thd->protocol->send_out_parameters(&this->lex->param_list); } - /* - Log COM_EXECUTE to the general log. Note, that in case of SQL - prepared statements this causes two records to be output: - - Query EXECUTE - Execute - - This is considered user-friendly, since in the - second log entry we output values of parameter markers. - - Do not print anything if this is an SQL prepared statement and - we're inside a stored procedure (also called Dynamic SQL) -- - sub-statements inside stored procedures are not logged into - the general log. - */ - if (likely(error == 0 && thd->spcont == NULL)) - general_log_write(thd, COM_STMT_EXECUTE, thd->query(), thd->query_length()); - error: thd->lex->restore_set_statement_var(); flags&= ~ (uint) IS_IN_USE; From 8754fce8b086911a2446cb414f770ece13ef1d27 Mon Sep 17 00:00:00 2001 From: Dmitry Shulga Date: Wed, 28 Apr 2021 12:44:46 +0700 Subject: [PATCH 108/251] MDEV-16708: Unsupported commands for prepared statements Fixed test failures caused by missing output of warnings that got on prepare phase --- mysql-test/main/derived.test | 2 ++ mysql-test/main/derived_cond_pushdown.test | 3 ++- mysql-test/main/having_cond_pushdown.test | 4 ++++ mysql-test/main/subselect.test | 10 ++++++++++ mysql-test/main/subselect4.test | 2 ++ mysql-test/main/table_value_constr.test | 2 ++ 6 files changed, 22 insertions(+), 1 deletion(-) diff --git a/mysql-test/main/derived.test b/mysql-test/main/derived.test index 8c41f80ffbd..0d2efca1a26 100644 --- a/mysql-test/main/derived.test +++ b/mysql-test/main/derived.test @@ -475,8 +475,10 @@ CREATE TABLE t1 (a INT) ENGINE=MyISAM; INSERT INTO t1 VALUES (8); CREATE TABLE t2 (b INT) ENGINE=MyISAM; INSERT INTO t2 VALUES (1),(7); +--enable_prepare_warnings EXPLAIN SELECT * FROM (SELECT * FROM t1) AS table1, (SELECT DISTINCT * FROM t2) AS table2 WHERE b = a AND a <> ANY (SELECT 9); +--disable_prepare_warnings DROP TABLE t1, t2; set optimizer_switch=@save_derived_optimizer_switch_bug; diff --git a/mysql-test/main/derived_cond_pushdown.test b/mysql-test/main/derived_cond_pushdown.test index fb227e85ee6..e6ee05dd644 100644 --- a/mysql-test/main/derived_cond_pushdown.test +++ b/mysql-test/main/derived_cond_pushdown.test @@ -1064,9 +1064,10 @@ DROP TABLE t1,t2; CREATE TABLE t1 (i INT); CREATE OR REPLACE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1; INSERT INTO t1 VALUES (1),(2); - +--enable_prepare_warnings EXPLAIN FORMAT=JSON SELECT * FROM v1 WHERE i <= ANY ( SELECT 3 ); +--disable_prepare_warnings SELECT * FROM v1 WHERE i <= ANY ( SELECT 3 ); diff --git a/mysql-test/main/having_cond_pushdown.test b/mysql-test/main/having_cond_pushdown.test index fc75122615c..60ed7ebb660 100644 --- a/mysql-test/main/having_cond_pushdown.test +++ b/mysql-test/main/having_cond_pushdown.test @@ -73,14 +73,18 @@ GROUP BY t1.a HAVING (t1.a>1) OR (a IN (SELECT 3)); eval $no_pushdown $query; eval $query; +--enable_prepare_warnings eval explain $query; eval explain format=json $query; +--disable_prepare_warnings let $query= SELECT t1.a,MAX(t1.b) FROM t1 WHERE (t1.a>1) OR (a IN (SELECT 3)) GROUP BY t1.a; +--enable_prepare_warnings eval $no_pushdown explain format=json $query; +--disable_prepare_warnings let $query= SELECT t1.a,MAX(t1.b),MIN(t1.c) diff --git a/mysql-test/main/subselect.test b/mysql-test/main/subselect.test index a58a08e1a58..19c30bd6dc8 100644 --- a/mysql-test/main/subselect.test +++ b/mysql-test/main/subselect.test @@ -30,11 +30,15 @@ SET optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; SET optimizer_use_condition_selectivity=4; select (select 2); + +--enable_prepare_warnings explain extended select (select 2); SELECT (SELECT 1) UNION SELECT (SELECT 2); explain extended SELECT (SELECT 1) UNION SELECT (SELECT 2); SELECT (SELECT (SELECT 0 UNION SELECT 0)); explain extended SELECT (SELECT (SELECT 0 UNION SELECT 0)); +--disable_prepare_warnings + -- error ER_ILLEGAL_REFERENCE SELECT (SELECT 1 FROM (SELECT 1) as b HAVING a=1) as a; -- error ER_ILLEGAL_REFERENCE @@ -441,11 +445,15 @@ SELECT * FROM (SELECT 1) b WHERE 1 IN (SELECT *); CREATE TABLE t2 (id int(11) default NULL, KEY id (id)) ENGINE=MyISAM CHARSET=latin1; INSERT INTO t2 VALUES (1),(2); SELECT * FROM t2 WHERE id IN (SELECT 1); +--enable_prepare_warnings EXPLAIN EXTENDED SELECT * FROM t2 WHERE id IN (SELECT 1); +--disable_prepare_warnings SELECT * FROM t2 WHERE id IN (SELECT 1 UNION SELECT 3); SELECT * FROM t2 WHERE id IN (SELECT 1+(select 1)); +--enable_prepare_warnings EXPLAIN EXTENDED SELECT * FROM t2 WHERE id IN (SELECT 1+(select 1)); EXPLAIN EXTENDED SELECT * FROM t2 WHERE id IN (SELECT 1 UNION SELECT 3); +--disable_prepare_warnings SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 3); SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 2); -- error ER_UPDATE_TABLE_USED @@ -501,7 +509,9 @@ select 1.5 > ALL (SELECT * from t1); select 10.5 > ALL (SELECT * from t1); select 1.5 > ANY (SELECT * from t1); select 10.5 > ANY (SELECT * from t1); +--enable_prepare_warnings explain extended select (select a+1) from t1; +--disable_prepare_warnings select (select a+1) from t1; drop table t1; diff --git a/mysql-test/main/subselect4.test b/mysql-test/main/subselect4.test index 2f65db875f8..8be44f214f0 100644 --- a/mysql-test/main/subselect4.test +++ b/mysql-test/main/subselect4.test @@ -104,8 +104,10 @@ DROP TABLE t1,t2; --echo # Bug#54568: create view cause Assertion failed: 0, --echo # file .\item_subselect.cc, line 836 --echo # +--enable_prepare_warnings EXPLAIN SELECT 1 LIKE ( 1 IN ( SELECT 1 ) ); DESCRIBE SELECT 1 LIKE ( 1 IN ( SELECT 1 ) ); +--disable_prepare_warnings --echo # None of the below should crash CREATE VIEW v1 AS SELECT 1 LIKE ( 1 IN ( SELECT 1 ) ); CREATE VIEW v2 AS SELECT 1 LIKE '%' ESCAPE ( 1 IN ( SELECT 1 ) ); diff --git a/mysql-test/main/table_value_constr.test b/mysql-test/main/table_value_constr.test index ddc949d8c00..9f06be800e6 100644 --- a/mysql-test/main/table_value_constr.test +++ b/mysql-test/main/table_value_constr.test @@ -1471,7 +1471,9 @@ insert into t2 values (1), (2); let $q1= select (values ((select 2))) from t2; eval $q1; +--enable_prepare_warnings eval explain $q1; +--disable_prepare_warnings eval prepare stmt from "$q1"; execute stmt; execute stmt; From f536974b73dec47ddd87cb525f2f0d26d84f1a1d Mon Sep 17 00:00:00 2001 From: Dmitry Shulga Date: Thu, 29 Apr 2021 17:16:56 +0700 Subject: [PATCH 109/251] MDEV-16708: Unsupported commands for prepared statements Fixed failures of the tests main.compound, main.union --- mysql-test/main/compound.result | 4 ++-- mysql-test/main/compound.test | 4 ++-- mysql-test/main/union.test | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/mysql-test/main/compound.result b/mysql-test/main/compound.result index 18df4fd34e2..6efa23e833f 100644 --- a/mysql-test/main/compound.result +++ b/mysql-test/main/compound.result @@ -101,7 +101,7 @@ t1 t2 t3 t4 -set @a=0; +set @a=0| repeat set @a = @a + 1; until @a > 5 @@ -154,7 +154,7 @@ master-bin.000001 # Query # # use `test`; insert t1 values( NAME_CONST('a',4)+3) master-bin.000001 # Query # # COMMIT drop function fn| drop table t1| -set @@sql_mode="STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"; +set @@sql_mode="STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"| begin not atomic select @@sql_mode; end| @@sql_mode STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION diff --git a/mysql-test/main/compound.test b/mysql-test/main/compound.test index 1f901e2a2b3..c902ef77b52 100644 --- a/mysql-test/main/compound.test +++ b/mysql-test/main/compound.test @@ -94,7 +94,7 @@ end loop| show tables| # REPEAT -set @a=0; +set @a=0| repeat set @a = @a + 1; until @a > 5 @@ -146,7 +146,7 @@ drop table t1| # MDEV-6609 SQL inside an anonymous block is executed with wrong SQL_MODE # -set @@sql_mode="STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"; +set @@sql_mode="STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"| begin not atomic select @@sql_mode; end| create table t1 (a int)| select a from t1 having a > 1| diff --git a/mysql-test/main/union.test b/mysql-test/main/union.test index 2e5a04a27f4..8d023546b3d 100644 --- a/mysql-test/main/union.test +++ b/mysql-test/main/union.test @@ -93,6 +93,7 @@ select 1 as a,(select a union select a); SELECT @a:=1 UNION SELECT @a:=@a+1; --error 1054 (SELECT 1) UNION (SELECT 2) ORDER BY (SELECT a); +--sorted_result (SELECT 1,3) UNION (SELECT 2,1) ORDER BY (SELECT 2); # From 5478ca779a8769c4ebdf03ba5f5d7be9fdcf7ef5 Mon Sep 17 00:00:00 2001 From: Dmitry Shulga Date: Wed, 5 May 2021 17:56:12 +0700 Subject: [PATCH 110/251] MDEV-25576: The statement EXPLAIN running as regular statement and as prepared statement produces different results for UPDATE with subquery 10.6 cleanup --- sql/sql_base.cc | 15 --------------- sql/sql_base.h | 2 -- sql/sql_delete.cc | 2 +- sql/sql_lex.h | 13 +++++++++++++ sql/sql_update.cc | 2 +- 5 files changed, 15 insertions(+), 19 deletions(-) diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 1ba01671201..0d3c476c0e5 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -9276,21 +9276,6 @@ int dynamic_column_error_message(enum_dyncol_func_result rc) return rc; } - -/** - Turn on the SELECT_DESCRIBE flag for the primary SELECT_LEX of the statement - being processed in case the statement is EXPLAIN UPDATE/DELETE. - - @param lex current LEX -*/ - -void promote_select_describe_flag_if_needed(LEX *lex) -{ - if (lex->describe) - lex->first_select_lex()->options|= SELECT_DESCRIBE; -} - - /** @} (end of group Data_Dictionary) */ diff --git a/sql/sql_base.h b/sql/sql_base.h index 19713a051bf..cafb5967480 100644 --- a/sql/sql_base.h +++ b/sql/sql_base.h @@ -518,8 +518,6 @@ bool extend_table_list(THD *thd, TABLE_LIST *tables, Prelocking_strategy *prelocking_strategy, bool has_prelocking_list); -void promote_select_describe_flag_if_needed(LEX *lex); - /** A context of open_tables() function, used to recover from a failed open_table() or open_routine() attempt. diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index c54851c295b..34fa14d4324 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -366,7 +366,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, query_plan.select_lex= thd->lex->first_select_lex(); query_plan.table= table; - promote_select_describe_flag_if_needed(thd->lex); + thd->lex->promote_select_describe_flag_if_needed(); if (mysql_prepare_delete(thd, table_list, &conds, &delete_while_scanning)) DBUG_RETURN(TRUE); diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 6df1996409c..0d8251968e8 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -4773,6 +4773,19 @@ public: bool resolve_references_to_cte(TABLE_LIST *tables, TABLE_LIST **tables_last); + /** + Turn on the SELECT_DESCRIBE flag for every SELECT_LEX involved into + the statement being processed in case the statement is EXPLAIN UPDATE/DELETE. + + @param lex current LEX + */ + + void promote_select_describe_flag_if_needed() + { + if (describe) + builtin_select.options |= SELECT_DESCRIBE; + } + }; diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 738b3e0781a..07171485da4 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -468,7 +468,7 @@ int mysql_update(THD *thd, want_privilege= (table_list->view ? UPDATE_ACL : table_list->grant.want_privilege); #endif - promote_select_describe_flag_if_needed(thd->lex); + thd->lex->promote_select_describe_flag_if_needed(); if (mysql_prepare_update(thd, table_list, &conds, order_num, order)) DBUG_RETURN(1); From 4decc03b285d4a1c42750d6f29c5f0c3a25cd1c4 Mon Sep 17 00:00:00 2001 From: Dmitry Shulga Date: Thu, 6 May 2021 13:55:57 +0700 Subject: [PATCH 111/251] MDEV-16708: Unsupported commands for prepared statements Fixed the test main.view --- mysql-test/main/view.test | 4 ++++ sql/item.cc | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/mysql-test/main/view.test b/mysql-test/main/view.test index 805afedc8ae..73322d97591 100644 --- a/mysql-test/main/view.test +++ b/mysql-test/main/view.test @@ -3081,7 +3081,9 @@ create view v1 as select * from t1 order by f2; select * from v1; explain extended select * from v1; select * from v1 order by f1; +--enable_prepare_warnings explain extended select * from v1 order by f1; +--disable_prepare_warnings drop view v1; drop table t1; @@ -4421,7 +4423,9 @@ CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT f1 FROM t1; CREATE ALGORITHM=MERGE VIEW v2 AS SELECT f1 FROM v1 ORDER BY f1; SELECT * FROM v2 AS a1, v2 AS a2; +--enable_prepare_warnings EXPLAIN EXTENDED SELECT * FROM v2 AS a1, v2 AS a2; +--disable_prepare_warnings DROP VIEW v1, v2; DROP TABLE t1; diff --git a/sql/item.cc b/sql/item.cc index 3cede11a415..252135f50ad 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -5531,9 +5531,12 @@ Item_field::fix_outer_field(THD *thd, Field **from_field, Item **reference) */ Name_resolution_context *last_checked_context= context; Item **ref= (Item **) not_found_item; + SELECT_LEX *current_sel= thd->lex->current_select; Name_resolution_context *outer_context= 0; SELECT_LEX *select= 0; - outer_context= context->outer_context; + + if (current_sel->master_unit()->outer_select()) + outer_context= context->outer_context; /* This assert is to ensure we have an outer contex when *from_field From 129098b70ce4a30bad600ea4dc2703e4edadfe88 Mon Sep 17 00:00:00 2001 From: Dmitry Shulga Date: Tue, 11 May 2021 15:16:55 +0700 Subject: [PATCH 112/251] MDEV-16708: Unsupported commands for prepared statements Fixed the bug in handling queries where select list contains subqueries with items referencing to items in outer query --- sql/item.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/item.cc b/sql/item.cc index 252135f50ad..a016f04953c 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -5531,7 +5531,7 @@ Item_field::fix_outer_field(THD *thd, Field **from_field, Item **reference) */ Name_resolution_context *last_checked_context= context; Item **ref= (Item **) not_found_item; - SELECT_LEX *current_sel= thd->lex->current_select; + SELECT_LEX *current_sel= context->select_lex; Name_resolution_context *outer_context= 0; SELECT_LEX *select= 0; @@ -5868,7 +5868,7 @@ bool Item_field::fix_fields(THD *thd, Item **reference) DBUG_ASSERT(fixed() == 0); Field *from_field= (Field *)not_found_field; bool outer_fixed= false; - SELECT_LEX *select= thd->lex->current_select; + SELECT_LEX *select= context->select_lex; if (select && select->in_tvc) { From b33111ba93a6bc279a51b512033e42e702cf5ed7 Mon Sep 17 00:00:00 2001 From: Dmitry Shulga Date: Tue, 18 May 2021 08:50:57 +0700 Subject: [PATCH 113/251] MDEV-16708: Fixed the failed test main.join_cache --- mysql-test/main/join_cache.result | 4 ++-- mysql-test/main/join_cache.test | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mysql-test/main/join_cache.result b/mysql-test/main/join_cache.result index 79c5b7923bd..0fbb73f56fe 100644 --- a/mysql-test/main/join_cache.result +++ b/mysql-test/main/join_cache.result @@ -5993,14 +5993,14 @@ create table t3 (c3 int); insert into t1 values (1), (2); insert into t2 values (1), (2); insert into t3 values (2); +set @counter=0; explain select count(*) from t1 straight_join t2 where c1 = c2-0 and c2 <= (select max(c3) from t3 where c3 = 2 and @counter:=@counter+1); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) -2 UNCACHEABLE SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE -set @counter=0; +2 UNCACHEABLE SUBQUERY t3 system NULL NULL NULL NULL 1 select count(*) from t1 straight_join t2 where c1 = c2-0 and c2 <= (select max(c3) from t3 where c3 = 2 and @counter:=@counter+1); count(*) diff --git a/mysql-test/main/join_cache.test b/mysql-test/main/join_cache.test index b4271f648e3..4b659345db4 100644 --- a/mysql-test/main/join_cache.test +++ b/mysql-test/main/join_cache.test @@ -3998,12 +3998,12 @@ insert into t1 values (1), (2); insert into t2 values (1), (2); insert into t3 values (2); +set @counter=0; + explain select count(*) from t1 straight_join t2 where c1 = c2-0 and c2 <= (select max(c3) from t3 where c3 = 2 and @counter:=@counter+1); -set @counter=0; - select count(*) from t1 straight_join t2 where c1 = c2-0 and c2 <= (select max(c3) from t3 where c3 = 2 and @counter:=@counter+1); From a00b51f639dc9aab8a7b788265ec75e388f22b09 Mon Sep 17 00:00:00 2001 From: Dmitry Shulga Date: Wed, 19 May 2021 11:28:58 +0700 Subject: [PATCH 114/251] MDEV-16708: Fixed the failed test main.set_statement --- sql/sp_head.h | 5 ++-- sql/sql_class.cc | 2 +- sql/sql_class.h | 2 +- sql/sql_cursor.cc | 2 +- sql/sql_parse.cc | 13 ++++++++- sql/sql_prepare.cc | 66 +++++++++++++++++++++++++++++++++++++--------- 6 files changed, 72 insertions(+), 18 deletions(-) diff --git a/sql/sp_head.h b/sql/sp_head.h index 34dd09fd88f..601d41ab04a 100644 --- a/sql/sp_head.h +++ b/sql/sp_head.h @@ -1041,7 +1041,7 @@ public: Query_arena(thd->lex->sphead->get_main_mem_root(), STMT_INITIALIZED_FOR_SP) { } ~sp_lex_cursor() { free_items(); } - void cleanup_stmt() { } + void cleanup_stmt(bool /*restore_set_statement_vars*/) { } Query_arena *query_arena() { return this; } bool validate() { @@ -1831,7 +1831,8 @@ public: cursor is closed. For now stored procedures always use materialized cursors and the call is not used. */ - virtual void cleanup_stmt() { /* no op */ } + virtual void cleanup_stmt(bool /*restore_set_statement_vars*/) + { /* no op */ } private: sp_lex_keeper m_lex_keeper; diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 6317e578156..9b6f1b1ef68 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -3835,7 +3835,7 @@ void Query_arena::set_query_arena(Query_arena *set) } -void Query_arena::cleanup_stmt() +void Query_arena::cleanup_stmt(bool /*restore_set_statement_vars*/) { DBUG_ASSERT(! "Query_arena::cleanup_stmt() not implemented"); } diff --git a/sql/sql_class.h b/sql/sql_class.h index 0f85da68c8e..004b92712c8 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1212,7 +1212,7 @@ public: void free_items(); /* Close the active state associated with execution of this statement */ - virtual void cleanup_stmt(); + virtual void cleanup_stmt(bool /*restore_set_statement_vars*/); }; diff --git a/sql/sql_cursor.cc b/sql/sql_cursor.cc index b995a841a74..0324e9691e8 100644 --- a/sql/sql_cursor.cc +++ b/sql/sql_cursor.cc @@ -197,7 +197,7 @@ int mysql_open_cursor(THD *thd, select_result *result, } *pcursor= materialized_cursor; - thd->stmt_arena->cleanup_stmt(); + thd->stmt_arena->cleanup_stmt(true); } end: diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index b1e7a12adac..8307cd0ed4d 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2419,7 +2419,18 @@ resume: thd->update_all_stats(); - log_slow_statement(thd); + /* + Write to slow query log only those statements that received via the text + protocol except the EXECUTE statement. The reason we do that way is + that for statements received via binary protocol and for the EXECUTE + statement, the slow statements have been already written to slow query log + inside the method Prepared_statement::execute(). + */ + if(command == COM_QUERY && + thd->lex->sql_command != SQLCOM_EXECUTE) + log_slow_statement(thd); + else + delete_explain_query(thd->lex); THD_STAGE_INFO(thd, stage_cleaning_up); thd->reset_query(); diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index b09dd4dc381..2f5470db123 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -201,7 +201,7 @@ public: virtual ~Prepared_statement(); void setup_set_params(); virtual Query_arena::Type type() const; - virtual void cleanup_stmt(); + virtual void cleanup_stmt(bool restore_set_statement_vars); bool set_name(const LEX_CSTRING *name); inline void close_cursor() { delete cursor; cursor= 0; } inline bool is_in_use() { return flags & (uint) IS_IN_USE; } @@ -4193,11 +4193,14 @@ Query_arena::Type Prepared_statement::type() const } -void Prepared_statement::cleanup_stmt() +void Prepared_statement::cleanup_stmt(bool restore_set_statement_vars) { DBUG_ENTER("Prepared_statement::cleanup_stmt"); DBUG_PRINT("enter",("stmt: %p", this)); - lex->restore_set_statement_var(); + + if (restore_set_statement_vars) + lex->restore_set_statement_var(); + thd->rollback_item_tree_changes(); cleanup_items(free_list); thd->cleanup_after_query(); @@ -4406,12 +4409,6 @@ bool Prepared_statement::prepare(const char *packet, uint packet_len) lex->context_analysis_only&= ~CONTEXT_ANALYSIS_ONLY_PREPARE; } - /* - Restore original values of variables modified on handling - SET STATEMENT clause. - */ - thd->lex->restore_set_statement_var(); - /* The order is important */ lex->unit.cleanup(); @@ -4440,7 +4437,12 @@ bool Prepared_statement::prepare(const char *packet, uint packet_len) if (lex->sql_command != SQLCOM_SET_OPTION) lex_unlock_plugins(lex); - cleanup_stmt(); + /* + Pass the value true to restore original values of variables modified + on handling SET STATEMENT clause. + */ + cleanup_stmt(true); + thd->restore_backup_statement(this, &stmt_backup); thd->stmt_arena= old_stmt_arena; thd->cur_stmt= save_cur_stmt; @@ -5159,6 +5161,7 @@ bool Prepared_statement::execute(String *expanded_query, bool open_cursor) (char *) thd->security_ctx->host_or_ip, 1); error= mysql_execute_command(thd, true); MYSQL_QUERY_EXEC_DONE(error); + thd->update_server_status(); } else { @@ -5184,8 +5187,47 @@ bool Prepared_statement::execute(String *expanded_query, bool open_cursor) DBUG_ASSERT(! (error && cursor)); if (! cursor) - cleanup_stmt(); - + /* + Pass the value false to don't restore set statement variables. + See the next comment block for more details. + */ + cleanup_stmt(false); + + /* + Log the statement to slow query log if it passes filtering. + We do it here for prepared statements despite of the fact that the function + log_slow_statement() is also called upper the stack from the function + dispatch_command(). The reason for logging slow queries here is that + the function log_slow_statement() must be called before restoring system + variables that could be set on execution of SET STATEMENT clause. Since + for prepared statement restoring of system variables set on execution of + SET STATEMENT clause is performed on return from the method + Prepared_statement::execute(), by the time the function log_slow_statement() + be invoked from the function dispatch_command() all variables set by + the SET STATEMEN clause would be already reset to their original values + that break semantic of the SET STATEMENT clause. + + E.g., lets consider the following statements + SET slow_query_log= 1; + SET @@long_query_time=0.01; + PREPARE stmt FROM 'set statement slow_query_log=0 for select sleep(0.1)'; + EXECUTE stmt; + + It's expected that the above statements don't write any record + to slow query log since the system variable slow_query_log is set to 0 + during execution of the whole statement + 'set statement slow_query_log=0 for select sleep(0.1)' + + However, if the function log_slow_statement wasn't called here the record + for the statement would be written to slow query log since the variable + slow_query_log is restored to its original value by the time the function + log_slow_statement is called from disptach_command() to write a record + into slow query log. + */ + log_slow_statement(thd); + + lex->restore_set_statement_var(); + /* EXECUTE command has its own dummy "explain data". We don't need it, instead, we want to keep the query plan of the statement that was From a3a80420ea5b405eb361c0c3cbda2491ce1deeb9 Mon Sep 17 00:00:00 2001 From: Dmitry Shulga Date: Wed, 19 May 2021 12:30:06 +0700 Subject: [PATCH 115/251] MDEV-16708: disabled the test main.sp to be executed with ps-protocol This test has been disable by the reason that it contains multi-statements that not supported in PS mode. Unfortunately, some of these multi-statements can't be converted to a sequence of single-statements by the reason that multi-statementness is a requirement for tests (e.g. tests for the MySQL bugs #5307, #8762) therefore the whole test file will be skipped in case it is run with --ps-protocol --- mysql-test/main/sp.test | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mysql-test/main/sp.test b/mysql-test/main/sp.test index 8157f18aad1..888cc569d6c 100644 --- a/mysql-test/main/sp.test +++ b/mysql-test/main/sp.test @@ -15,6 +15,11 @@ # Tests that require multibyte character sets, which are not always available, # go into separate files (e.g. sp-ucs2.test) +if (`SELECT $PS_PROTOCOL != 0`) +{ + --skip Need regular protocol but ps-protocol was specified +} + --source include/default_charset.inc set @save_character_set_client=@@character_set_client; set @save_userstat=@@global.userstat, @@global.userstat= 0; From a72098421c73a961fb0b8193d7175820d5318b65 Mon Sep 17 00:00:00 2001 From: Dmitry Shulga Date: Sun, 30 May 2021 21:49:34 +0700 Subject: [PATCH 116/251] MDEV-16708: Unsupported commands for prepared statements Added the directive --disable_ps_protocol before running tests that checking correct handling of ER_STACK_OVERRUN_NEED_MORE. These tests rely on estimation of stack consumption that differ in case statements run in regular and in ps mode. --- mysql-test/main/sp_notembedded.test | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mysql-test/main/sp_notembedded.test b/mysql-test/main/sp_notembedded.test index 29901c1221b..12bacff4e87 100644 --- a/mysql-test/main/sp_notembedded.test +++ b/mysql-test/main/sp_notembedded.test @@ -185,6 +185,7 @@ set @@max_sp_recursion_depth=255| set @var=1| # disable log because error about stack overrun contains numbers which # depend on a system +-- disable_ps_protocol -- disable_result_log -- error ER_STACK_OVERRUN_NEED_MORE call bug10100p(255, @var)| @@ -197,6 +198,7 @@ call bug10100pd(1,255)| -- error ER_STACK_OVERRUN_NEED_MORE call bug10100pc(1,255)| -- enable_result_log +-- enable_ps_protocol set @@max_sp_recursion_depth=0| deallocate prepare stmt2| From fc71746a6a75e2b24a50a6c3afb026a667d409c6 Mon Sep 17 00:00:00 2001 From: Dmitry Shulga Date: Fri, 4 Jun 2021 12:59:24 +0700 Subject: [PATCH 117/251] MDEV-16708: Fixed ths issue with handling of ERR packet received by mysqltest on response to COM_STMT_EXECUTE The test cases like the following one delimiter |; CREATE PROCEDURE SP001() BEGIN DECLARE C1 CURSOR FOR SELECT 1; OPEN C1; SELECT 1; CLOSE C1; CLOSE C1; END| delimiter ;| --error 1326 call SP001(); are failed since processing of ERR packet was missed by mysqltest in case it is run with --ps-protocol Additionally, the test sp-error was changed to don't run multi-statements since they are not supported by PS protocol --- client/mysqltest.cc | 11 ++++++++--- mysql-test/main/sp-error.result | 4 ++-- mysql-test/main/sp-error.test | 4 ++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 0f052397d4f..a873618bf55 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -8324,6 +8324,7 @@ void run_query_stmt(struct st_connection *cn, struct st_command *command, goto end; } + int err; do { /* @@ -8357,8 +8358,6 @@ void run_query_stmt(struct st_connection *cn, struct st_command *command, goto end; } - /* If we got here the statement was both executed and read successfully */ - handle_no_error(command); if (!disable_result_log) { /* @@ -8436,8 +8435,14 @@ void run_query_stmt(struct st_connection *cn, struct st_command *command, } } } - } while ( !mysql_stmt_next_result(stmt)); + } while ( !(err= mysql_stmt_next_result(stmt))); + if (err > 0) + /* We got an error from mysql_next_result, maybe expected */ + handle_error(command, mysql_errno(mysql), mysql_error(mysql), + mysql_sqlstate(mysql), ds); + else + handle_no_error(command); end: if (!disable_warnings) { diff --git a/mysql-test/main/sp-error.result b/mysql-test/main/sp-error.result index f64735f8006..3832d63c073 100644 --- a/mysql-test/main/sp-error.result +++ b/mysql-test/main/sp-error.result @@ -2771,7 +2771,7 @@ DROP TABLE t2; DROP PROCEDURE IF EXISTS p1; DROP PROCEDURE IF EXISTS p2; -SET sql_mode = ''; +SET sql_mode = ''| CREATE PROCEDURE p1() BEGIN DECLARE var1 INTEGER DEFAULT 'string'; @@ -2782,7 +2782,7 @@ CALL p1()| Warnings: Warning 1366 Incorrect integer value: 'string' for column ``.``.`var1` at row 1 -SET sql_mode = DEFAULT; +SET sql_mode = DEFAULT| CREATE PROCEDURE p2() BEGIN DECLARE EXIT HANDLER FOR SQLWARNING SELECT 'H2'; diff --git a/mysql-test/main/sp-error.test b/mysql-test/main/sp-error.test index d2af9834823..3ce3623be18 100644 --- a/mysql-test/main/sp-error.test +++ b/mysql-test/main/sp-error.test @@ -3711,7 +3711,7 @@ DROP PROCEDURE IF EXISTS p2; delimiter |; -SET sql_mode = ''; +SET sql_mode = ''| CREATE PROCEDURE p1() BEGIN DECLARE var1 INTEGER DEFAULT 'string'; @@ -3721,7 +3721,7 @@ END| --echo CALL p1()| --echo -SET sql_mode = DEFAULT; +SET sql_mode = DEFAULT| CREATE PROCEDURE p2() BEGIN From b126c3f3fa2de565ec6737cdfac902cd34d0515b Mon Sep 17 00:00:00 2001 From: Dmitry Shulga Date: Mon, 7 Jun 2021 00:39:15 +0700 Subject: [PATCH 118/251] MDEV-16708: fixed issue with handling of the directive --enable-prepared-warnings in mysqltest --- client/mysqltest.cc | 2 +- mysql-test/include/ctype_numconv.inc | 4 ++-- mysql-test/include/explain_utils.inc | 4 ++++ mysql-test/main/bug12427262.test | 2 ++ mysql-test/main/column_compression.test | 2 ++ mysql-test/main/ctype_gbk.test | 2 ++ mysql-test/main/ctype_ucs.test | 4 ++++ mysql-test/main/delayed.test | 2 ++ mysql-test/main/func_group.test | 2 ++ mysql-test/main/func_time.test | 3 +++ mysql-test/main/grant.test | 2 ++ mysql-test/main/grant2.test | 2 ++ mysql-test/main/information_schema_db.test | 2 ++ mysql-test/main/innodb_mysql_lock2.test | 2 ++ mysql-test/main/invisible_field.test | 2 ++ mysql-test/main/lock_sync.test | 3 +++ mysql-test/main/locking_clause.test | 2 ++ mysql-test/main/merge.test | 4 ++++ mysql-test/main/myisam_debug.test | 2 ++ mysql-test/main/mysqldump.test | 2 ++ mysql-test/main/null.test | 2 ++ mysql-test/main/outfile_loaddata.test | 4 +++- mysql-test/main/parser.test | 2 ++ mysql-test/main/partition.test | 2 ++ mysql-test/main/partition_exchange.test | 2 ++ mysql-test/main/partition_explicit_prune.test | 2 ++ mysql-test/main/ps_ddl.test | 6 ++++++ mysql-test/main/ps_ddl1.test | 2 ++ mysql-test/main/query_cache.test | 4 ++++ mysql-test/main/select.test | 2 ++ mysql-test/main/signal_demo1.test | 4 ++++ mysql-test/main/sp-anchor-row-type-cursor.test | 3 +++ mysql-test/main/sp-anchor-row-type-table.test | 3 +++ mysql-test/main/sp-anchor-type.test | 2 ++ mysql-test/main/sp-big.test | 4 ++++ mysql-test/main/sp-error.test | 7 ++++++- mysql-test/main/sp_gis.test | 4 ++++ mysql-test/main/sp_trans.test | 2 ++ mysql-test/main/sp_trans_log.test | 2 ++ mysql-test/main/subselect_exists2in_costmat.test | 2 ++ mysql-test/main/subselect_mat_cost.test | 2 ++ mysql-test/main/temporal_literal.test | 2 ++ mysql-test/main/trigger.test | 4 ++++ mysql-test/main/type_blob.test | 4 ++++ mysql-test/main/type_newdecimal.test | 2 ++ mysql-test/main/type_year.test | 4 +++- mysql-test/main/union.test | 4 ++++ mysql-test/main/userstat.test | 2 ++ mysql-test/main/view.test | 9 ++++++++- mysql-test/main/view_grant.test | 4 ++++ 50 files changed, 141 insertions(+), 7 deletions(-) diff --git a/client/mysqltest.cc b/client/mysqltest.cc index a873618bf55..a3ca60819ce 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -8293,7 +8293,7 @@ void run_query_stmt(struct st_connection *cn, struct st_command *command, Get the warnings from mysql_stmt_prepare and keep them in a separate string */ - if (!disable_warnings) + if (!disable_warnings && prepare_warnings_enabled) append_warnings(&ds_prepare_warnings, mysql); /* diff --git a/mysql-test/include/ctype_numconv.inc b/mysql-test/include/ctype_numconv.inc index 889c80cc477..d99942c5d5f 100644 --- a/mysql-test/include/ctype_numconv.inc +++ b/mysql-test/include/ctype_numconv.inc @@ -1043,7 +1043,7 @@ update t1 set a= a + 0.1; select a, hex(a) from t1; drop table t1; - +--enable_prepare_warnings # # Columns # @@ -1203,7 +1203,6 @@ create table t2 as select concat(a) from t1; show create table t2; drop table t1, t2; - # # create view with string functions with numeric input # @@ -1517,6 +1516,7 @@ select hex(a) from v1; drop table t1; drop view v1; +--disable_prepare_warnings # # User defined function returning numeric result # diff --git a/mysql-test/include/explain_utils.inc b/mysql-test/include/explain_utils.inc index 505798e432a..15376b76610 100644 --- a/mysql-test/include/explain_utils.inc +++ b/mysql-test/include/explain_utils.inc @@ -28,9 +28,11 @@ --echo # if ($select) { +--enable_prepare_warnings --disable_query_log --eval $select INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/before_explain.txt' --enable_query_log +--disable_prepare_warnings } if ($innodb) { @@ -122,7 +124,9 @@ if ($validation) { --disable_query_log if ($select) { +--enable_prepare_warnings --eval $select INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/after_explain.txt' +--disable_prepare_warnings --diff_files '$MYSQLTEST_VARDIR/tmp/before_explain.txt' '$MYSQLTEST_VARDIR/tmp/after_explain.txt' --remove_file '$MYSQLTEST_VARDIR/tmp/before_explain.txt' --remove_file '$MYSQLTEST_VARDIR/tmp/after_explain.txt' diff --git a/mysql-test/main/bug12427262.test b/mysql-test/main/bug12427262.test index aca37a651c4..3a5642516a8 100644 --- a/mysql-test/main/bug12427262.test +++ b/mysql-test/main/bug12427262.test @@ -21,6 +21,7 @@ create table t10 (c1 int); --enable_warnings # Query PS to know initial read count for frm file. +--enable_prepare_warnings select Sum(ALL(COUNT_READ)) from performance_schema.file_summary_by_instance where FILE_NAME like "%show_table_lw_db%" AND FILE_NAME like "%.frm%" AND EVENT_NAME='wait/io/file/sql/FRM' into @count_read_before; @@ -45,6 +46,7 @@ into @count_read_after; select @count_read_after-@count_read_before; +--disable_prepare_warnings --disable_warnings drop table t1; drop database show_table_lw_db; diff --git a/mysql-test/main/column_compression.test b/mysql-test/main/column_compression.test index 2ae50be95d2..52235b07811 100644 --- a/mysql-test/main/column_compression.test +++ b/mysql-test/main/column_compression.test @@ -29,6 +29,7 @@ let $typec= BLOB COMPRESSED; let $typeu= BLOB; --source column_compression.inc +--enable_prepare_warnings --error ER_PARSE_ERROR CREATE TABLE t1(a CHAR(100) COMPRESSED); --error ER_WRONG_FIELD_SPEC @@ -291,6 +292,7 @@ CREATE TABLE t1 (a VARCHAR(1000) COMPRESSED, FULLTEXT INDEX(a)); --error ER_COMPRESSED_COLUMN_USED_AS_KEY CREATE TABLE t1 (a TEXT COMPRESSED, FULLTEXT INDEX(a)); +--disable_prepare_warnings --echo # --echo # End of 10.5 tests --echo # diff --git a/mysql-test/main/ctype_gbk.test b/mysql-test/main/ctype_gbk.test index c63c331c643..d68b78f847c 100644 --- a/mysql-test/main/ctype_gbk.test +++ b/mysql-test/main/ctype_gbk.test @@ -63,8 +63,10 @@ CREATE TABLE t1(a MEDIUMTEXT CHARACTER SET gbk, INSERT INTO t1 VALUES (REPEAT(0x1125,200000), REPEAT(0x1125,200000)), ('', ''), ('', ''); +--enable_prepare_warnings SELECT a FROM t1 GROUP BY 1 LIMIT 1 INTO @nullll; SELECT b FROM t1 GROUP BY 1 LIMIT 1 INTO @nullll; +--disable_prepare_warnings DROP TABLES t1; diff --git a/mysql-test/main/ctype_ucs.test b/mysql-test/main/ctype_ucs.test index cdc86fa3283..7c798e0a201 100644 --- a/mysql-test/main/ctype_ucs.test +++ b/mysql-test/main/ctype_ucs.test @@ -75,7 +75,9 @@ DROP TABLE t1; --echo # Problem # 1 (original report): wrong parsing of ucs2 data SET character_set_connection=ucs2; +--enable_prepare_warnings SELECT '00' UNION SELECT '10' INTO OUTFILE 'tmpp.txt'; +--disable_prepare_warnings CREATE TABLE t1(a INT); LOAD DATA INFILE 'tmpp.txt' INTO TABLE t1 CHARACTER SET ucs2 (@b) SET a=REVERSE(@b); @@ -88,7 +90,9 @@ remove_file $MYSQLD_DATADIR/test/tmpp.txt; --echo # Problem # 2 : if you write and read ucs2 data to a file they're lost +--enable_prepare_warnings SELECT '00' UNION SELECT '10' INTO OUTFILE 'tmpp2.txt' CHARACTER SET ucs2; +--disable_prepare_warnings CREATE TABLE t1(a INT); LOAD DATA INFILE 'tmpp2.txt' INTO TABLE t1 CHARACTER SET ucs2 (@b) SET a=REVERSE(@b); diff --git a/mysql-test/main/delayed.test b/mysql-test/main/delayed.test index a96ffdfcca9..862d30fe79f 100644 --- a/mysql-test/main/delayed.test +++ b/mysql-test/main/delayed.test @@ -636,8 +636,10 @@ insert into t1 values (1,1); call mtr.add_suppression(" marked as crashed and should be repaired"); call mtr.add_suppression("Checking table"); +--enable_prepare_warnings --replace_result '\\' '/' insert delayed into t1 values (2,2); +--disable_prepare_warnings insert delayed into t1 values (3,3); flush tables t1; select * from t1; diff --git a/mysql-test/main/func_group.test b/mysql-test/main/func_group.test index a28b39c28f6..71129352aae 100644 --- a/mysql-test/main/func_group.test +++ b/mysql-test/main/func_group.test @@ -1070,7 +1070,9 @@ DROP TABLE t1; --echo # --echo # Bug#43668: Wrong comparison and MIN/MAX for YEAR(2) --echo # +--enable_prepare_warnings create table t1 (f1 year(2), f2 year(4), f3 date, f4 datetime); +--disable_prepare_warnings insert into t1 values (98,1998,19980101,"1998-01-01 00:00:00"), (00,2000,20000101,"2000-01-01 00:00:01"), diff --git a/mysql-test/main/func_time.test b/mysql-test/main/func_time.test index ccec4d18ea3..f0bfb926f83 100644 --- a/mysql-test/main/func_time.test +++ b/mysql-test/main/func_time.test @@ -2228,6 +2228,7 @@ SET @sav_slow_query_log= @@session.slow_query_log; SET @@session.slow_query_log= ON; SELECT current_timestamp(6),fn_sleep_before_now() INTO @ts_cur, @ts_func; +--enable_prepare_warnings SELECT a FROM t_ts LIMIT 1 into @ts_func; SELECT a FROM t_trig LIMIT 1 into @ts_trig; if (!`SELECT @ts_cur = @ts_func and @ts_func = @ts_trig`) @@ -2243,6 +2244,8 @@ SET @@session.slow_query_log= OFF; SELECT current_timestamp(6),fn_sleep_before_now() INTO @ts_cur, @func_ts; SELECT a FROM t_ts LIMIT 1 into @ts_func; SELECT a FROM t_trig LIMIT 1 into @ts_trig; +--disable_prepare_warnings + if (!`SELECT @ts_cur = @ts_func and @ts_func = @ts_trig`) { SELECT @ts_cur, @ts_func, @ts_trig; diff --git a/mysql-test/main/grant.test b/mysql-test/main/grant.test index 82b68b3b6e6..c8ca440b3e8 100644 --- a/mysql-test/main/grant.test +++ b/mysql-test/main/grant.test @@ -1239,12 +1239,14 @@ drop function if exists test_function; drop view if exists v1; create table test (col1 varchar(30)); delimiter |; +--enable_prepare_warnings create function test_function() returns varchar(30) begin declare tmp varchar(30); select col1 from test limit 1 into tmp; return '1'; end| +--disable_prepare_warnings delimiter ;| create view v1 as select test.* from test where test.col1=test_function(); grant update (col1) on v1 to 'greg'@'localhost'; diff --git a/mysql-test/main/grant2.test b/mysql-test/main/grant2.test index f98af8d8630..b8098488709 100644 --- a/mysql-test/main/grant2.test +++ b/mysql-test/main/grant2.test @@ -524,8 +524,10 @@ INSERT INTO t2 VALUES (1); DROP FUNCTION IF EXISTS f2; --enable_warnings delimiter //; +--enable_prepare_warnings CREATE FUNCTION f2 () RETURNS INT BEGIN DECLARE v INT; SELECT s1 FROM t2 INTO v; RETURN v; END// +--disable_prepare_warnings delimiter ;// SELECT f2(); diff --git a/mysql-test/main/information_schema_db.test b/mysql-test/main/information_schema_db.test index 7cf8c0801e6..1dd0f84bc09 100644 --- a/mysql-test/main/information_schema_db.test +++ b/mysql-test/main/information_schema_db.test @@ -35,12 +35,14 @@ grant all privileges on `inf%`.* to 'mysqltest_1'@'localhost'; grant all privileges on `mbase`.* to 'mysqltest_1'@'localhost'; create table t1 (f1 int); delimiter |; +--enable_prepare_warnings create function func1(curr_int int) returns int begin declare ret_val int; select max(f1) from t1 into ret_val; return ret_val; end| +--disable_prepare_warnings delimiter ;| create view v1 as select f1 from t1 where f1 = func1(f1); create function func2() returns int return 1; diff --git a/mysql-test/main/innodb_mysql_lock2.test b/mysql-test/main/innodb_mysql_lock2.test index b983fd8dc7a..09298a900b1 100644 --- a/mysql-test/main/innodb_mysql_lock2.test +++ b/mysql-test/main/innodb_mysql_lock2.test @@ -71,6 +71,7 @@ insert into t5 values (1); create view v1 as select i from t1; create view v2 as select j from t2 where j in (select i from t1); create procedure p1(k int) insert into t2 values (k); +--enable_prepare_warnings delimiter |; create function f1() returns int begin @@ -192,6 +193,7 @@ begin set new.l= j + 1; end| delimiter ;| +--disable_prepare_warnings --echo # --echo # Set common variables to be used by scripts called below. diff --git a/mysql-test/main/invisible_field.test b/mysql-test/main/invisible_field.test index 7a48347ec29..f3f8fc8f19c 100644 --- a/mysql-test/main/invisible_field.test +++ b/mysql-test/main/invisible_field.test @@ -251,6 +251,7 @@ DROP TABLE t1; create or replace table t1 (a int, b int invisible); insert into t1 values (1),(2); +--enable_prepare_warnings select * from t1 into outfile 'f'; load data infile 'f' into table t1; select a,b from t1; @@ -277,5 +278,6 @@ drop table t1; --echo # create table t1 (a int, b int invisible); insert delayed into t1 values (1); +--disable_prepare_warnings # cleanup drop table t1; diff --git a/mysql-test/main/lock_sync.test b/mysql-test/main/lock_sync.test index 1a8cd7bdbd3..16367d74800 100644 --- a/mysql-test/main/lock_sync.test +++ b/mysql-test/main/lock_sync.test @@ -82,6 +82,7 @@ create view v1 as select i from t1; create view v2 as select j from t2 where j in (select i from t1); create procedure p1(k int) insert into t2 values (k); delimiter |; +--enable_prepare_warnings create function f1() returns int begin declare j int; @@ -223,6 +224,8 @@ begin end| delimiter ;| +--disable_prepare_warnings + --echo # --echo # Set common variables to be used by the scripts --echo # called below. diff --git a/mysql-test/main/locking_clause.test b/mysql-test/main/locking_clause.test index a27546a5cab..acba190b29f 100644 --- a/mysql-test/main/locking_clause.test +++ b/mysql-test/main/locking_clause.test @@ -150,6 +150,7 @@ DROP USER test2@localhost; --echo # MYSQL 8 --echo # +--enable_prepare_warnings SELECT 1 FROM DUAL LIMIT 1 INTO @var FOR UPDATE; SELECT 1 FROM DUAL LIMIT 1 FOR UPDATE INTO @var; @@ -159,3 +160,4 @@ SELECT 1 FROM DUAL LIMIT 1 INTO @var FOR UPDATE INTO @var; SELECT 1 UNION SELECT 1 FOR UPDATE INTO @var; SELECT 1 UNION SELECT 1 INTO @var FOR UPDATE; +--disable_prepare_warnings diff --git a/mysql-test/main/merge.test b/mysql-test/main/merge.test index 888b41b24bd..99cce370beb 100644 --- a/mysql-test/main/merge.test +++ b/mysql-test/main/merge.test @@ -2200,8 +2200,10 @@ DROP TABLE tm1, t1; CREATE TABLE t1 (c1 INT) ENGINE=MyISAM; CREATE TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1) INSERT_METHOD=LAST; +--enable_prepare_warnings CREATE TRIGGER tm1_ai AFTER INSERT ON tm1 FOR EACH ROW SELECT max(c1) FROM t1 INTO @var; +--disable_prepare_warnings LOCK TABLE tm1 WRITE, t1 WRITE; INSERT INTO tm1 VALUES (1); SELECT * FROM tm1; @@ -2223,8 +2225,10 @@ CREATE TABLE t4 (c1 INT) ENGINE=MyISAM; CREATE TABLE t5 (c1 INT) ENGINE=MyISAM; CREATE TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1,t2,t3,t4,t5) INSERT_METHOD=LAST; +--enable_prepare_warnings CREATE TRIGGER t2_au AFTER UPDATE ON t2 FOR EACH ROW SELECT MAX(c1) FROM t1 INTO @var; +--disable_prepare_warnings CREATE FUNCTION f1() RETURNS INT RETURN (SELECT MAX(c1) FROM t4); LOCK TABLE tm1 WRITE, t1 WRITE, t2 WRITE, t3 WRITE, t4 WRITE, t5 WRITE; diff --git a/mysql-test/main/myisam_debug.test b/mysql-test/main/myisam_debug.test index fcb134c0400..2659a3f9347 100644 --- a/mysql-test/main/myisam_debug.test +++ b/mysql-test/main/myisam_debug.test @@ -48,10 +48,12 @@ let $wait_condition= INFO = "INSERT INTO t1(id) SELECT id FROM t2"; --source include/wait_condition.inc +--enable_prepare_warnings SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = 'wait_in_enable_indexes' AND INFO = "INSERT INTO t1(id) SELECT id FROM t2" INTO @thread_id; +--disable_prepare_warnings KILL QUERY @thread_id; CHECK TABLE t1; diff --git a/mysql-test/main/mysqldump.test b/mysql-test/main/mysqldump.test index d2264d0a585..3b8130be5f8 100644 --- a/mysql-test/main/mysqldump.test +++ b/mysql-test/main/mysqldump.test @@ -1036,10 +1036,12 @@ begin return f1; end // +--enable_prepare_warnings CREATE PROCEDURE bug9056_proc2(OUT a INT) BEGIN select sum(id) from t1 into a; END // +--disable_prepare_warnings DELIMITER ;// diff --git a/mysql-test/main/null.test b/mysql-test/main/null.test index 403790356ce..4e230f72543 100644 --- a/mysql-test/main/null.test +++ b/mysql-test/main/null.test @@ -318,7 +318,9 @@ SELECT NOT NOT NULLIF(2,3); --echo # --echo # MDEV-7146 NULLIF returns unexpected result with a YEAR field --echo # +--enable_prepare_warnings CREATE TABLE t1 (a YEAR(2)); +--disable_prepare_warnings INSERT INTO t1 VALUES (0); SELECT a,NULLIF(a,2000),NULLIF(2000,a) FROM t1; SELECT a,NULLIF(a,2001),NULLIF(2001,a) FROM t1; diff --git a/mysql-test/main/outfile_loaddata.test b/mysql-test/main/outfile_loaddata.test index 745c75cb4de..85e26ac7b4e 100644 --- a/mysql-test/main/outfile_loaddata.test +++ b/mysql-test/main/outfile_loaddata.test @@ -2,6 +2,8 @@ DROP TABLE IF EXISTS t1, t2; --enable_warnings +--enable_prepare_warnings + --echo # --echo # Bug#31663 FIELDS TERMINATED BY special character --echo # @@ -289,6 +291,6 @@ SELECT LENGTH(a) FROM t2; DROP TABLE t1, t2; - +--disable_prepare_warnings ########################################################################### --echo # End of 5.1 tests. diff --git a/mysql-test/main/parser.test b/mysql-test/main/parser.test index 816e55435d1..c202a8ac878 100644 --- a/mysql-test/main/parser.test +++ b/mysql-test/main/parser.test @@ -885,6 +885,7 @@ SELECT 1 FROM t1 UNION SELECT 1 FROM t1 ORDER BY 1 LIMIT 1 FOR UPDATE; --echo # "INTO" clause tests +--enable_prepare_warnings SELECT 1 FROM t1 INTO @var17727401; SELECT 1 FROM DUAL INTO @var17727401; SELECT 1 INTO @var17727401; @@ -924,6 +925,7 @@ SELECT 1 FROM t1 INTO @var17727401 UNION SELECT 1 FROM t1 INTO t1; SELECT 1 FROM t1 UNION SELECT 1 FROM t1 INTO @var17727401; +--disable_prepare_warnings --error ER_PARSE_ERROR SELECT 1 INTO @var17727401 FROM t1 PROCEDURE ANALYSE(); diff --git a/mysql-test/main/partition.test b/mysql-test/main/partition.test index 5d5dafdb206..5f4c5f659ca 100644 --- a/mysql-test/main/partition.test +++ b/mysql-test/main/partition.test @@ -350,10 +350,12 @@ ENGINE=Memory; ALTER TABLE t1 ENGINE=NonExistentEngine; # OK to only specify one partitions engine, since it is already assigned at # table level (after create, it is specified on all levels and all parts). +--enable_prepare_warnings ALTER TABLE t1 PARTITION BY HASH (a) (PARTITION p0 ENGINE=Memory, PARTITION p1 ENGINE=NonExistentEngine); +--disable_prepare_warnings ALTER TABLE t1 ENGINE=NonExistentEngine; SHOW CREATE TABLE t1; DROP TABLE t1; diff --git a/mysql-test/main/partition_exchange.test b/mysql-test/main/partition_exchange.test index cb33b8dd857..e996866b1f9 100644 --- a/mysql-test/main/partition_exchange.test +++ b/mysql-test/main/partition_exchange.test @@ -5,6 +5,7 @@ DROP TABLE IF EXISTS t1, t2, t3, t, tp, tsp, tmp; --enable_warnings +--enable_prepare_warnings --echo # --echo # Bug#11894100: EXCHANGE PARTITION CAN'T BE EXECUTED IF --echo # ROW_FORMAT WAS SET EXPLICITLY @@ -536,3 +537,4 @@ ALTER TABLE t2 REMOVE PARTITIONING; ALTER TABLE t1 EXCHANGE PARTITION pm WITH TABLE t2; DROP TABLE t1, t2; +--disable_prepare_warnings diff --git a/mysql-test/main/partition_explicit_prune.test b/mysql-test/main/partition_explicit_prune.test index fdbbcadd8cb..4dc3275394f 100644 --- a/mysql-test/main/partition_explicit_prune.test +++ b/mysql-test/main/partition_explicit_prune.test @@ -355,7 +355,9 @@ eval $get_handler_status_counts; --echo # SELECT * FROM t1 PARTITION (pNeg, `p10-99`); FLUSH STATUS; +--enable_prepare_warnings SELECT * FROM t1 PARTITION (pNeg, `p10-99`) INTO OUTFILE 'loadtest.txt'; +--disable_prepare_warnings eval $get_handler_status_counts; --echo # 1 commit --echo # 10 locks (1 ha_partition + 4 ha_innobase) x 2 (lock/unlock) diff --git a/mysql-test/main/ps_ddl.test b/mysql-test/main/ps_ddl.test index 5a2a0f60a70..8d811ec00c0 100644 --- a/mysql-test/main/ps_ddl.test +++ b/mysql-test/main/ps_ddl.test @@ -63,6 +63,7 @@ drop view if exists v1, v2; TRUNCATE TABLE mysql.general_log; delimiter |; +--enable_prepare_warnings create procedure p_verify_reprepare_count(expected int) begin declare old_reprepare_count int default @reprepare_count; @@ -80,6 +81,7 @@ begin select '' as "SUCCESS"; end if; end| +--disable_prepare_warnings delimiter ;| set @reprepare_count= 0; flush status; @@ -902,14 +904,18 @@ begin return x; end| delimiter ;| +--enable_prepare_warnings create procedure p1(out x int) select max(a) from t1 into x; +--disable_prepare_warnings prepare stmt from "select * from v1"; execute stmt; execute stmt; call p_verify_reprepare_count(0); drop procedure p1; +--enable_prepare_warnings create procedure p1(out x int) select max(a) from t2 into x; +--disable_prepare_warnings --echo # XXX: used to be a bug. The prelocked list was not invalidated --echo # and we kept opening table t1, whereas the procedure --echo # is now referring to table t2 diff --git a/mysql-test/main/ps_ddl1.test b/mysql-test/main/ps_ddl1.test index 0145d445a14..e0441cb0ab8 100644 --- a/mysql-test/main/ps_ddl1.test +++ b/mysql-test/main/ps_ddl1.test @@ -30,6 +30,7 @@ drop view if exists t1; drop schema if exists mysqltest; --enable_warnings +--enable_prepare_warnings delimiter |; create procedure p_verify_reprepare_count(expected int) begin @@ -48,6 +49,7 @@ begin select '' as "SUCCESS"; end if; end| +--disable_prepare_warnings delimiter ;| set @reprepare_count= 0; flush status; diff --git a/mysql-test/main/query_cache.test b/mysql-test/main/query_cache.test index e49387dcaf4..f8152945396 100644 --- a/mysql-test/main/query_cache.test +++ b/mysql-test/main/query_cache.test @@ -432,10 +432,12 @@ drop table t1; create table t1 (a int); insert into t1 values (1),(2),(3); show status like "Qcache_queries_in_cache"; +--enable_prepare_warnings select * from t1 into outfile "query_cache.out.file"; --error ER_FILE_EXISTS_ERROR select * from t1 into outfile "query_cache.out.file"; select * from t1 limit 1 into dumpfile "query_cache.dump.file"; +--disable_prepare_warnings show status like "Qcache_queries_in_cache"; drop table t1; let $datadir=`select @@datadir`; @@ -812,12 +814,14 @@ end// call p1()// drop procedure p1// +--enable_prepare_warnings create function f1() returns int begin Declare var1 int; select max(a) from t1 into var1; return var1; end// +--disable_prepare_warnings create procedure `p1`() begin select a, f1() from t1; diff --git a/mysql-test/main/select.test b/mysql-test/main/select.test index 22baccc625c..b9891280c45 100644 --- a/mysql-test/main/select.test +++ b/mysql-test/main/select.test @@ -3525,7 +3525,9 @@ CREATE VIEW v1 AS SELECT 1 AS ` `; --error 1166 CREATE VIEW v1 AS SELECT (SELECT 1 AS ` `); +--enable_prepare_warnings CREATE VIEW v1 AS SELECT 1 AS ` x`; +--disable_prepare_warnings SELECT `x` FROM v1; --error 1166 diff --git a/mysql-test/main/signal_demo1.test b/mysql-test/main/signal_demo1.test index 62020b8f3fd..ff6a4437cdf 100644 --- a/mysql-test/main/signal_demo1.test +++ b/mysql-test/main/signal_demo1.test @@ -67,6 +67,8 @@ delimiter $$; --echo # Schema integrity enforcement --echo # +--enable_prepare_warnings + create procedure check_pk_person(in person_type char, in id integer) begin declare x integer; @@ -158,6 +160,8 @@ begin end $$ +--disable_prepare_warnings + create trigger po_order_bi before insert on po_order for each row begin diff --git a/mysql-test/main/sp-anchor-row-type-cursor.test b/mysql-test/main/sp-anchor-row-type-cursor.test index 7089175507c..bf4b6968458 100644 --- a/mysql-test/main/sp-anchor-row-type-cursor.test +++ b/mysql-test/main/sp-anchor-row-type-cursor.test @@ -1006,6 +1006,7 @@ DROP TABLE t1; --echo # SELECT INTO + cursor ROW TYPE variable with a wrong column count --echo # +--enable_prepare_warnings CREATE TABLE t1 (a INT, b VARCHAR(32)); INSERT INTO t1 VALUES (10,'b10'); DELIMITER $$; @@ -1068,6 +1069,8 @@ CALL p1(); DROP TABLE t1; DROP PROCEDURE p1; +--disable_prepare_warnings + --echo # --echo # End of MDEV-12461 TYPE OF and ROW TYPE OF anchored data types --echo # diff --git a/mysql-test/main/sp-anchor-row-type-table.test b/mysql-test/main/sp-anchor-row-type-table.test index 3f04dc68586..33b2d7487a4 100644 --- a/mysql-test/main/sp-anchor-row-type-table.test +++ b/mysql-test/main/sp-anchor-row-type-table.test @@ -11,6 +11,8 @@ --echo # Referring to a table in a non-existing database --echo # +--enable_prepare_warnings + DELIMITER $$; CREATE PROCEDURE p1() BEGIN @@ -881,3 +883,4 @@ END; $$ DELIMITER ;$$ DROP TABLE t1; +--disable_prepare_warnings diff --git a/mysql-test/main/sp-anchor-type.test b/mysql-test/main/sp-anchor-type.test index b340cf776c5..56136c4bd63 100644 --- a/mysql-test/main/sp-anchor-type.test +++ b/mysql-test/main/sp-anchor-type.test @@ -659,6 +659,7 @@ DROP TABLE t1; CREATE TABLE t1 (a INT, b VARCHAR(10),c DATETIME(3)); INSERT INTO t1 VALUES (1,'b1','2001-01-01 10:20:30.123'); DELIMITER $$; +--enable_prepare_warnings CREATE PROCEDURE p1() BEGIN DECLARE v_a TYPE OF t1.a; @@ -669,6 +670,7 @@ BEGIN END; $$ DELIMITER ;$$ +--disable_prepare_warnings CALL p1(); DROP PROCEDURE p1; DROP TABLE t1; diff --git a/mysql-test/main/sp-big.test b/mysql-test/main/sp-big.test index 043e737105a..ff091c0a883 100644 --- a/mysql-test/main/sp-big.test +++ b/mysql-test/main/sp-big.test @@ -8,6 +8,7 @@ insert into t1 values (1),(2),(3); let $body=`select repeat('select count(*) into out1 from t1;\n', 3072)`; +--enable_prepare_warnings delimiter //; --disable_query_log eval select length('$body') as length// @@ -16,6 +17,7 @@ begin $body end// --enable_query_log +--disable_prepare_warnings delimiter ;// @@ -98,6 +100,7 @@ create table t1 ( ) default collate=latin1_bin; delimiter //; +--enable_prepare_warnings create procedure select_test() begin declare id1_cond int; @@ -107,6 +110,7 @@ begin set id1_cond = id1_cond + 1; end while; end// +--disable_prepare_warnings delimiter ;// insert t1 select seq, seq, 1, 1, seq, seq, seq from seq_1_to_2000; diff --git a/mysql-test/main/sp-error.test b/mysql-test/main/sp-error.test index 3ce3623be18..9b0213a1f91 100644 --- a/mysql-test/main/sp-error.test +++ b/mysql-test/main/sp-error.test @@ -9,9 +9,10 @@ drop table if exists t1, t2; --enable_warnings # Backup the mysql.proc table +--enable_prepare_warnings --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR eval SELECT * FROM mysql.proc INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/proc.txt'; - +--disable_prepare_warnings # Make sure we don't have any procedures left. delete from mysql.proc; @@ -42,8 +43,10 @@ drop table if exists t3| create table t3 ( x int )| insert into t3 values (2), (3)| +--enable_prepare_warnings create procedure bad_into(out param int) select x from t3 into param| +--disable_prepare_warnings --error 1172 call bad_into(@x)| @@ -3797,12 +3800,14 @@ delimiter |; --echo # because SIGNAL would raise SQL-error in that case. --echo +--enable_prepare_warnings CREATE FUNCTION f1() RETURNS INTEGER BEGIN DECLARE v VARCHAR(5) DEFAULT -1; SELECT b FROM t1 WHERE a = 2 INTO v; RETURN v; END| +--disable_prepare_warnings --echo --echo # Here we check that the NOT_FOUND condition raised in f1() diff --git a/mysql-test/main/sp_gis.test b/mysql-test/main/sp_gis.test index 4148a4ec423..749586854a3 100644 --- a/mysql-test/main/sp_gis.test +++ b/mysql-test/main/sp_gis.test @@ -12,6 +12,8 @@ drop function if exists x; drop function if exists y; --enable_warnings +--enable_prepare_warnings + create function a() returns int return 1; @@ -97,6 +99,8 @@ SELECT geometrycollection(); --enable_warnings DROP FUNCTION geometrycollection; +--disable_prepare_warnings + --echo # --echo # End of 10.5 tests --echo # diff --git a/mysql-test/main/sp_trans.test b/mysql-test/main/sp_trans.test index b39c13287ed..abc308a26d8 100644 --- a/mysql-test/main/sp_trans.test +++ b/mysql-test/main/sp_trans.test @@ -522,6 +522,7 @@ select @@session.max_heap_table_size| --disable_warnings create table t3 (a char(255)) engine=InnoDB| --enable_warnings +--enable_prepare_warnings create procedure bug14210_fill_table() begin declare table_size, max_table_size int default 0; @@ -533,6 +534,7 @@ begin select count(*)*255 from t3 into table_size; until table_size > max_table_size*2 end repeat; end| +--disable_prepare_warnings --disable_warnings call bug14210_fill_table()| --enable_warnings diff --git a/mysql-test/main/sp_trans_log.test b/mysql-test/main/sp_trans_log.test index deea6e6d9b6..12efcc46ada 100644 --- a/mysql-test/main/sp_trans_log.test +++ b/mysql-test/main/sp_trans_log.test @@ -22,6 +22,7 @@ CREATE TABLE t2 (a int NOT NULL auto_increment, b int, PRIMARY KEY (a)) ENGINE= insert into t2 values (1,1)| +--enable_prepare_warnings create function bug23333() RETURNS int(11) DETERMINISTIC @@ -31,6 +32,7 @@ begin return @a; end| delimiter ;| +--disable_prepare_warnings reset master; --error ER_DUP_ENTRY diff --git a/mysql-test/main/subselect_exists2in_costmat.test b/mysql-test/main/subselect_exists2in_costmat.test index 5d5eeaee268..371f0936d1a 100644 --- a/mysql-test/main/subselect_exists2in_costmat.test +++ b/mysql-test/main/subselect_exists2in_costmat.test @@ -47,7 +47,9 @@ create index Language on CountryLanguage(Language); create index CityName on City(Name); alter table City change population population int(11) null default 0; +--enable_prepare_warnings select max(id) from City into @max_city_id; +--disable_prepare_warnings insert into City values (@max_city_id + 1,'Kilifarevo','BGR',NULL); diff --git a/mysql-test/main/subselect_mat_cost.test b/mysql-test/main/subselect_mat_cost.test index 73ba717a8dc..8fe38849735 100644 --- a/mysql-test/main/subselect_mat_cost.test +++ b/mysql-test/main/subselect_mat_cost.test @@ -53,7 +53,9 @@ create index Language on CountryLanguage(Language); create index CityName on City(Name); alter table City change population population int(11) null default 0; +--enable_prepare_warnings select max(id) from City into @max_city_id; +--disable_prepare_warnings insert into City values (@max_city_id + 1,'Kilifarevo','BGR',NULL); diff --git a/mysql-test/main/temporal_literal.test b/mysql-test/main/temporal_literal.test index 6783b19a7d4..5126796dc33 100644 --- a/mysql-test/main/temporal_literal.test +++ b/mysql-test/main/temporal_literal.test @@ -243,7 +243,9 @@ SELECT TIMESTAMP('2001-01-01 10:10:10.123456xyz'); SELECT TIMESTAMP('2001-01-01 10:10:10.1234567xyz'); CREATE TABLE t1 (a TIME(6)); +--enable_prepare_warnings INSERT INTO t1 VALUES (TIME'10:20:30.1234567'); +--disable_prepare_warnings INSERT INTO t1 VALUES (TIME('10:20:30.1234567')); SELECT * FROM t1; DROP TABLE t1; diff --git a/mysql-test/main/trigger.test b/mysql-test/main/trigger.test index 086912000d9..6fb194ed8dd 100644 --- a/mysql-test/main/trigger.test +++ b/mysql-test/main/trigger.test @@ -761,6 +761,7 @@ drop table t1; create table t1 (id int, data int, username varchar(16)); insert into t1 (id, data) values (1, 0); +--enable_prepare_warnings delimiter |; create trigger t1_whoupdated before update on t1 for each row begin @@ -771,6 +772,7 @@ begin select count(*) from ((select 1) union (select 2)) as d1 into i; end| delimiter ;| +--disable_prepare_warnings update t1 set data = 1; connection addconroot1; @@ -2343,6 +2345,7 @@ DROP TABLE IF EXISTS t1, t2; CREATE TABLE t1 (b VARCHAR(50) NOT NULL); CREATE TABLE t2 (a VARCHAR(10) NOT NULL DEFAULT ''); +--enable_prepare_warnings delimiter //; CREATE TRIGGER trg1 AFTER INSERT ON t2 FOR EACH ROW BEGIN @@ -2350,6 +2353,7 @@ FOR EACH ROW BEGIN (@bug51650 IS NULL OR @bug51650 != c.b) AND c.b = NEW.a LIMIT 1 INTO @foo; END// delimiter ;// +--disable_prepare_warnings SET @bug51650 = 1; INSERT IGNORE INTO t2 VALUES(); diff --git a/mysql-test/main/type_blob.test b/mysql-test/main/type_blob.test index 38c8b9a83ca..c61ed124139 100644 --- a/mysql-test/main/type_blob.test +++ b/mysql-test/main/type_blob.test @@ -526,14 +526,18 @@ CREATE TABLE b15776 (a char(4294967296)); ## When we complain about it, we say that the max is 255. We may be ## talking about different things. It's confusing. --replace_result 4294967295 ? 0 ? +--enable_prepare_warnings CREATE TABLE b15776 (a year(4294967295)); +--disable_prepare_warnings INSERT INTO b15776 VALUES (42); SELECT * FROM b15776; DROP TABLE b15776; CREATE TABLE b15776 (a year(4294967296)); SHOW CREATE TABLE b15776; DROP TABLE b15776; +--enable_prepare_warnings CREATE TABLE b15776 (a year(0)); # 0 is special case, means default size +--disable_prepare_warnings DROP TABLE b15776; --error ER_PARSE_ERROR CREATE TABLE b15776 (a year(-2)); diff --git a/mysql-test/main/type_newdecimal.test b/mysql-test/main/type_newdecimal.test index 5b7ecf89a07..5e4d3b4b84b 100644 --- a/mysql-test/main/type_newdecimal.test +++ b/mysql-test/main/type_newdecimal.test @@ -1339,9 +1339,11 @@ DESC t1; SELECT * FROM t1; DROP TABLE t1; +--enable_prepare_warnings CREATE TABLE t1 SELECT /* 82 */ 1000000000000000000000000000000000000000000000000000000000000000000000000000000001 AS c1; +--disable_prepare_warnings DESC t1; SELECT * FROM t1; DROP TABLE t1; diff --git a/mysql-test/main/type_year.test b/mysql-test/main/type_year.test index 0f1f49be5d0..09538fab805 100644 --- a/mysql-test/main/type_year.test +++ b/mysql-test/main/type_year.test @@ -2,6 +2,8 @@ # Test year # +--enable_prepare_warnings + create table t1 (y year,y2 year(2)); insert into t1 values (0,0),(1999,1999),(2000,2000),(2001,2001),(70,70),(69,69); select * from t1; @@ -372,7 +374,7 @@ SELECT MAX(NULLIF(a, 1970)) AS f FROM t1; --enable_ps_protocol DROP TABLE t1; - +--disable_prepare_warnings --echo # --echo # End of 10.5 tests --echo # diff --git a/mysql-test/main/union.test b/mysql-test/main/union.test index 8d023546b3d..7e0147cd337 100644 --- a/mysql-test/main/union.test +++ b/mysql-test/main/union.test @@ -987,7 +987,9 @@ DROP TABLE t1; (select 1) union (select 1 into @var); --error ER_PARSE_ERROR (select 2) union (select 1 into @var); +--enable_prepare_warnings (select 1) union (select 1) into @var; +--disable_prepare_warnings --error ER_TOO_MANY_ROWS (select 2) union (select 1) into @var; @@ -1115,9 +1117,11 @@ SELECT a FROM t1 UNION SELECT a INTO @v FROM t1; SELECT a FROM t1 UNION SELECT a INTO OUTFILE 'union.out.file5' FROM t1; --error ER_PARSE_ERROR SELECT a FROM t1 UNION SELECT a INTO OUTFILE 'union.out.file6' FROM t1; +--enable_prepare_warnings SELECT a FROM t1 UNION SELECT a FROM t1 INTO @v ; SELECT a FROM t1 UNION SELECT a FROM t1 INTO OUTFILE 'union.out.file5'; SELECT a FROM t1 UNION SELECT a FROM t1 INTO OUTFILE 'union.out.file6'; +--disable_prepare_warnings --error ER_PARSE_ERROR SELECT a INTO @v FROM t1 UNION SELECT a FROM t1; --error ER_PARSE_ERROR diff --git a/mysql-test/main/userstat.test b/mysql-test/main/userstat.test index 6d486810db1..5691a2dc890 100644 --- a/mysql-test/main/userstat.test +++ b/mysql-test/main/userstat.test @@ -7,7 +7,9 @@ -- source include/have_log_bin.inc -- source include/have_perfschema.inc +--enable_prepare_warnings select variable_value from information_schema.global_status where variable_name="handler_read_key" into @global_read_key; +--disable_prepare_warnings show columns from information_schema.client_statistics; show columns from information_schema.user_statistics; show columns from information_schema.index_statistics; diff --git a/mysql-test/main/view.test b/mysql-test/main/view.test index 73322d97591..74f80919333 100644 --- a/mysql-test/main/view.test +++ b/mysql-test/main/view.test @@ -2292,6 +2292,7 @@ CREATE VIEW v1 AS SELECT 42 AS Meaning; DROP FUNCTION IF EXISTS f1; --enable_warnings DELIMITER //; +--enable_prepare_warnings CREATE FUNCTION f1() RETURNS INTEGER BEGIN DECLARE retn INTEGER; @@ -2300,6 +2301,7 @@ BEGIN END // DELIMITER ;// +--disable_prepare_warnings CREATE VIEW v2 AS SELECT f1(); select * from v2; drop view v2,v1; @@ -2476,6 +2478,7 @@ drop view t1, v1; # using SP function create table t1 (a int); delimiter //; +--enable_prepare_warnings create function f1() returns int begin declare mx int; @@ -2483,6 +2486,7 @@ begin return mx; end// delimiter ;// +--disable_prepare_warnings create view v1 as select f1() as a; create view v2 as select * from v1; drop table t1; @@ -3117,12 +3121,13 @@ DROP VIEW IF EXISTS v1; let $query = SELECT * FROM (SELECT 1) AS t into @w; +--enable_prepare_warnings eval $query; --error ER_PARSE_ERROR eval CREATE VIEW v1 AS $query; --echo # Previously the following would fail. eval $query; - +--disable_prepare_warnings # # Bug#24532 The return data type of IS TRUE is different from similar operations @@ -3885,11 +3890,13 @@ CREATE TABLE t1 (a INT); CREATE TABLE t2 (a INT); delimiter //; +--enable_prepare_warnings CREATE FUNCTION f1() RETURNS INT BEGIN SELECT a FROM v2 INTO @a; RETURN @a; END// +--disable_prepare_warnings delimiter ;// --echo # Trigger pre-locking when opening v2. diff --git a/mysql-test/main/view_grant.test b/mysql-test/main/view_grant.test index 18ff8aaf4fc..83bbeb3be77 100644 --- a/mysql-test/main/view_grant.test +++ b/mysql-test/main/view_grant.test @@ -494,10 +494,12 @@ create table t2 (s1 int); --disable_warnings drop function if exists f2; --enable_warnings +--enable_prepare_warnings delimiter //; create function f2 () returns int begin declare v int; select s1 from t2 into v; return v; end// delimiter ;// +--disable_prepare_warnings create algorithm=TEMPTABLE view v1 as select f2() from t1; create algorithm=MERGE view v2 as select f2() from t1; create algorithm=TEMPTABLE SQL SECURITY INVOKER view v3 as select f2() from t1; @@ -548,10 +550,12 @@ create table t2 (s1 int); --disable_warnings drop function if exists f2; --enable_warnings +--enable_prepare_warnings delimiter //; create function f2 () returns int begin declare v int; select s1 from t2 into v; return v; end// delimiter ;// +--disable_prepare_warnings create user mysqltest_1@localhost; grant select on t1 to mysqltest_1@localhost; grant execute on function f2 to mysqltest_1@localhost; From ccb0504fb02a5896455f6feb2b73a09d2d509f94 Mon Sep 17 00:00:00 2001 From: Dmitry Shulga Date: Wed, 9 Jun 2021 23:03:34 +0700 Subject: [PATCH 119/251] MDEV-16708: fix in test failures caused by missing warnings received in prepare response packet --- mysql-test/suite/compat/oracle/r/sp-package.result | 2 -- mysql-test/suite/compat/oracle/t/parser.test | 4 ++-- mysql-test/suite/compat/oracle/t/sp-package.test | 4 ++-- mysql-test/suite/funcs_1/t/is_columns_memory.test | 4 ++++ mysql-test/suite/funcs_1/t/is_columns_myisam.test | 4 ++++ mysql-test/suite/funcs_1/t/storedproc.test | 2 ++ mysql-test/suite/innodb/t/innodb_bug51920.test | 2 ++ mysql-test/suite/perfschema/t/ortho_iter.test | 4 ++++ mysql-test/suite/perfschema/t/rpl_threads.test | 6 ++++++ mysql-test/suite/versioning/t/load_data.test | 2 ++ mysql-test/suite/versioning/t/sysvars.test | 6 ++++++ 11 files changed, 34 insertions(+), 6 deletions(-) diff --git a/mysql-test/suite/compat/oracle/r/sp-package.result b/mysql-test/suite/compat/oracle/r/sp-package.result index e7ab4eaa4a2..cffb3ce7857 100644 --- a/mysql-test/suite/compat/oracle/r/sp-package.result +++ b/mysql-test/suite/compat/oracle/r/sp-package.result @@ -34,7 +34,6 @@ ERROR HY000: Incorrect usage of OR REPLACE and IF NOT EXISTS # PACKAGE and PS # PREPARE stmt FROM 'CREATE PACKAGE test2 AS FUNCTION f1 RETURN INT; END test2'; -ERROR HY000: This command is not supported in the prepared statement protocol yet CREATE PACKAGE test2 AS FUNCTION f1 RETURN INT; END; @@ -42,7 +41,6 @@ $$ PREPARE stmt FROM 'CREATE PACKAGE BODY test2 AS' ' FUNCTION f1 RETURN INT AS BEGIN RETURN 10; END;' 'END test2'; -ERROR HY000: This command is not supported in the prepared statement protocol yet DROP PACKAGE test2; # # Package and READ ONLY transactions diff --git a/mysql-test/suite/compat/oracle/t/parser.test b/mysql-test/suite/compat/oracle/t/parser.test index c2019f258ce..40b4e297e93 100644 --- a/mysql-test/suite/compat/oracle/t/parser.test +++ b/mysql-test/suite/compat/oracle/t/parser.test @@ -247,6 +247,7 @@ CALL comment(); CALL comment; DROP PROCEDURE comment; +enable_prepare_warnings; DELIMITER /; CREATE FUNCTION comment RETURN INT COMMENT 'test' AS BEGIN @@ -254,7 +255,6 @@ BEGIN END; / DELIMITER ;/ -enable_prepare_warnings; SELECT test.comment() FROM DUAL; disable_prepare_warnings; DROP FUNCTION comment; @@ -570,8 +570,8 @@ call p1(1,2); drop procedure p1; -delimiter //; set sql_mode=ORACLE; +delimiter //; create or replace procedure p1(id int, dt int) as begin while (1) diff --git a/mysql-test/suite/compat/oracle/t/sp-package.test b/mysql-test/suite/compat/oracle/t/sp-package.test index 96420c18820..edad90e547f 100644 --- a/mysql-test/suite/compat/oracle/t/sp-package.test +++ b/mysql-test/suite/compat/oracle/t/sp-package.test @@ -2,6 +2,7 @@ SET sql_mode=ORACLE; +--enable_prepare_warnings --echo # --echo # Creating a body of a non-existing package @@ -49,7 +50,6 @@ DELIMITER ;$$ --echo # PACKAGE and PS --echo # ---error ER_UNSUPPORTED_PS PREPARE stmt FROM 'CREATE PACKAGE test2 AS FUNCTION f1 RETURN INT; END test2'; DELIMITER $$; @@ -58,7 +58,6 @@ CREATE PACKAGE test2 AS END; $$ DELIMITER ;$$ ---error ER_UNSUPPORTED_PS PREPARE stmt FROM 'CREATE PACKAGE BODY test2 AS' ' FUNCTION f1 RETURN INT AS BEGIN RETURN 10; END;' 'END test2'; @@ -2689,3 +2688,4 @@ DELIMITER ;$$ CALL xyz.xyz123(17,18,@R); DROP PACKAGE xyz; DROP TABLE t1; +--disable_prepare_warnings diff --git a/mysql-test/suite/funcs_1/t/is_columns_memory.test b/mysql-test/suite/funcs_1/t/is_columns_memory.test index 8ec32895217..f5ed6b6e40a 100644 --- a/mysql-test/suite/funcs_1/t/is_columns_memory.test +++ b/mysql-test/suite/funcs_1/t/is_columns_memory.test @@ -15,6 +15,8 @@ --source include/not_embedded.inc --source include/default_charset.inc +--enable_prepare_warnings + let $engine_type= MEMORY; SET @@session.sql_mode = 'NO_ENGINE_SUBSTITUTION'; --source suite/funcs_1/datadict/datadict_load.inc @@ -23,4 +25,6 @@ SET @@session.sql_mode = 'NO_ENGINE_SUBSTITUTION'; let $my_where = WHERE table_schema LIKE 'test%'; --source suite/funcs_1/datadict/columns.inc +--disable_prepare_warnings + --source suite/funcs_1/include/cleanup.inc diff --git a/mysql-test/suite/funcs_1/t/is_columns_myisam.test b/mysql-test/suite/funcs_1/t/is_columns_myisam.test index 9b9974044aa..97a23717b1c 100644 --- a/mysql-test/suite/funcs_1/t/is_columns_myisam.test +++ b/mysql-test/suite/funcs_1/t/is_columns_myisam.test @@ -15,6 +15,8 @@ --source include/not_embedded.inc --source include/default_charset.inc +--enable_prepare_warnings + let $engine_type= MyISAM; SET @@session.sql_mode = 'NO_ENGINE_SUBSTITUTION'; --source suite/funcs_1/datadict/datadict_load.inc @@ -23,4 +25,6 @@ SET @@session.sql_mode = 'NO_ENGINE_SUBSTITUTION'; let $my_where = WHERE table_schema LIKE 'test%'; --source suite/funcs_1/datadict/columns.inc +--disable_prepare_warnings + --source suite/funcs_1/include/cleanup.inc diff --git a/mysql-test/suite/funcs_1/t/storedproc.test b/mysql-test/suite/funcs_1/t/storedproc.test index dde624bd0b9..8712919e430 100644 --- a/mysql-test/suite/funcs_1/t/storedproc.test +++ b/mysql-test/suite/funcs_1/t/storedproc.test @@ -10,6 +10,7 @@ # ############################################################################ +--disable_ps_protocol --source include/default_charset.inc set sql_mode=""; @@ -29547,3 +29548,4 @@ DROP TABLE IF EXISTS res_t1; let $message= . +++ END OF SCRIPT +++; --source include/show_msg80.inc # ============================================================================== +--enable_ps_protocol diff --git a/mysql-test/suite/innodb/t/innodb_bug51920.test b/mysql-test/suite/innodb/t/innodb_bug51920.test index c83e00db22a..0a9839b612a 100644 --- a/mysql-test/suite/innodb/t/innodb_bug51920.test +++ b/mysql-test/suite/innodb/t/innodb_bug51920.test @@ -22,9 +22,11 @@ let $wait_condition = WHERE INFO="UPDATE bug51920 SET i=2"; -- source include/wait_condition.inc +--enable_prepare_warnings SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE INFO="UPDATE bug51920 SET i=2" INTO @thread_id; +--disable_prepare_warnings KILL @thread_id; let $wait_condition = diff --git a/mysql-test/suite/perfschema/t/ortho_iter.test b/mysql-test/suite/perfschema/t/ortho_iter.test index fe1d916b6a0..d577b6dba5b 100644 --- a/mysql-test/suite/perfschema/t/ortho_iter.test +++ b/mysql-test/suite/perfschema/t/ortho_iter.test @@ -25,6 +25,8 @@ flush status; # (select event_name from # performance_schema.memory_summary_by_account_by_event_name)); +--enable_prepare_warnings + delimiter $; create procedure check_instrument(in instr_name varchar(128)) begin @@ -274,6 +276,8 @@ end $ delimiter ;$ +--disable_prepare_warnings + # Check the configuration is ok show global variables like "performance_schema%"; diff --git a/mysql-test/suite/perfschema/t/rpl_threads.test b/mysql-test/suite/perfschema/t/rpl_threads.test index 984939c21f8..a5ca51a94a4 100644 --- a/mysql-test/suite/perfschema/t/rpl_threads.test +++ b/mysql-test/suite/perfschema/t/rpl_threads.test @@ -29,9 +29,11 @@ connection master; # Read the ID of the binlog dump connection, # as exposed in PROCESSLIST. +--enable_prepare_warnings select ID from INFORMATION_SCHEMA.PROCESSLIST where COMMAND = "Binlog Dump" into @master_dump_pid; +--disable_prepare_warnings select COMMAND, STATE from INFORMATION_SCHEMA.PROCESSLIST @@ -47,9 +49,11 @@ sync_slave_with_master; # Read the ID of the SLAVE IO thread, # as exposed in PROCESSLIST. +--enable_prepare_warnings select ID from INFORMATION_SCHEMA.PROCESSLIST where STATE like "Waiting for master to send event%" into @slave_io_pid; +--disable_prepare_warnings select COMMAND, STATE from INFORMATION_SCHEMA.PROCESSLIST @@ -62,9 +66,11 @@ select NAME, TYPE, PROCESSLIST_COMMAND, PROCESSLIST_STATE # Read the ID of the SLAVE SQL thread, # as exposed in PROCESSLIST. +--enable_prepare_warnings select ID from INFORMATION_SCHEMA.PROCESSLIST where STATE like "Slave has read all relay log%" into @slave_sql_pid; +--disable_prepare_warnings select COMMAND, STATE from INFORMATION_SCHEMA.PROCESSLIST diff --git a/mysql-test/suite/versioning/t/load_data.test b/mysql-test/suite/versioning/t/load_data.test index 4db6eee6c4d..3bac2942a81 100644 --- a/mysql-test/suite/versioning/t/load_data.test +++ b/mysql-test/suite/versioning/t/load_data.test @@ -4,7 +4,9 @@ CREATE TABLE t1 (a INT, b INT, c INT, vc INT AS (c), UNIQUE(a), UNIQUE(b)) WITH SYSTEM VERSIONING; INSERT IGNORE INTO t1 (a,b,c) VALUES (1,2,3); +--enable_prepare_warnings SELECT a, b, c FROM t1 INTO OUTFILE '15330.data'; +--disable_prepare_warnings LOAD DATA INFILE '15330.data' IGNORE INTO TABLE t1 (a,b,c); LOAD DATA INFILE '15330.data' REPLACE INTO TABLE t1 (a,b,c); diff --git a/mysql-test/suite/versioning/t/sysvars.test b/mysql-test/suite/versioning/t/sysvars.test index a1026418e98..34c98c48ff7 100644 --- a/mysql-test/suite/versioning/t/sysvars.test +++ b/mysql-test/suite/versioning/t/sysvars.test @@ -57,7 +57,9 @@ show global variables like 'system_versioning_asof'; set global system_versioning_asof= '1900-01-01 00:00:00'; show global variables like 'system_versioning_asof'; +--enable_prepare_warnings set global system_versioning_asof= timestamp'1911-11-11 11:11:11.1111119'; +--disable_prepare_warnings show global variables like 'system_versioning_asof'; set @ts= timestamp'1900-01-01 00:00:00'; @@ -74,7 +76,9 @@ show variables like 'system_versioning_asof'; set system_versioning_asof= '1900-01-01 00:00:00'; show variables like 'system_versioning_asof'; +--enable_prepare_warnings set system_versioning_asof= timestamp'1911-11-11 11:11:11.1111119'; +--disable_prepare_warnings show variables like 'system_versioning_asof'; set @ts= timestamp'1900-01-01 00:00:00'; @@ -134,7 +138,9 @@ drop tables t1, t2; --echo # SET sql_mode=TIME_ROUND_FRACTIONAL; +--enable_prepare_warnings SET @@global.system_versioning_asof= timestamp'2001-12-31 23:59:59.9999999'; +--disable_prepare_warnings SELECT @@global.system_versioning_asof; SET @@global.system_versioning_asof= DEFAULT; From 994e3f40b5588a044dcebeb20f3e8a217c3bad79 Mon Sep 17 00:00:00 2001 From: Dmitry Shulga Date: Thu, 10 Jun 2021 01:00:31 +0700 Subject: [PATCH 120/251] MDEV-16708: fixed incorrect issuing the error ' Access denied; you need (at least one of) the SUPER privilege(s) for this operation on executing SET system_variable=.... in PS mode --- sql/set_var.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sql/set_var.cc b/sql/set_var.cc index 724225f1058..f03152ace03 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -836,9 +836,9 @@ int set_var::light_check(THD *thd) my_error(err, MYF(0), var->name.str); return -1; } - if (type == OPT_GLOBAL && - check_global_access(thd, PRIV_SET_GLOBAL_SYSTEM_VARIABLE)) - return 1; + + if (type == OPT_GLOBAL && var->on_check_access_global(thd)) + return 1; if (value && value->fix_fields_if_needed_for_scalar(thd, &value)) return -1; From fe784950532e96812d06f1bcd6b977435154b15c Mon Sep 17 00:00:00 2001 From: Dmitry Shulga Date: Fri, 11 Jun 2021 11:25:56 +0700 Subject: [PATCH 121/251] MDEV-16708: fixed assert firing in the method THD::reset_for_the_next_command --- sql/sql_binlog.cc | 22 +++++++++++++++++++++- sql/sql_class.h | 27 +++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/sql/sql_binlog.cc b/sql/sql_binlog.cc index 5cd70199645..bab2afb957a 100644 --- a/sql/sql_binlog.cc +++ b/sql/sql_binlog.cc @@ -354,8 +354,28 @@ void mysql_client_binlog_statement(THD* thd) (ev->flags & LOG_EVENT_SKIP_REPLICATION_F ? OPTION_SKIP_REPLICATION : 0); - err= ev->apply_event(rgi); + { + /* + For conventional statements thd->lex points to thd->main_lex, that is + thd->lex == &thd->main_lex. On the other hand, for prepared statement + thd->lex points to the LEX object explicitly allocated for execution + of the prepared statement and in this case thd->lex != &thd->main_lex. + On handling the BINLOG statement, invocation of ev->apply_event(rgi) + initiates the following sequence of calls + Rows_log_event::do_apply_event -> THD::reset_for_next_command + Since the method THD::reset_for_next_command() contains assert + DBUG_ASSERT(lex == &main_lex) + this sequence of calls results in crash when a binlog event is + applied in PS mode. So, reset the current lex temporary to point to + thd->main_lex before running ev->apply_event() and restore its + original value on return. + */ + LEX *backup_lex; + thd->backup_and_reset_current_lex(&backup_lex); + err= ev->apply_event(rgi); + thd->restore_current_lex(backup_lex); + } thd->variables.option_bits= (thd->variables.option_bits & ~OPTION_SKIP_REPLICATION) | save_skip_replication; diff --git a/sql/sql_class.h b/sql/sql_class.h index 004b92712c8..713523b7d75 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -5453,6 +5453,33 @@ public: return (variables.old_behavior & OLD_MODE_UTF8_IS_UTF8MB3 ? MY_UTF8_IS_UTF8MB3 : 0); } + + /** + Save current lex to the output parameter and reset it to point to + main_lex. This method is called from mysql_client_binlog_statement() + to temporary + + @param[out] backup_lex original value of current lex + */ + + void backup_and_reset_current_lex(LEX **backup_lex) + { + *backup_lex= lex; + lex= &main_lex; + } + + + /** + Restore current lex to its original value it had before calling the method + backup_and_reset_current_lex(). + + @param backup_lex original value of current lex + */ + + void restore_current_lex(LEX *backup_lex) + { + lex= backup_lex; + } }; From 97e8d27bed097e6be2c2924077d6f4fd16f94280 Mon Sep 17 00:00:00 2001 From: Dmitry Shulga Date: Thu, 10 Jun 2021 11:12:27 +0700 Subject: [PATCH 122/251] MDEV-16708: fix in test failures(added --enable_prepared_warnings/--disable_prepared_warnings) --- mysql-test/include/column_compression_syntax_varbinary.inc | 3 +++ mysql-test/include/column_compression_syntax_varchar.inc | 3 +++ mysql-test/suite/compat/oracle/t/sp-package-innodb.test | 4 ++++ mysql-test/suite/compat/oracle/t/update_innodb.test | 3 +++ mysql-test/suite/engines/funcs/r/rpl_sp.result | 2 +- mysql-test/suite/funcs_1/include/innodb_tb2.inc | 2 ++ mysql-test/suite/funcs_1/include/innodb_tb4.inc | 2 ++ mysql-test/suite/funcs_1/include/memory_tb2.inc | 5 +++++ mysql-test/suite/funcs_1/include/memory_tb4.inc | 2 ++ mysql-test/suite/handler/handler.inc | 2 ++ mysql-test/suite/innodb/t/data_types.test | 4 ++++ mysql-test/suite/innodb/t/innodb_bug30919.test | 4 ++++ mysql-test/suite/perfschema/t/alter_table_progress.test | 2 ++ mysql-test/suite/perfschema/t/dml_handler.test | 5 ++++- mysql-test/suite/perfschema/t/selects.test | 2 ++ mysql-test/suite/rpl/r/rpl_sp.result | 2 +- mysql-test/suite/rpl/t/rpl_bug31076.test | 5 +++++ mysql-test/suite/rpl/t/rpl_drop_db.test | 2 ++ mysql-test/suite/rpl/t/rpl_events.test | 5 +++++ mysql-test/suite/rpl/t/rpl_heartbeat.test | 3 +++ mysql-test/suite/rpl/t/rpl_heartbeat_basic.test | 4 ++++ mysql-test/suite/rpl/t/rpl_innodb_bug30888.test | 3 ++- mysql-test/suite/rpl/t/rpl_mdev12179.test | 2 ++ mysql-test/suite/rpl/t/rpl_misc_functions.test | 2 ++ mysql-test/suite/rpl/t/rpl_sp.test | 2 +- .../sys_vars/t/innodb_fil_make_page_dirty_debug_basic.test | 2 ++ .../sys_vars/t/innodb_saved_page_number_debug_basic.test | 2 ++ mysql-test/suite/sys_vars/t/secure_file_priv.test | 2 ++ mysql-test/suite/versioning/t/alter.test | 2 ++ mysql-test/suite/versioning/t/commit_id.test | 4 ++++ mysql-test/suite/versioning/t/create.test | 3 +++ mysql-test/suite/versioning/t/foreign.test | 2 ++ mysql-test/suite/versioning/t/insert.test | 2 ++ mysql-test/suite/versioning/t/partition.test | 4 ++++ mysql-test/suite/versioning/t/select.test | 6 ++++++ mysql-test/suite/versioning/t/select2.test | 5 ++++- mysql-test/suite/versioning/t/trx_id.test | 4 ++++ 37 files changed, 107 insertions(+), 6 deletions(-) diff --git a/mysql-test/include/column_compression_syntax_varbinary.inc b/mysql-test/include/column_compression_syntax_varbinary.inc index b609969fc14..e2f96c33d06 100644 --- a/mysql-test/include/column_compression_syntax_varbinary.inc +++ b/mysql-test/include/column_compression_syntax_varbinary.inc @@ -28,6 +28,8 @@ DROP TABLE t1; --echo # The following statements return deprecated syntax warnings --echo # +--enable_prepare_warnings + --eval CREATE TABLE t1 (a $type DEFAULT '' COMPRESSED) SHOW CREATE TABLE t1; DROP TABLE t1; @@ -35,6 +37,7 @@ DROP TABLE t1; SHOW CREATE TABLE t1; DROP TABLE t1; +--disable_prepare_warnings --echo # --echo # The following statements fail by the grammar, diff --git a/mysql-test/include/column_compression_syntax_varchar.inc b/mysql-test/include/column_compression_syntax_varchar.inc index 6b96440c511..41ace4fe5f6 100644 --- a/mysql-test/include/column_compression_syntax_varchar.inc +++ b/mysql-test/include/column_compression_syntax_varchar.inc @@ -53,6 +53,8 @@ DROP TABLE t1; --echo # The following statements return deprecated syntax warnings --echo # +--enable_prepare_warnings + --eval CREATE TABLE t1 (a $type BINARY COMPRESSED) SHOW CREATE TABLE t1; DROP TABLE t1; @@ -63,6 +65,7 @@ DROP TABLE t1; SHOW CREATE TABLE t1; DROP TABLE t1; +--disable_prepare_warnings --echo # --echo # The following statements fail by the grammar, diff --git a/mysql-test/suite/compat/oracle/t/sp-package-innodb.test b/mysql-test/suite/compat/oracle/t/sp-package-innodb.test index f4cd05b7112..94c7b714fb7 100644 --- a/mysql-test/suite/compat/oracle/t/sp-package-innodb.test +++ b/mysql-test/suite/compat/oracle/t/sp-package-innodb.test @@ -9,6 +9,8 @@ SELECT ENGINE FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1'; INSERT INTO t1 VALUES (10,'none'); +--enable_prepare_warnings + DELIMITER $$; CREATE PACKAGE pkg1 AS PROCEDURE p1; @@ -58,5 +60,7 @@ ROLLBACK; SELECT * FROM t1 ORDER BY a; DELETE FROM t1; +--disable_prepare_warnings + DROP PACKAGE pkg1; DROP TABLE t1; diff --git a/mysql-test/suite/compat/oracle/t/update_innodb.test b/mysql-test/suite/compat/oracle/t/update_innodb.test index 8af219584d6..79660920901 100644 --- a/mysql-test/suite/compat/oracle/t/update_innodb.test +++ b/mysql-test/suite/compat/oracle/t/update_innodb.test @@ -8,6 +8,7 @@ SET sql_mode='ORACLE'; CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY) engine=innodb; INSERT INTO t1 VALUES (1); START TRANSACTION; +--enable_prepare_warnings SELECT a AS a_con1 FROM t1 INTO @a FOR UPDATE; --connect(con2,localhost,root,,) @@ -24,5 +25,7 @@ COMMIT; SELECT a AS con2 FROM t1; COMMIT; +--disable_prepare_warnings + --connection default DROP TABLE t1; diff --git a/mysql-test/suite/engines/funcs/r/rpl_sp.result b/mysql-test/suite/engines/funcs/r/rpl_sp.result index 004608691ce..71177d6a2f5 100644 --- a/mysql-test/suite/engines/funcs/r/rpl_sp.result +++ b/mysql-test/suite/engines/funcs/r/rpl_sp.result @@ -189,7 +189,7 @@ select * from t2; a 23 connection master; -drop function fn1; +drop function fn1| create function fn1() returns int no sql diff --git a/mysql-test/suite/funcs_1/include/innodb_tb2.inc b/mysql-test/suite/funcs_1/include/innodb_tb2.inc index 4e5ee091c74..1a5896cb003 100644 --- a/mysql-test/suite/funcs_1/include/innodb_tb2.inc +++ b/mysql-test/suite/funcs_1/include/innodb_tb2.inc @@ -3,6 +3,7 @@ --disable_warnings drop table if exists tb2 ; --enable_warnings +--enable_prepare_warnings create table tb2 ( f59 numeric (0) unsigned, f60 numeric (64) unsigned, @@ -61,3 +62,4 @@ f109 set("1set","2set") not null default "1set" eval load data infile '$MYSQLTEST_VARDIR/std_data/funcs_1/innodb_tb2.txt' into table tb2; +--disable_prepare_warnings diff --git a/mysql-test/suite/funcs_1/include/innodb_tb4.inc b/mysql-test/suite/funcs_1/include/innodb_tb4.inc index b3e94fce80e..95a0b8afb86 100644 --- a/mysql-test/suite/funcs_1/include/innodb_tb4.inc +++ b/mysql-test/suite/funcs_1/include/innodb_tb4.inc @@ -3,6 +3,7 @@ --disable_warnings drop table if exists tb4; --enable_warnings +--enable_prepare_warnings create table tb4 ( f176 numeric (0) unsigned not null DEFAULT 9, f177 numeric (64) unsigned not null DEFAULT 9, @@ -68,3 +69,4 @@ f241 char(100) eval load data infile '$MYSQLTEST_VARDIR/std_data/funcs_1/innodb_tb4.txt' into table tb4; +--disable_prepare_warnings diff --git a/mysql-test/suite/funcs_1/include/memory_tb2.inc b/mysql-test/suite/funcs_1/include/memory_tb2.inc index 272b86b9f03..b9e6bd72e95 100644 --- a/mysql-test/suite/funcs_1/include/memory_tb2.inc +++ b/mysql-test/suite/funcs_1/include/memory_tb2.inc @@ -3,6 +3,9 @@ --disable_warnings drop table if exists tb2 ; --enable_warnings + +--enable_prepare_warnings + create table tb2 ( f59 numeric (0) unsigned, f60 numeric (64) unsigned, @@ -61,3 +64,5 @@ f109 set("1set","2set") not null default "1set" eval load data infile '$MYSQLTEST_VARDIR/std_data/funcs_1/memory_tb2.txt' into table tb2 ; + +--disable_prepare_warnings diff --git a/mysql-test/suite/funcs_1/include/memory_tb4.inc b/mysql-test/suite/funcs_1/include/memory_tb4.inc index 3a4fc861f28..786e2772b44 100644 --- a/mysql-test/suite/funcs_1/include/memory_tb4.inc +++ b/mysql-test/suite/funcs_1/include/memory_tb4.inc @@ -3,6 +3,7 @@ --disable_warnings drop table if exists tb4 ; --enable_warnings +--enable_prepare_warnings create table tb4 ( f176 numeric (0) unsigned not null DEFAULT 9, f177 numeric (64) unsigned not null DEFAULT 9, @@ -67,3 +68,4 @@ f240 varchar(1200) eval load data infile '$MYSQLTEST_VARDIR/std_data/funcs_1/memory_tb4.txt' into table tb4; +--disable_prepare_warnings diff --git a/mysql-test/suite/handler/handler.inc b/mysql-test/suite/handler/handler.inc index f4c677adc90..c83e7e5d0b2 100644 --- a/mysql-test/suite/handler/handler.inc +++ b/mysql-test/suite/handler/handler.inc @@ -1293,6 +1293,7 @@ DROP TABLE IF EXISTS t1, t2; DROP FUNCTION IF EXISTS f1; --enable_warnings +--enable_prepare_warnings delimiter |; CREATE FUNCTION f1() RETURNS INTEGER BEGIN @@ -1300,6 +1301,7 @@ BEGIN RETURN 1; END| delimiter ;| +--disable_prepare_warnings # Get f1() parsed and cached --error ER_NO_SUCH_TABLE diff --git a/mysql-test/suite/innodb/t/data_types.test b/mysql-test/suite/innodb/t/data_types.test index cfdd5201af2..2856650dad1 100644 --- a/mysql-test/suite/innodb/t/data_types.test +++ b/mysql-test/suite/innodb/t/data_types.test @@ -11,6 +11,8 @@ --source include/have_innodb.inc +--enable_prepare_warnings + CREATE TABLE t1 ( t1_BIGINT BIGINT, @@ -95,6 +97,8 @@ CREATE TABLE t1 t1_VARMYSQL_0 VARCHAR(0) CHARACTER SET utf8 ) ENGINE=InnoDB; +--disable_prepare_warnings + INSERT INTO t1 () VALUES (); SELECT diff --git a/mysql-test/suite/innodb/t/innodb_bug30919.test b/mysql-test/suite/innodb/t/innodb_bug30919.test index 56b2c7bc03d..b80da1244fb 100644 --- a/mysql-test/suite/innodb/t/innodb_bug30919.test +++ b/mysql-test/suite/innodb/t/innodb_bug30919.test @@ -22,6 +22,8 @@ eval CREATE TABLE test.part_tbl(id MEDIUMINT NOT NULL AUTO_INCREMENT, ######## Create SPs, Functions, Views and Triggers Section ############## +--enable_prepare_warnings + delimiter |; CREATE PROCEDURE test.proc_part() @@ -52,6 +54,8 @@ END| delimiter ;| +--disable_prepare_warnings + ############ Finish Setup Section ################### ############ Test Section ################### diff --git a/mysql-test/suite/perfschema/t/alter_table_progress.test b/mysql-test/suite/perfschema/t/alter_table_progress.test index d0a4055ad0e..d4933ac9006 100644 --- a/mysql-test/suite/perfschema/t/alter_table_progress.test +++ b/mysql-test/suite/perfschema/t/alter_table_progress.test @@ -52,8 +52,10 @@ SET DEBUG_SYNC='copy_data_between_tables_before SIGNAL found_row WAIT_FOR wait_r SET DEBUG_SYNC='now WAIT_FOR found_row'; # Find the statement id of the ALTER TABLE +--enable_prepare_warnings select event_id from performance_schema.events_statements_current where thread_id = @con1_thread_id into @con1_stmt_id; +--disable_prepare_warnings # completed 0 select EVENT_NAME, WORK_COMPLETED, WORK_ESTIMATED diff --git a/mysql-test/suite/perfschema/t/dml_handler.test b/mysql-test/suite/perfschema/t/dml_handler.test index 16810fcba82..d289d89ce50 100644 --- a/mysql-test/suite/perfschema/t/dml_handler.test +++ b/mysql-test/suite/perfschema/t/dml_handler.test @@ -21,6 +21,8 @@ CREATE TEMPORARY TABLE table_list (id INT AUTO_INCREMENT, PRIMARY KEY (id)) AS WHERE TABLE_SCHEMA='performance_schema' ORDER BY TABLE_NAME; +--enable_prepare_warnings + SELECT COUNT(*) FROM table_list INTO @table_count; let $count=`SELECT @table_count`; @@ -39,5 +41,6 @@ while ($count > 0) dec $count; } -DROP TEMPORARY TABLE table_list; +--disable_prepare_warnings +DROP TEMPORARY TABLE table_list; diff --git a/mysql-test/suite/perfschema/t/selects.test b/mysql-test/suite/perfschema/t/selects.test index d2d447bd77e..c67cb4b286c 100644 --- a/mysql-test/suite/perfschema/t/selects.test +++ b/mysql-test/suite/perfschema/t/selects.test @@ -126,6 +126,7 @@ DROP TRIGGER t_ps_trigger; --disable_warnings DROP PROCEDURE IF EXISTS t_ps_proc; --enable_warnings +--enable_prepare_warnings delimiter |; CREATE PROCEDURE t_ps_proc(IN conid INT, OUT pid INT) @@ -140,6 +141,7 @@ delimiter ;| CALL t_ps_proc(connection_id(), @p_id); +--disable_prepare_warnings # FUNCTION --disable_warnings diff --git a/mysql-test/suite/rpl/r/rpl_sp.result b/mysql-test/suite/rpl/r/rpl_sp.result index 2fc2f5ba236..dad89db8135 100644 --- a/mysql-test/suite/rpl/r/rpl_sp.result +++ b/mysql-test/suite/rpl/r/rpl_sp.result @@ -188,7 +188,7 @@ select * from t2; a 23 connection master; -drop function fn1; +drop function fn1| create function fn1() returns int no sql diff --git a/mysql-test/suite/rpl/t/rpl_bug31076.test b/mysql-test/suite/rpl/t/rpl_bug31076.test index 4e9517fbf2a..5ef2b345eab 100644 --- a/mysql-test/suite/rpl/t/rpl_bug31076.test +++ b/mysql-test/suite/rpl/t/rpl_bug31076.test @@ -1,3 +1,8 @@ +if (`SELECT $PS_PROTOCOL != 0`) +{ + --skip Need regular protocol but ps-protocol was specified +} + source include/have_binlog_format_mixed_or_row.inc; source include/master-slave.inc; diff --git a/mysql-test/suite/rpl/t/rpl_drop_db.test b/mysql-test/suite/rpl/t/rpl_drop_db.test index 372afaa63c6..f67f422c36f 100644 --- a/mysql-test/suite/rpl/t/rpl_drop_db.test +++ b/mysql-test/suite/rpl/t/rpl_drop_db.test @@ -10,7 +10,9 @@ drop database if exists mysqltest1; create database mysqltest1; create table mysqltest1.t1 (n int); insert into mysqltest1.t1 values (1); +--enable_prepare_warnings select * from mysqltest1.t1 into outfile 'mysqltest1/f1.txt'; +--disable_prepare_warnings create table mysqltest1.t2 (n int); create table mysqltest1.t3 (n int); --replace_result \\ / 66 39 93 39 17 39 247 39 41 39 "File exists" "Directory not empty" diff --git a/mysql-test/suite/rpl/t/rpl_events.test b/mysql-test/suite/rpl/t/rpl_events.test index 3e73fc7a3ee..1d66c327633 100644 --- a/mysql-test/suite/rpl/t/rpl_events.test +++ b/mysql-test/suite/rpl/t/rpl_events.test @@ -4,6 +4,11 @@ # Purpose: To test that event effects are replicated. # ################################################################## +if (`SELECT $PS_PROTOCOL != 0`) +{ + --skip Need regular protocol but ps-protocol was specified +} + --source include/master-slave.inc SET @old_event_scheduler = @@global.event_scheduler; diff --git a/mysql-test/suite/rpl/t/rpl_heartbeat.test b/mysql-test/suite/rpl/t/rpl_heartbeat.test index 77c05a60c0a..e4753b7be07 100644 --- a/mysql-test/suite/rpl/t/rpl_heartbeat.test +++ b/mysql-test/suite/rpl/t/rpl_heartbeat.test @@ -21,6 +21,7 @@ set @restore_slave_net_timeout= @@global.slave_net_timeout; set @@global.slave_net_timeout= 10; --enable_warnings +--enable_prepare_warnings ### ### Checking the range ### @@ -167,6 +168,8 @@ drop table t1; sync_slave_with_master; set @@global.slave_net_timeout= @restore_slave_net_timeout; +--disable_prepare_warnings + --source include/stop_slave.inc --echo End of tests diff --git a/mysql-test/suite/rpl/t/rpl_heartbeat_basic.test b/mysql-test/suite/rpl/t/rpl_heartbeat_basic.test index f12c5921ba2..45b5d48c13b 100644 --- a/mysql-test/suite/rpl/t/rpl_heartbeat_basic.test +++ b/mysql-test/suite/rpl/t/rpl_heartbeat_basic.test @@ -18,6 +18,8 @@ --source include/have_binlog_format_mixed.inc --echo +--enable_prepare_warnings + # Set number of retries to connect to master let $connect_retry= 20; @@ -561,5 +563,7 @@ DROP TABLE t1; --sync_slave_with_master SET @@global.slave_net_timeout=@restore_slave_net_timeout; +--disable_prepare_warnings + #--let $rpl_only_running_threads= 1 --source include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_innodb_bug30888.test b/mysql-test/suite/rpl/t/rpl_innodb_bug30888.test index 9bfce61804b..a18b09981ef 100644 --- a/mysql-test/suite/rpl/t/rpl_innodb_bug30888.test +++ b/mysql-test/suite/rpl/t/rpl_innodb_bug30888.test @@ -19,6 +19,7 @@ eval CREATE TABLE test.regular_tbl(id MEDIUMINT NOT NULL AUTO_INCREMENT, ######## Create SPs, Functions, Views and Triggers Section ############## +--enable_prepare_warnings delimiter |; CREATE PROCEDURE test.proc_norm() BEGIN @@ -46,7 +47,7 @@ BEGIN END| delimiter ;| - +--disable_prepare_warnings ############ Finish Setup Section ################### diff --git a/mysql-test/suite/rpl/t/rpl_mdev12179.test b/mysql-test/suite/rpl/t/rpl_mdev12179.test index e3caccde6b4..2afcbf7b1e1 100644 --- a/mysql-test/suite/rpl/t/rpl_mdev12179.test +++ b/mysql-test/suite/rpl/t/rpl_mdev12179.test @@ -285,8 +285,10 @@ EOF --connection server_2 --enable_reconnect +--enable_prepare_warnings --source include/wait_until_connected_again.inc SELECT max(seq_no) FROM mysql.gtid_slave_pos_InnoDB into @seq_no; +--disable_prepare_warnings --connection server_1 INSERT INTO t2(a) SELECT 1+MAX(a) FROM t2; diff --git a/mysql-test/suite/rpl/t/rpl_misc_functions.test b/mysql-test/suite/rpl/t/rpl_misc_functions.test index 7189e5c44ba..4b140c9588a 100644 --- a/mysql-test/suite/rpl/t/rpl_misc_functions.test +++ b/mysql-test/suite/rpl/t/rpl_misc_functions.test @@ -89,8 +89,10 @@ INSERT INTO t1 (col_a) VALUES (test_replication_sf()); --sync_slave_with_master +--enable_prepare_warnings # Dump table on slave select * from t1 into outfile "../../tmp/t1_slave.txt"; +--disable_prepare_warnings # Load data from slave into temp table on master connection master; diff --git a/mysql-test/suite/rpl/t/rpl_sp.test b/mysql-test/suite/rpl/t/rpl_sp.test index 637dda47489..c68c76caf41 100644 --- a/mysql-test/suite/rpl/t/rpl_sp.test +++ b/mysql-test/suite/rpl/t/rpl_sp.test @@ -208,7 +208,7 @@ select * from t2; connection master; delimiter |; -drop function fn1; +drop function fn1| create function fn1() returns int diff --git a/mysql-test/suite/sys_vars/t/innodb_fil_make_page_dirty_debug_basic.test b/mysql-test/suite/sys_vars/t/innodb_fil_make_page_dirty_debug_basic.test index 950dbabd1bd..396d30c76c8 100644 --- a/mysql-test/suite/sys_vars/t/innodb_fil_make_page_dirty_debug_basic.test +++ b/mysql-test/suite/sys_vars/t/innodb_fil_make_page_dirty_debug_basic.test @@ -23,8 +23,10 @@ set innodb_fil_make_page_dirty_debug = ON; --echo # An example usage. create table t1 (f1 int primary key) engine = innodb; +--enable_prepare_warnings select space from information_schema.innodb_sys_tables where name = 'test/t1' into @space_id; +--disable_prepare_warnings set global innodb_saved_page_number_debug = 0; set global innodb_fil_make_page_dirty_debug = @space_id; drop table t1; diff --git a/mysql-test/suite/sys_vars/t/innodb_saved_page_number_debug_basic.test b/mysql-test/suite/sys_vars/t/innodb_saved_page_number_debug_basic.test index 74ce3ffc049..d0996ae9a24 100644 --- a/mysql-test/suite/sys_vars/t/innodb_saved_page_number_debug_basic.test +++ b/mysql-test/suite/sys_vars/t/innodb_saved_page_number_debug_basic.test @@ -23,8 +23,10 @@ set innodb_saved_page_number_debug = ON; --echo # An example usage. create table t1 (f1 int primary key) engine = innodb; +--enable_prepare_warnings select space from information_schema.innodb_sys_tables where name = 'test/t1' into @space_id; +--disable_prepare_warnings set global innodb_saved_page_number_debug = 0; set global innodb_fil_make_page_dirty_debug = @space_id; drop table t1; diff --git a/mysql-test/suite/sys_vars/t/secure_file_priv.test b/mysql-test/suite/sys_vars/t/secure_file_priv.test index a5a465d8c98..a8565375e45 100644 --- a/mysql-test/suite/sys_vars/t/secure_file_priv.test +++ b/mysql-test/suite/sys_vars/t/secure_file_priv.test @@ -33,7 +33,9 @@ print FILE "SELECT load_file('",$protected_file,"') AS loaded_file;\n"; close(FILE); EOF +--enable_prepare_warnings --source $MYSQL_TMP_DIR/bug50373.inc +--disable_prepare_warnings --remove_file $MYSQL_TMP_DIR/bug50373.inc --enable_query_log diff --git a/mysql-test/suite/versioning/t/alter.test b/mysql-test/suite/versioning/t/alter.test index 9d3101fb4ad..53f0537ff92 100644 --- a/mysql-test/suite/versioning/t/alter.test +++ b/mysql-test/suite/versioning/t/alter.test @@ -139,7 +139,9 @@ select * from t; update t set a=3 where a=1; select * from t; select * from t for system_time all; +--enable_prepare_warnings select row_start from t where a=3 into @tm; +--disable_prepare_warnings alter table t add column b int; select @tm=row_start from t where a=3; show create table t; diff --git a/mysql-test/suite/versioning/t/commit_id.test b/mysql-test/suite/versioning/t/commit_id.test index 0f9cf1eb391..96461f5c299 100644 --- a/mysql-test/suite/versioning/t/commit_id.test +++ b/mysql-test/suite/versioning/t/commit_id.test @@ -17,6 +17,9 @@ insert into t1 values (); --real_sleep 0.01 set @ts0= now(6); insert into t1 values (); + +--enable_prepare_warnings + select sys_trx_start from t1 where id = last_insert_id() into @tx0; select transaction_id = @tx0 from mysql.transaction_registry order by transaction_id desc limit 1; @@ -87,6 +90,7 @@ insert into t1 values (); select sys_trx_start from t1 where id = last_insert_id() into @tx6; select isolation_level = 'REPEATABLE-READ' from mysql.transaction_registry where transaction_id = @tx6; +--disable_prepare_warnings drop table t1; call verify_trt; diff --git a/mysql-test/suite/versioning/t/create.test b/mysql-test/suite/versioning/t/create.test index 1f016fed871..62f09b255f2 100644 --- a/mysql-test/suite/versioning/t/create.test +++ b/mysql-test/suite/versioning/t/create.test @@ -5,6 +5,8 @@ drop table if exists t1; --enable_warnings +--enable_prepare_warnings + --replace_result $default_engine DEFAULT_ENGINE $sys_datatype_expl SYS_DATATYPE NULL '' eval create table t1 ( x1 int unsigned, @@ -439,3 +441,4 @@ show create table t1; show create table t2; drop temporary table t2; drop table t1; +--disable_prepare_warnings diff --git a/mysql-test/suite/versioning/t/foreign.test b/mysql-test/suite/versioning/t/foreign.test index ed2ed4dd122..138698b6306 100644 --- a/mysql-test/suite/versioning/t/foreign.test +++ b/mysql-test/suite/versioning/t/foreign.test @@ -314,7 +314,9 @@ create or replace table subchild ( ) engine=innodb; insert into parent (value) values (23); +--enable_prepare_warnings select id, value from parent into @id, @value; +--disable_prepare_warnings insert into child values (default, @id, @value); insert into subchild values (default, @id, @value); diff --git a/mysql-test/suite/versioning/t/insert.test b/mysql-test/suite/versioning/t/insert.test index 0324df64d0c..4e8c91315c6 100644 --- a/mysql-test/suite/versioning/t/insert.test +++ b/mysql-test/suite/versioning/t/insert.test @@ -52,7 +52,9 @@ drop view vt1_1; replace_result $sys_datatype_expl SYS_DATATYPE; eval create or replace table t1( id bigint primary key, a int, b int) with system versioning; insert into t1 values(1, 1, 1); +--enable_prepare_warnings select row_start, row_end from t1 into @sys_start, @sys_end; +--disable_prepare_warnings select id, a, b from t1; insert into t1 values(2, 2, 2); select id, a, b, row_start > @sys_start as C, row_end = @sys_end as D from t1 where id = 2; diff --git a/mysql-test/suite/versioning/t/partition.test b/mysql-test/suite/versioning/t/partition.test index 445f5844630..006a65e1a16 100644 --- a/mysql-test/suite/versioning/t/partition.test +++ b/mysql-test/suite/versioning/t/partition.test @@ -4,6 +4,8 @@ call mtr.add_suppression("need more HISTORY partitions"); +--enable_prepare_warnings + set system_versioning_alter_history=keep; --echo # Check conventional partitioning on temporal tables @@ -1073,6 +1075,8 @@ show create table t1; drop tables t1; +--disable_prepare_warnings + --echo # --echo # End of 10.5 tests --echo # diff --git a/mysql-test/suite/versioning/t/select.test b/mysql-test/suite/versioning/t/select.test index d2615940ac8..bf27723adee 100644 --- a/mysql-test/suite/versioning/t/select.test +++ b/mysql-test/suite/versioning/t/select.test @@ -1,7 +1,12 @@ +if (`SELECT $PS_PROTOCOL != 0`) +{ + --skip Need regular protocol but ps-protocol was specified +} --source suite/versioning/engines.inc --source suite/versioning/common.inc --source include/default_optimizer_switch.inc +--enable_prepare_warnings # test_01 --replace_result $sys_datatype_expl SYS_DATATYPE @@ -475,5 +480,6 @@ drop table tmp1; drop tables x, x_p; call verify_trt_dummy(34); +--disable_prepare_warnings -- source suite/versioning/common_finish.inc diff --git a/mysql-test/suite/versioning/t/select2.test b/mysql-test/suite/versioning/t/select2.test index 1ab7bcf27c1..53840b390b6 100644 --- a/mysql-test/suite/versioning/t/select2.test +++ b/mysql-test/suite/versioning/t/select2.test @@ -22,13 +22,16 @@ insert into t1 (x, y) values (8, 108), (9, 109); set @t0= now(6); +--enable_prepare_warnings select sys_start from t1 limit 1 into @x0; - +--disable_prepare_warnings delete from t1 where x = 3; delete from t1 where x > 7; insert into t1(x, y) values(3, 33); +--enable_prepare_warnings select sys_start from t1 where x = 3 and y = 33 into @t1; +--disable_prepare_warnings if($MTR_COMBINATION_TRX_ID) { set @x1= @t1; select trt_commit_ts(@x1) into @t1; diff --git a/mysql-test/suite/versioning/t/trx_id.test b/mysql-test/suite/versioning/t/trx_id.test index 23c65b2525c..4728ce9b2d0 100644 --- a/mysql-test/suite/versioning/t/trx_id.test +++ b/mysql-test/suite/versioning/t/trx_id.test @@ -18,6 +18,8 @@ create or replace table t1 ( period for system_time (sys_trx_start, sys_trx_end) ) with system versioning; +--enable_prepare_warnings + --echo # No history inside the transaction start transaction; insert into t1 (x) values (1); @@ -511,3 +513,5 @@ drop table t; uninstall plugin test_versioning; --error ER_SP_DOES_NOT_EXIST select trt_begin_ts(0); + +--disable_prepare_warnings From 510662e81bf4d294bf012897bc1e6122c9ca5e07 Mon Sep 17 00:00:00 2001 From: Dmitry Shulga Date: Wed, 16 Jun 2021 13:18:29 +0200 Subject: [PATCH 123/251] MDEV-16708: more fixes to test cases --- mysql-test/main/cte_recursive.test | 4 ++++ mysql-test/main/events_restart.test | 3 ++- mysql-test/main/features.test | 4 ++++ mysql-test/main/fetch_first.test | 4 ++++ mysql-test/main/func_group.test | 5 +++++ mysql-test/main/limit_rows_examined.test | 5 +++++ mysql-test/main/opt_trace.test | 4 ++++ mysql-test/main/parser.test | 4 ++++ mysql-test/main/parser_stack.test | 4 ++++ mysql-test/main/skip_grants.result | 2 -- mysql-test/main/skip_grants.test | 6 +++++- mysql-test/main/sp-row.test | 5 ++++- mysql-test/suite/compat/oracle/t/sp-row.test | 5 +++++ mysql-test/suite/plugins/t/test_sql_service.test | 4 ++++ mysql-test/suite/rpl/t/rpl_gtid_stop_start.test | 4 ++++ mysql-test/suite/sys_vars/t/stored_program_cache_func.test | 4 ++++ mysql-test/suite/versioning/t/cte.test | 4 ++++ 17 files changed, 66 insertions(+), 5 deletions(-) diff --git a/mysql-test/main/cte_recursive.test b/mysql-test/main/cte_recursive.test index 125e22ebfa6..e258d3c3397 100644 --- a/mysql-test/main/cte_recursive.test +++ b/mysql-test/main/cte_recursive.test @@ -1,3 +1,7 @@ +if (`SELECT $PS_PROTOCOL != 0`) +{ + --skip Test temporarily disabled for ps-protocol +} --source include/default_optimizer_switch.inc create table t1 (a int, b varchar(32)); diff --git a/mysql-test/main/events_restart.test b/mysql-test/main/events_restart.test index f56bd32b71d..b96a3954e33 100644 --- a/mysql-test/main/events_restart.test +++ b/mysql-test/main/events_restart.test @@ -1,6 +1,6 @@ # Can't test with embedded server that doesn't support grants -- source include/not_embedded.inc - +--disable_ps_protocol call mtr.add_suppression("Column count of mysql.event is wrong. Expected .*, found .*\. The table is probably corrupted"); let $collation_server=`select @@collation_server`; @@ -172,3 +172,4 @@ select name, originator, status from mysql.event; # Cleanup drop event ev; +--enable_ps_protocol diff --git a/mysql-test/main/features.test b/mysql-test/main/features.test index d0f5263c5c3..0dd0be20c9e 100644 --- a/mysql-test/main/features.test +++ b/mysql-test/main/features.test @@ -1,4 +1,8 @@ # Testing of feature statistics +if (`SELECT $PS_PROTOCOL != 0`) +{ + --skip Test temporarily disabled for ps-protocol +} -- source include/have_geometry.inc diff --git a/mysql-test/main/fetch_first.test b/mysql-test/main/fetch_first.test index 76c0a8b8b39..3fdd6c56968 100644 --- a/mysql-test/main/fetch_first.test +++ b/mysql-test/main/fetch_first.test @@ -1,3 +1,7 @@ +if (`SELECT $PS_PROTOCOL != 0`) +{ + --skip Test temporarily disabled for ps-protocol +} --echo # --echo # The following entries are meant for testing the parser, ensuring --echo # the right values are passed down to the executor, for all possible diff --git a/mysql-test/main/func_group.test b/mysql-test/main/func_group.test index 71129352aae..949d40dda1a 100644 --- a/mysql-test/main/func_group.test +++ b/mysql-test/main/func_group.test @@ -2,6 +2,11 @@ # simple test of all group functions # +if (`SELECT $PS_PROTOCOL != 0`) +{ + --skip Test temporarily disabled for ps-protocol +} + --disable_warnings drop table if exists t1,t2,t3,t4,t5,t6; --enable_warnings diff --git a/mysql-test/main/limit_rows_examined.test b/mysql-test/main/limit_rows_examined.test index 2315580410f..8dc595ab594 100644 --- a/mysql-test/main/limit_rows_examined.test +++ b/mysql-test/main/limit_rows_examined.test @@ -2,6 +2,11 @@ # Tests for LIMIT ROWS EXAMINED, MDEV-28 # +if (`SELECT $PS_PROTOCOL != 0`) +{ + --skip Test temporarily disabled for ps-protocol +} + --source include/default_optimizer_switch.inc call mtr.add_suppression("Sort aborted.*"); diff --git a/mysql-test/main/opt_trace.test b/mysql-test/main/opt_trace.test index 8a9a618635b..35a1f99236f 100644 --- a/mysql-test/main/opt_trace.test +++ b/mysql-test/main/opt_trace.test @@ -1,3 +1,7 @@ +if (`SELECT $PS_PROTOCOL != 0`) +{ + --skip Test temporarily disabled for ps-protocol +} --source include/not_embedded.inc --source include/have_sequence.inc SELECT table_name, column_name FROM information_schema.columns where table_name="OPTIMIZER_TRACE"; diff --git a/mysql-test/main/parser.test b/mysql-test/main/parser.test index c202a8ac878..61cea2e7fa4 100644 --- a/mysql-test/main/parser.test +++ b/mysql-test/main/parser.test @@ -1906,6 +1906,8 @@ drop table t1; --echo # MDEV-19682 sql_mode="oracle" does not support sysdate --echo # +--enable_prepare_warnings + --error ER_BAD_FIELD_ERROR SELECT sysdate LIKE '____-__-__ __:__:__'; --error ER_BAD_FIELD_ERROR @@ -1951,6 +1953,8 @@ END; $$ DELIMITER ;$$ +--disable_prepare_warnings + --echo # --echo # End of 10.6 tests --echo # diff --git a/mysql-test/main/parser_stack.test b/mysql-test/main/parser_stack.test index 8bc316da18e..5d53ff98902 100644 --- a/mysql-test/main/parser_stack.test +++ b/mysql-test/main/parser_stack.test @@ -1,3 +1,7 @@ +if (`SELECT $PS_PROTOCOL != 0`) +{ + --skip Test temporarily disabled for ps-protocol +} # # These tests are designed to cause an internal parser stack overflow, # and trigger my_yyoverflow(). diff --git a/mysql-test/main/skip_grants.result b/mysql-test/main/skip_grants.result index a8633807571..f21bfa1da41 100644 --- a/mysql-test/main/skip_grants.result +++ b/mysql-test/main/skip_grants.result @@ -52,8 +52,6 @@ DROP FUNCTION f3; # Bug #26807 "set global event_scheduler=1" and --skip-grant-tables crashes server # set global event_scheduler=1; -Warnings: -Note 1408 Event Scheduler: Loaded 0 events set global event_scheduler=0; # # Bug#26285 Selecting information_schema crahes server diff --git a/mysql-test/main/skip_grants.test b/mysql-test/main/skip_grants.test index eb8d3c3df88..7594285aed7 100644 --- a/mysql-test/main/skip_grants.test +++ b/mysql-test/main/skip_grants.test @@ -1,6 +1,6 @@ # This tests not performed with embedded server -- source include/not_embedded.inc - +-- disable_ps_protocol use test; # @@ -92,7 +92,9 @@ DROP FUNCTION f3; --echo # --echo # Bug #26807 "set global event_scheduler=1" and --skip-grant-tables crashes server --echo # +--disable_warnings set global event_scheduler=1; +--enable_warnings set global event_scheduler=0; --echo # @@ -161,6 +163,8 @@ drop user baz@baz; # need to restart the server to restore the --skip-grant state --source include/restart_mysqld.inc +--enable_ps_protocol + --echo # --echo # End of 10.3 tests --echo # diff --git a/mysql-test/main/sp-row.test b/mysql-test/main/sp-row.test index b9143b1113b..cbd1e940475 100644 --- a/mysql-test/main/sp-row.test +++ b/mysql-test/main/sp-row.test @@ -2,7 +2,10 @@ --echo # MDEV-10914 ROW data type for stored routine variables --echo # - +if (`SELECT $PS_PROTOCOL != 0`) +{ + --skip Test temporarily disabled for ps-protocol +} --echo # --echo # ROW of ROWs is not supported yet diff --git a/mysql-test/suite/compat/oracle/t/sp-row.test b/mysql-test/suite/compat/oracle/t/sp-row.test index 8abf317708a..e2725e3a769 100644 --- a/mysql-test/suite/compat/oracle/t/sp-row.test +++ b/mysql-test/suite/compat/oracle/t/sp-row.test @@ -1,3 +1,8 @@ +if (`SELECT $PS_PROTOCOL != 0`) +{ + --skip Test temporarily disabled for ps-protocol +} + SET sql_mode=ORACLE; diff --git a/mysql-test/suite/plugins/t/test_sql_service.test b/mysql-test/suite/plugins/t/test_sql_service.test index 3384b523bda..2ff2db2fce0 100644 --- a/mysql-test/suite/plugins/t/test_sql_service.test +++ b/mysql-test/suite/plugins/t/test_sql_service.test @@ -1,3 +1,7 @@ +if (`SELECT $PS_PROTOCOL != 0`) +{ + --skip Test temporarily disabled for ps-protocol +} --source include/not_embedded.inc diff --git a/mysql-test/suite/rpl/t/rpl_gtid_stop_start.test b/mysql-test/suite/rpl/t/rpl_gtid_stop_start.test index fd4cdf71f6f..4a192230859 100644 --- a/mysql-test/suite/rpl/t/rpl_gtid_stop_start.test +++ b/mysql-test/suite/rpl/t/rpl_gtid_stop_start.test @@ -1,3 +1,7 @@ +if (`SELECT $PS_PROTOCOL != 0`) +{ + --skip Test temporarily disabled for ps-protocol +} --let $rpl_topology=1->2 --source include/rpl_init.inc --source include/have_innodb.inc diff --git a/mysql-test/suite/sys_vars/t/stored_program_cache_func.test b/mysql-test/suite/sys_vars/t/stored_program_cache_func.test index f85fc8eb1bf..86cdd56a6de 100644 --- a/mysql-test/suite/sys_vars/t/stored_program_cache_func.test +++ b/mysql-test/suite/sys_vars/t/stored_program_cache_func.test @@ -1,3 +1,7 @@ +if (`SELECT $PS_PROTOCOL != 0`) +{ + --skip Test temporarily disabled for ps-protocol +} create procedure p1() select 1; flush status; diff --git a/mysql-test/suite/versioning/t/cte.test b/mysql-test/suite/versioning/t/cte.test index 5a8fb1f8211..5f2a709eebe 100644 --- a/mysql-test/suite/versioning/t/cte.test +++ b/mysql-test/suite/versioning/t/cte.test @@ -1,3 +1,7 @@ +if (`SELECT $PS_PROTOCOL != 0`) +{ + --skip Test temporarily disabled for ps-protocol +} --source include/have_innodb.inc --source include/default_optimizer_switch.inc From aedf3143339b588bc54eaa1c4f2708b9ba0f8e62 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 16 Jun 2021 14:49:19 +0200 Subject: [PATCH 124/251] MDEV-16708: spurious ER_NEED_REPREPARE for gtid_slave_pos and event_scheduler do not try to detect metadata change (and reprepare) for internal short-lived TABLE_LIST objects that couldn't have possibly lived long enough to see prepare and cache the metadata. --- mysql-test/main/events_restart.test | 2 -- sql/sql_base.cc | 8 +++++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/mysql-test/main/events_restart.test b/mysql-test/main/events_restart.test index b96a3954e33..624c4188f9a 100644 --- a/mysql-test/main/events_restart.test +++ b/mysql-test/main/events_restart.test @@ -1,6 +1,5 @@ # Can't test with embedded server that doesn't support grants -- source include/not_embedded.inc ---disable_ps_protocol call mtr.add_suppression("Column count of mysql.event is wrong. Expected .*, found .*\. The table is probably corrupted"); let $collation_server=`select @@collation_server`; @@ -172,4 +171,3 @@ select name, originator, status from mysql.event; # Cleanup drop event ev; ---enable_ps_protocol diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 0d3c476c0e5..51e4bcad16b 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -2815,7 +2815,13 @@ static bool check_and_update_table_version(THD *thd, TABLE_LIST *tables, TABLE_SHARE *table_share) { - if (! tables->is_table_ref_id_equal(table_share)) + /* + First, verify that TABLE_LIST was indeed *created by the parser* - + it must be in the global TABLE_LIST list. Standalone TABLE_LIST objects + created with TABLE_LIST::init_one_table() have a short life time and + aren't linked anywhere. + */ + if (tables->prev_global && !tables->is_table_ref_id_equal(table_share)) { if (thd->m_reprepare_observer && thd->m_reprepare_observer->report_error(thd)) From 12bcbfc9780e6c78993fd97818fc87516a4da6a1 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 16 Jun 2021 16:18:15 +0200 Subject: [PATCH 125/251] MDEV-16708: extract nonembedded part of the test into a separate file --- mysql-test/main/ps_missed_cmds.result | 50 ----------- mysql-test/main/ps_missed_cmds.test | 60 ------------- .../main/ps_missed_cmds_bin_prot.result | 20 ----- mysql-test/main/ps_missed_cmds_bin_prot.test | 29 ------- ...s_missed_cmds_bin_prot_not_embedded.result | 21 +++++ .../ps_missed_cmds_bin_prot_not_embedded.test | 40 +++++++++ .../main/ps_missed_cmds_not_embedded.result | 61 +++++++++++++ .../main/ps_missed_cmds_not_embedded.test | 85 +++++++++++++++++++ .../funcs_1/t/is_columns_myisam_embedded.test | 1 + .../t/create_table_index_parser_comment.test | 1 + .../t/create_table_index_parser_off.test | 1 + .../t/create_table_parser_comment.test | 1 + 12 files changed, 211 insertions(+), 159 deletions(-) create mode 100644 mysql-test/main/ps_missed_cmds_bin_prot_not_embedded.result create mode 100644 mysql-test/main/ps_missed_cmds_bin_prot_not_embedded.test create mode 100644 mysql-test/main/ps_missed_cmds_not_embedded.result create mode 100644 mysql-test/main/ps_missed_cmds_not_embedded.test diff --git a/mysql-test/main/ps_missed_cmds.result b/mysql-test/main/ps_missed_cmds.result index e016226bb17..1d996141adf 100644 --- a/mysql-test/main/ps_missed_cmds.result +++ b/mysql-test/main/ps_missed_cmds.result @@ -712,44 +712,6 @@ ERROR HY000: The foreign server name you are trying to reference does not exist. DEALLOCATE PREPARE stmt_1; DEALLOCATE PREPARE stmt_2; DEALLOCATE PREPARE stmt_3; -# Test case 20: Check that the CREATE EVENT/ALTER EVENT/DROP EVENT -# statements can be executed as a prepared statement -PREPARE stmt_1 FROM "CREATE EVENT e1 ON SCHEDULE AT CURRENT_TIMESTAMP - INTERVAL 1 DAY ON COMPLETION PRESERVE DO SET @a=1"; -PREPARE stmt_2 FROM "ALTER EVENT e1 COMMENT 'New comment'"; -PREPARE stmt_3 FROM "DROP EVENT e1"; -# Create the event e1 that specifies time in past. Such event is created -# just for the sake of its existence and never will be triggered. -# Disable warnings temprorary in order to hide the following warnings -# generated in result of execution the 'CREATE EVENT' statement: -# "1544 | Event execution time is in the past. Event has been disabled" -# "1105 | Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it." -EXECUTE stmt_1; -# Execute the same prepared statement the second time to check that -# no internal structures used for handling the 'CREATE EVENT' statement -# were damaged. Execution of this statement the second time expectedly -# results in emitting the error ER_EVENT_ALREADY_EXISTS since the event -# with the same name has just been created. -EXECUTE stmt_1; -ERROR HY000: Event 'e1' already exists -# Alter event e1 -EXECUTE stmt_2; -# Execute the same prepared statement the second time to check that -# no internal structures used for handling the 'ALTER EVENT' statement -# were damaged. -EXECUTE stmt_2; -# Drop event e1 -EXECUTE stmt_3; -# Execute the same prepared statement the second time to check that -# no internal structures used for handling the 'DROP EVENT' statement -# were damaged. Execution of this statement the second time expectedly -# results in emitting the error ER_EVENT_DOESNT_EXIST since the event -# with the same name has just been dropped. -EXECUTE stmt_3; -ERROR HY000: Unknown event 'e1' -# Clean up -DEALLOCATE PREPARE stmt_1; -DEALLOCATE PREPARE stmt_2; -DEALLOCATE PREPARE stmt_3; # Test case 21: Check that the SIGNAL and RESIGNAL statements # can be executed as a prepared statement PREPARE stmt_1 FROM "SIGNAL SQLSTATE '45000' SET MYSQL_ERRNO=30001, MESSAGE_TEXT='Hello, world!'"; @@ -770,18 +732,6 @@ EXECUTE stmt_1; ERROR 0K000: RESIGNAL when handler not active # Clean up DEALLOCATE PREPARE stmt_1; -# Test case 22: Check that the 'SHOW RELAYLOG EVENTS' statement can be -# executed as a prepared statement. -PREPARE stmt_1 FROM 'SHOW RELAYLOG EVENTS'; -EXECUTE stmt_1; -Log_name Pos Event_type Server_id End_log_pos Info -# Execute the same prepared statement the second time to check that -# no internal structures used for handling the 'SHOW RELAYLOG EVENTS' -# statement were damaged. -EXECUTE stmt_1; -Log_name Pos Event_type Server_id End_log_pos Info -# Clean up -DEALLOCATE PREPARE stmt_1; # Test case 23: Check the 'GET DIAGNOSTICS' statement # can be executed as a prepared statement PREPARE stmt_1 FROM 'GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE, @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT'; diff --git a/mysql-test/main/ps_missed_cmds.test b/mysql-test/main/ps_missed_cmds.test index 3aa14d5cce1..1546b064d89 100644 --- a/mysql-test/main/ps_missed_cmds.test +++ b/mysql-test/main/ps_missed_cmds.test @@ -517,55 +517,6 @@ DEALLOCATE PREPARE stmt_1; DEALLOCATE PREPARE stmt_2; DEALLOCATE PREPARE stmt_3; ---echo # Test case 20: Check that the CREATE EVENT/ALTER EVENT/DROP EVENT ---echo # statements can be executed as a prepared statement - -PREPARE stmt_1 FROM "CREATE EVENT e1 ON SCHEDULE AT CURRENT_TIMESTAMP - INTERVAL 1 DAY ON COMPLETION PRESERVE DO SET @a=1"; - -PREPARE stmt_2 FROM "ALTER EVENT e1 COMMENT 'New comment'"; - -PREPARE stmt_3 FROM "DROP EVENT e1"; ---echo # Create the event e1 that specifies time in past. Such event is created ---echo # just for the sake of its existence and never will be triggered. ---echo # Disable warnings temprorary in order to hide the following warnings ---echo # generated in result of execution the 'CREATE EVENT' statement: ---echo # "1544 | Event execution time is in the past. Event has been disabled" ---echo # "1105 | Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it." - ---disable_warnings -EXECUTE stmt_1; - ---echo # Execute the same prepared statement the second time to check that ---echo # no internal structures used for handling the 'CREATE EVENT' statement ---echo # were damaged. Execution of this statement the second time expectedly ---echo # results in emitting the error ER_EVENT_ALREADY_EXISTS since the event ---echo # with the same name has just been created. ---error ER_EVENT_ALREADY_EXISTS -EXECUTE stmt_1; - ---enable_warnings - ---echo # Alter event e1 -EXECUTE stmt_2; ---echo # Execute the same prepared statement the second time to check that ---echo # no internal structures used for handling the 'ALTER EVENT' statement ---echo # were damaged. -EXECUTE stmt_2; - ---echo # Drop event e1 -EXECUTE stmt_3; ---echo # Execute the same prepared statement the second time to check that ---echo # no internal structures used for handling the 'DROP EVENT' statement ---echo # were damaged. Execution of this statement the second time expectedly ---echo # results in emitting the error ER_EVENT_DOESNT_EXIST since the event ---echo # with the same name has just been dropped. ---error ER_EVENT_DOES_NOT_EXIST -EXECUTE stmt_3; ---echo # Clean up -DEALLOCATE PREPARE stmt_1; -DEALLOCATE PREPARE stmt_2; -DEALLOCATE PREPARE stmt_3; - --echo # Test case 21: Check that the SIGNAL and RESIGNAL statements --echo # can be executed as a prepared statement PREPARE stmt_1 FROM "SIGNAL SQLSTATE '45000' SET MYSQL_ERRNO=30001, MESSAGE_TEXT='Hello, world!'"; @@ -589,17 +540,6 @@ EXECUTE stmt_1; --echo # Clean up DEALLOCATE PREPARE stmt_1; ---echo # Test case 22: Check that the 'SHOW RELAYLOG EVENTS' statement can be ---echo # executed as a prepared statement. -PREPARE stmt_1 FROM 'SHOW RELAYLOG EVENTS'; -EXECUTE stmt_1; ---echo # Execute the same prepared statement the second time to check that ---echo # no internal structures used for handling the 'SHOW RELAYLOG EVENTS' ---echo # statement were damaged. -EXECUTE stmt_1; ---echo # Clean up -DEALLOCATE PREPARE stmt_1; - --echo # Test case 23: Check the 'GET DIAGNOSTICS' statement --echo # can be executed as a prepared statement PREPARE stmt_1 FROM 'GET DIAGNOSTICS CONDITION 1 @sqlstate = RETURNED_SQLSTATE, @errno = MYSQL_ERRNO, @text = MESSAGE_TEXT'; diff --git a/mysql-test/main/ps_missed_cmds_bin_prot.result b/mysql-test/main/ps_missed_cmds_bin_prot.result index 3b56d9a1a5b..d27159354f5 100644 --- a/mysql-test/main/ps_missed_cmds_bin_prot.result +++ b/mysql-test/main/ps_missed_cmds_bin_prot.result @@ -210,26 +210,6 @@ DROP TABLE t1; CREATE SERVER s FOREIGN DATA WRAPPER mysql OPTIONS (USER 'u1', HOST '127.0.0.1'); ALTER SERVER s OPTIONS (USER 'u2'); DROP SERVER s; -# Test case 18: Check that the statements CREATE EVENT/ALTER EVENT/ -# DROP EVENT can be executed as a prepared statement -# Create the event e1 that specifies time in past. Such event is created -# just for the sake of its existence and never will be triggered. -# Disable warnings temprorary in order to hide the following warnings -# generated in result of execution the 'CREATE EVENT' statement: -# "1544 | Event execution time is in the past. Event has been disabled" -# "1105 | Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it." -CREATE EVENT e1 ON SCHEDULE AT CURRENT_TIMESTAMP - INTERVAL 1 DAY ON COMPLETION PRESERVE DO SET @a=1; -ALTER EVENT e1 COMMENT 'New comment'; -DROP EVENT IF EXISTS e1; -# Test case 19: Check that the statement 'SHOW RELAYLOG EVENTS' can be -# executed as a prepared statement. -SHOW RELAYLOG EVENTS; -Log_name Pos Event_type Server_id End_log_pos Info -# Test case 20: Check the the statement 'EXECUTE IMMEDIATE' -# can be executed as a prepared statement -EXECUTE IMMEDIATE 'SELECT 1'; -1 -1 # Test Test case 21: Check the statements 'BACKUP'/'BACKUP STAGE' # can be executed as a prepared statement CREATE TABLE t1 (a INT); diff --git a/mysql-test/main/ps_missed_cmds_bin_prot.test b/mysql-test/main/ps_missed_cmds_bin_prot.test index 10ce9ebd60a..f36385cc079 100644 --- a/mysql-test/main/ps_missed_cmds_bin_prot.test +++ b/mysql-test/main/ps_missed_cmds_bin_prot.test @@ -219,35 +219,6 @@ CREATE SERVER s FOREIGN DATA WRAPPER mysql OPTIONS (USER 'u1', HOST '127.0.0.1') ALTER SERVER s OPTIONS (USER 'u2'); DROP SERVER s; ---echo # Test case 18: Check that the statements CREATE EVENT/ALTER EVENT/ ---echo # DROP EVENT can be executed as a prepared statement - ---echo # Create the event e1 that specifies time in past. Such event is created ---echo # just for the sake of its existence and never will be triggered. ---echo # Disable warnings temprorary in order to hide the following warnings ---echo # generated in result of execution the 'CREATE EVENT' statement: ---echo # "1544 | Event execution time is in the past. Event has been disabled" ---echo # "1105 | Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it." - ---disable_warnings - -CREATE EVENT e1 ON SCHEDULE AT CURRENT_TIMESTAMP - INTERVAL 1 DAY ON COMPLETION PRESERVE DO SET @a=1; - -ALTER EVENT e1 COMMENT 'New comment'; - -DROP EVENT IF EXISTS e1; - ---enable_warnings - ---echo # Test case 19: Check that the statement 'SHOW RELAYLOG EVENTS' can be ---echo # executed as a prepared statement. -SHOW RELAYLOG EVENTS; - ---echo # Test case 20: Check the the statement 'EXECUTE IMMEDIATE' ---echo # can be executed as a prepared statement - -EXECUTE IMMEDIATE 'SELECT 1'; - --echo # Test Test case 21: Check the statements 'BACKUP'/'BACKUP STAGE' --echo # can be executed as a prepared statement CREATE TABLE t1 (a INT); diff --git a/mysql-test/main/ps_missed_cmds_bin_prot_not_embedded.result b/mysql-test/main/ps_missed_cmds_bin_prot_not_embedded.result new file mode 100644 index 00000000000..0e36165db33 --- /dev/null +++ b/mysql-test/main/ps_missed_cmds_bin_prot_not_embedded.result @@ -0,0 +1,21 @@ +# +# MDEV-16708: Unsupported commands for prepared statements +# +SET @save_storage_engine= @@default_storage_engine; +SET default_storage_engine= InnoDB; +# Test case 18: Check that the statements CREATE EVENT/ALTER EVENT/ +# DROP EVENT can be executed as a prepared statement +# Create the event e1 that specifies time in past. Such event is created +# just for the sake of its existence and never will be triggered. +# Disable warnings temprorary in order to hide the following warnings +# generated in result of execution the 'CREATE EVENT' statement: +# "1544 | Event execution time is in the past. Event has been disabled" +# "1105 | Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it." +CREATE EVENT e1 ON SCHEDULE AT CURRENT_TIMESTAMP - INTERVAL 1 DAY ON COMPLETION PRESERVE DO SET @a=1; +ALTER EVENT e1 COMMENT 'New comment'; +DROP EVENT IF EXISTS e1; +# Test case 19: Check that the statement 'SHOW RELAYLOG EVENTS' can be +# executed as a prepared statement. +SHOW RELAYLOG EVENTS; +Log_name Pos Event_type Server_id End_log_pos Info +SET default_storage_engine= @save_storage_engine; diff --git a/mysql-test/main/ps_missed_cmds_bin_prot_not_embedded.test b/mysql-test/main/ps_missed_cmds_bin_prot_not_embedded.test new file mode 100644 index 00000000000..6d87441a476 --- /dev/null +++ b/mysql-test/main/ps_missed_cmds_bin_prot_not_embedded.test @@ -0,0 +1,40 @@ +source include/not_embedded.inc; +--echo # +--echo # MDEV-16708: Unsupported commands for prepared statements +--echo # + +if (`SELECT $PS_PROTOCOL = 0`) +{ + --skip Need ps-protocol +} + +--source include/have_innodb.inc + +SET @save_storage_engine= @@default_storage_engine; +SET default_storage_engine= InnoDB; + +--echo # Test case 18: Check that the statements CREATE EVENT/ALTER EVENT/ +--echo # DROP EVENT can be executed as a prepared statement + +--echo # Create the event e1 that specifies time in past. Such event is created +--echo # just for the sake of its existence and never will be triggered. +--echo # Disable warnings temprorary in order to hide the following warnings +--echo # generated in result of execution the 'CREATE EVENT' statement: +--echo # "1544 | Event execution time is in the past. Event has been disabled" +--echo # "1105 | Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it." + +--disable_warnings + +CREATE EVENT e1 ON SCHEDULE AT CURRENT_TIMESTAMP - INTERVAL 1 DAY ON COMPLETION PRESERVE DO SET @a=1; + +ALTER EVENT e1 COMMENT 'New comment'; + +DROP EVENT IF EXISTS e1; + +--enable_warnings + +--echo # Test case 19: Check that the statement 'SHOW RELAYLOG EVENTS' can be +--echo # executed as a prepared statement. +SHOW RELAYLOG EVENTS; + +SET default_storage_engine= @save_storage_engine; diff --git a/mysql-test/main/ps_missed_cmds_not_embedded.result b/mysql-test/main/ps_missed_cmds_not_embedded.result new file mode 100644 index 00000000000..959a78b5591 --- /dev/null +++ b/mysql-test/main/ps_missed_cmds_not_embedded.result @@ -0,0 +1,61 @@ +SET @save_storage_engine= @@default_storage_engine; +SET default_storage_engine= InnoDB; +# +# MDEV-16708: Unsupported commands for prepared statements +# +# Disable ps-protocol explicitly in order to test support of +# prepared statements for use case when statements passed +# to the server via text client-server protocol (in contrast +# with binary protocol used in the test file +# ps_missed_cmds_bin_prot.test) +# Test case 20: Check that the CREATE EVENT/ALTER EVENT/DROP EVENT +# statements can be executed as a prepared statement +PREPARE stmt_1 FROM "CREATE EVENT e1 ON SCHEDULE AT CURRENT_TIMESTAMP - INTERVAL 1 DAY ON COMPLETION PRESERVE DO SET @a=1"; +PREPARE stmt_2 FROM "ALTER EVENT e1 COMMENT 'New comment'"; +PREPARE stmt_3 FROM "DROP EVENT e1"; +# Create the event e1 that specifies time in past. Such event is created +# just for the sake of its existence and never will be triggered. +# Disable warnings temprorary in order to hide the following warnings +# generated in result of execution the 'CREATE EVENT' statement: +# "1544 | Event execution time is in the past. Event has been disabled" +# "1105 | Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it." +EXECUTE stmt_1; +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the 'CREATE EVENT' statement +# were damaged. Execution of this statement the second time expectedly +# results in emitting the error ER_EVENT_ALREADY_EXISTS since the event +# with the same name has just been created. +EXECUTE stmt_1; +ERROR HY000: Event 'e1' already exists +# Alter event e1 +EXECUTE stmt_2; +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the 'ALTER EVENT' statement +# were damaged. +EXECUTE stmt_2; +# Drop event e1 +EXECUTE stmt_3; +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the 'DROP EVENT' statement +# were damaged. Execution of this statement the second time expectedly +# results in emitting the error ER_EVENT_DOESNT_EXIST since the event +# with the same name has just been dropped. +EXECUTE stmt_3; +ERROR HY000: Unknown event 'e1' +# Clean up +DEALLOCATE PREPARE stmt_1; +DEALLOCATE PREPARE stmt_2; +DEALLOCATE PREPARE stmt_3; +# Test case 22: Check that the 'SHOW RELAYLOG EVENTS' statement can be +# executed as a prepared statement. +PREPARE stmt_1 FROM 'SHOW RELAYLOG EVENTS'; +EXECUTE stmt_1; +Log_name Pos Event_type Server_id End_log_pos Info +# Execute the same prepared statement the second time to check that +# no internal structures used for handling the 'SHOW RELAYLOG EVENTS' +# statement were damaged. +EXECUTE stmt_1; +Log_name Pos Event_type Server_id End_log_pos Info +# Clean up +DEALLOCATE PREPARE stmt_1; +SET default_storage_engine= @save_storage_engine; diff --git a/mysql-test/main/ps_missed_cmds_not_embedded.test b/mysql-test/main/ps_missed_cmds_not_embedded.test new file mode 100644 index 00000000000..2e7eebedf91 --- /dev/null +++ b/mysql-test/main/ps_missed_cmds_not_embedded.test @@ -0,0 +1,85 @@ +--source include/not_embedded.inc +--source include/have_innodb.inc + +if (`SELECT $PS_PROTOCOL != 0`) +{ + --skip Need regular protocol but ps-protocol was specified +} + +SET @save_storage_engine= @@default_storage_engine; +SET default_storage_engine= InnoDB; + +--echo # +--echo # MDEV-16708: Unsupported commands for prepared statements +--echo # + +--echo # Disable ps-protocol explicitly in order to test support of +--echo # prepared statements for use case when statements passed +--echo # to the server via text client-server protocol (in contrast +--echo # with binary protocol used in the test file +--echo # ps_missed_cmds_bin_prot.test) +--disable_ps_protocol + +--echo # Test case 20: Check that the CREATE EVENT/ALTER EVENT/DROP EVENT +--echo # statements can be executed as a prepared statement + +PREPARE stmt_1 FROM "CREATE EVENT e1 ON SCHEDULE AT CURRENT_TIMESTAMP - INTERVAL 1 DAY ON COMPLETION PRESERVE DO SET @a=1"; + +PREPARE stmt_2 FROM "ALTER EVENT e1 COMMENT 'New comment'"; + +PREPARE stmt_3 FROM "DROP EVENT e1"; +--echo # Create the event e1 that specifies time in past. Such event is created +--echo # just for the sake of its existence and never will be triggered. +--echo # Disable warnings temprorary in order to hide the following warnings +--echo # generated in result of execution the 'CREATE EVENT' statement: +--echo # "1544 | Event execution time is in the past. Event has been disabled" +--echo # "1105 | Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it." + +--disable_warnings +EXECUTE stmt_1; + +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the 'CREATE EVENT' statement +--echo # were damaged. Execution of this statement the second time expectedly +--echo # results in emitting the error ER_EVENT_ALREADY_EXISTS since the event +--echo # with the same name has just been created. +--error ER_EVENT_ALREADY_EXISTS +EXECUTE stmt_1; + +--enable_warnings + +--echo # Alter event e1 +EXECUTE stmt_2; +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the 'ALTER EVENT' statement +--echo # were damaged. +EXECUTE stmt_2; + +--echo # Drop event e1 +EXECUTE stmt_3; +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the 'DROP EVENT' statement +--echo # were damaged. Execution of this statement the second time expectedly +--echo # results in emitting the error ER_EVENT_DOESNT_EXIST since the event +--echo # with the same name has just been dropped. +--error ER_EVENT_DOES_NOT_EXIST +EXECUTE stmt_3; +--echo # Clean up +DEALLOCATE PREPARE stmt_1; +DEALLOCATE PREPARE stmt_2; +DEALLOCATE PREPARE stmt_3; + +--echo # Test case 22: Check that the 'SHOW RELAYLOG EVENTS' statement can be +--echo # executed as a prepared statement. +PREPARE stmt_1 FROM 'SHOW RELAYLOG EVENTS'; +EXECUTE stmt_1; +--echo # Execute the same prepared statement the second time to check that +--echo # no internal structures used for handling the 'SHOW RELAYLOG EVENTS' +--echo # statement were damaged. +EXECUTE stmt_1; +--echo # Clean up +DEALLOCATE PREPARE stmt_1; + +--enable_warnings +--enable_ps_protocol +SET default_storage_engine= @save_storage_engine; diff --git a/mysql-test/suite/funcs_1/t/is_columns_myisam_embedded.test b/mysql-test/suite/funcs_1/t/is_columns_myisam_embedded.test index 3d0cca24474..9e31190c008 100644 --- a/mysql-test/suite/funcs_1/t/is_columns_myisam_embedded.test +++ b/mysql-test/suite/funcs_1/t/is_columns_myisam_embedded.test @@ -15,6 +15,7 @@ if (`SELECT VERSION() NOT LIKE '%embedded%'`) --skip Test requires: embedded server } let $engine_type= MyISAM; +--enable_prepare_warnings SET @@session.sql_mode = 'NO_ENGINE_SUBSTITUTION'; --source suite/funcs_1/datadict/datadict_load.inc diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/create_table_index_parser_comment.test b/storage/mroonga/mysql-test/mroonga/storage/t/create_table_index_parser_comment.test index 82d68ae5421..c4bc32d18ce 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/create_table_index_parser_comment.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/create_table_index_parser_comment.test @@ -28,6 +28,7 @@ CREATE TABLE diaries ( COMMENT 'parser "TokenBigramSplitSymbolAlphaDigit"' ) DEFAULT CHARSET utf8; +--enable_prepare_warnings INSERT INTO diaries (body) VALUES ("will start Groonga!"); INSERT INTO diaries (body) VALUES ("starting Groonga..."); INSERT INTO diaries (body) VALUES ("started Groonga."); diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/create_table_index_parser_off.test b/storage/mroonga/mysql-test/mroonga/storage/t/create_table_index_parser_off.test index f62a6a0fe6c..2191a28c483 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/create_table_index_parser_off.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/create_table_index_parser_off.test @@ -27,6 +27,7 @@ CREATE TABLE variables ( FULLTEXT INDEX (name) COMMENT 'parser "off"' ) DEFAULT CHARSET=utf8; +--enable_prepare_warnings INSERT INTO variables (name) VALUES ("mroonga_database_path_prefix"); INSERT INTO variables (name) VALUES ("mroonga_default_tokenizer"); INSERT INTO variables (name) VALUES ("mroonga_default_wrapper_engine"); diff --git a/storage/mroonga/mysql-test/mroonga/wrapper/t/create_table_parser_comment.test b/storage/mroonga/mysql-test/mroonga/wrapper/t/create_table_parser_comment.test index 064685d20b9..81342a74f2e 100644 --- a/storage/mroonga/mysql-test/mroonga/wrapper/t/create_table_parser_comment.test +++ b/storage/mroonga/mysql-test/mroonga/wrapper/t/create_table_parser_comment.test @@ -28,6 +28,7 @@ create table diaries ( fulltext index body_index (body) comment 'parser "TokenBigramSplitSymbolAlphaDigit"' ) comment = 'engine "innodb"' default charset utf8; +--enable_prepare_warnings insert into diaries (body) values ("will start Groonga!"); insert into diaries (body) values ("starting Groonga..."); insert into diaries (body) values ("started Groonga."); From 3d752f0a3ac8eefacdc8dc1a152f0f32a2b5b7ae Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 16 Jun 2021 20:40:40 +0200 Subject: [PATCH 126/251] MDEV-16708: correct server side cursor detection in embedded fixes a bunch of tests failures in --ps --embed also, don't use cli_advanced_command(). --- libmysqld/libmysql.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/libmysqld/libmysql.c b/libmysqld/libmysql.c index 09ae52aedee..fbfe8b683c0 100644 --- a/libmysqld/libmysql.c +++ b/libmysqld/libmysql.c @@ -2132,7 +2132,7 @@ static my_bool execute(MYSQL_STMT *stmt, char *packet, ulong length) buff[4]= (char) stmt->flags; int4store(buff+5, 1); /* iteration count */ - res= MY_TEST(cli_advanced_command(mysql, COM_STMT_EXECUTE, buff, sizeof(buff), + res= MY_TEST((*mysql->methods->advanced_command)(mysql, COM_STMT_EXECUTE, buff, sizeof(buff), (uchar*) packet, length, 1, stmt) || (*mysql->methods->read_query_result)(mysql)); stmt->affected_rows= mysql->affected_rows; @@ -2524,9 +2524,16 @@ static void reinit_result_set_metadata(MYSQL_STMT *stmt) } +static int has_cursor(MYSQL_STMT *stmt) +{ + return stmt->server_status & SERVER_STATUS_CURSOR_EXISTS && + stmt->flags & CURSOR_TYPE_READ_ONLY; +} + + static void prepare_to_fetch_result(MYSQL_STMT *stmt) { - if (stmt->server_status & SERVER_STATUS_CURSOR_EXISTS) + if (has_cursor(stmt)) { stmt->mysql->status= MYSQL_STATUS_READY; stmt->read_row_func= stmt_read_row_from_cursor; @@ -4470,8 +4477,7 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt) DBUG_RETURN(1); } - if (mysql->status == MYSQL_STATUS_READY && - stmt->server_status & SERVER_STATUS_CURSOR_EXISTS) + if (mysql->status == MYSQL_STATUS_READY && has_cursor(stmt)) { /* Server side cursor exist, tell server to start sending the rows @@ -4483,7 +4489,7 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt) /* Send row request to the server */ int4store(buff, stmt->stmt_id); int4store(buff + 4, (int)~0); /* number of rows to fetch */ - if (cli_advanced_command(mysql, COM_STMT_FETCH, buff, sizeof(buff), + if ((*mysql->methods->advanced_command)(mysql, COM_STMT_FETCH, buff, sizeof(buff), (uchar*) 0, 0, 1, stmt)) { /* From 44db6ffc192a3cca61be3fc2c1e977821ad2f733 Mon Sep 17 00:00:00 2001 From: Dmitry Shulga Date: Thu, 17 Jun 2021 14:53:22 +0700 Subject: [PATCH 127/251] MDEV-16708: fixed failure of the test sys_vars.sql_select_limit_func This test failed in case it was run in PS mode and for embedded server The reason of test failure was that the following fields affected_row, server_status, insert_id of the structure MYSQL_STMT weren't update on calling mysql_stmt_next_result() in case combination of binary protocol and embedded server used. --- libmysqld/libmysql.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libmysqld/libmysql.c b/libmysqld/libmysql.c index fbfe8b683c0..7a0843d32e5 100644 --- a/libmysqld/libmysql.c +++ b/libmysqld/libmysql.c @@ -4936,6 +4936,12 @@ int STDCALL mysql_stmt_next_result(MYSQL_STMT *stmt) alloc_stmt_fields(stmt); prepare_to_fetch_result(stmt); } + else + { + stmt->affected_rows= stmt->mysql->affected_rows; + stmt->server_status= stmt->mysql->server_status; + stmt->insert_id= stmt->mysql->insert_id; + } DBUG_RETURN(0); } From 59cf1a8a8ad07add11ea9a55ebb15828d3d99196 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 17 Jun 2021 12:12:42 +0200 Subject: [PATCH 128/251] update C/C --- libmariadb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmariadb b/libmariadb index a771b3ba206..74a405d9770 160000 --- a/libmariadb +++ b/libmariadb @@ -1 +1 @@ -Subproject commit a771b3ba2069cbef54545ee1570db8e174bc8c71 +Subproject commit 74a405d9770720e000c391672fca9e67421fa4bf From 78bd7d86a4a0b3733ba38373213645a6b3a9b9c6 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Thu, 17 Jun 2021 20:39:47 +0200 Subject: [PATCH 129/251] MDEV-25953 Tpool - prevent potential deadlock in simulated AIO Do not execute user callback just after pwrite. Instead, submit user function as task into thread pool. This way, the IO thread would not hog aiocb, which is a limited (in Innodb) resource --- tpool/aio_simulated.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tpool/aio_simulated.cc b/tpool/aio_simulated.cc index 4811797a75e..93b2ae134b2 100644 --- a/tpool/aio_simulated.cc +++ b/tpool/aio_simulated.cc @@ -159,7 +159,9 @@ public: #endif cb->m_ret_len = ret_len; cb->m_err = err; - cb->m_callback(cb); + cb->m_internal_task.m_func= cb->m_callback; + thread_pool *pool= (thread_pool *)cb->m_internal; + pool->submit_task(&cb->m_internal_task); } virtual int submit_io(aiocb *aiocb) override @@ -167,6 +169,7 @@ public: aiocb->m_internal_task.m_func = simulated_aio_callback; aiocb->m_internal_task.m_arg = aiocb; aiocb->m_internal_task.m_group = aiocb->m_group; + aiocb->m_internal = m_pool; m_pool->submit_task(&aiocb->m_internal_task); return 0; } From b7d87bf0a988e6471b793c4c148837a460641102 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Otto=20Kek=C3=A4l=C3=A4inen?= Date: Sun, 30 May 2021 15:42:04 -0700 Subject: [PATCH 130/251] MDEV-20392: Skip ABI check if 'diff' is not found Not all environments have 'diff' installed. Most notably CentOS 8 does not have diff out-of-the-box. Thus users running 'cmake .' and 'make' would fail to build MariaDB, and they would think the error was in ABI incompatibilities due to the error message emitted by CMake when in reality simply 'diff' was missing. This fixes it and makes the developer experience better by simply skipping the diffing if 'diff' is not found. ## Proof Running in a clean CentOS 8 container. ### Before ``` $ cmake . ... -- Looking for cpuid.h -- Looking for cpuid.h - found -- Looking for x86intrin.h -- Looking for x86intrin.h - found -- Looking for event.h -- Looking for event.h - not found -- Configuring done -- Generating done -- Build files have been written to: /build $ make Scanning dependencies of target abi_check CMake Error at cmake/do_abi_check.cmake:82 (MESSAGE): ABI check found difference between /build/include/mysql/plugin_audit.h.pp and /build/abi_check.out make[2]: *** [CMakeFiles/abi_check.dir/build.make:57: CMakeFiles/abi_check] Error 1 make[1]: *** [CMakeFiles/Makefile2:168: CMakeFiles/abi_check.dir/all] Error 2 make: *** [Makefile:163: all] Error 2 $ yum install -y diffutils ... Installed: diffutils-3.6-6.el8.x86_64 Complete! $ make [ 0%] Built target abi_check Scanning dependencies of target INFO_BIN [ 0%] Built target INFO_BIN Scanning dependencies of target INFO_SRC [ 0%] Built target INFO_SRC Scanning dependencies of target wsrep_api_v26 [ 0%] Building C object wsrep-lib/wsrep-API/CMakeFiles/wsrep_api_v26.dir/v26/wsrep_dummy.c.o [ 0%] Building C object wsrep-lib/wsrep-API/CMakeFiles/wsrep_api_v26.dir/v26/wsrep_gtid.c.o [ 0%] Building C object wsrep-lib/wsrep-API/CMakeFiles/wsrep_api_v26.dir/v26/wsrep_loader.c.o [ 0%] Building C object wsrep-lib/wsrep-API/CMakeFiles/wsrep_api_v26.dir/v26/wsrep_uuid.c.o [ 0%] Linking C static library libwsrep_api_v26.a [ 0%] Built target wsrep_api_v26 ``` ### After ``` $ make Command 'diff' not found. ABI check for /build/server/include/mysql/plugin_audit.h skipped. Command 'diff' not found. ABI check for /build/server/include/mysql/plugin_ftparser.h skipped. Command 'diff' not found. ABI check for /build/server/include/mysql.h skipped. Command 'diff' not found. ABI check for /build/server/include/mysql/psi/psi_abi_v1.h skipped. Command 'diff' not found. ABI check for /build/server/include/mysql/psi/psi_abi_v2.h skipped. Command 'diff' not found. ABI check for /build/server/include/mysql/client_plugin.h skipped. Command 'diff' not found. ABI check for /build/server/include/mysql/plugin_auth.h skipped. Command 'diff' not found. ABI check for /build/server/include/mysql/plugin_password_validation.h skipped. Command 'diff' not found. ABI check for /build/server/include/mysql/plugin_encryption.h skipped. Command 'diff' not found. ABI check for /build/server/include/mysql/plugin_data_type.h skipped. Command 'diff' not found. ABI check for /build/server/include/mysql/plugin_function.h skipped. [ 0%] Built target abi_check [ 0%] Built target INFO_SRC [ 0%] Built target INFO_BIN [ 0%] Built target wsrep_api_v26 [ 0%] Building CXX object wsrep-lib/src/CMakeFiles/wsrep-lib.dir/server_state.cpp.o ``` If diff is installed, those warnings are simply not shown. Builds pass without the need to install 'diff'. --- cmake/do_abi_check.cmake | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmake/do_abi_check.cmake b/cmake/do_abi_check.cmake index d775d310383..02bf9fbe1fb 100644 --- a/cmake/do_abi_check.cmake +++ b/cmake/do_abi_check.cmake @@ -75,7 +75,9 @@ FOREACH(file ${ABI_HEADERS}) FILE(REMOVE ${tmpfile}) EXECUTE_PROCESS( COMMAND diff -w ${file}.pp ${abi_check_out} RESULT_VARIABLE result) - IF(NOT ${result} EQUAL 0) + IF(result MATCHES "No such file or directory") + MESSAGE("Command 'diff' not found. ABI check for ${file} skipped.") + ELSEIF(NOT result EQUAL 0) IF(ABI_UPDATE) EXECUTE_PROCESS(COMMAND mv -v ${abi_check_out} ${file}.pp) ELSE(ABI_UPDATE) @@ -85,4 +87,3 @@ FOREACH(file ${ABI_HEADERS}) ENDIF() FILE(REMOVE ${abi_check_out}) ENDFOREACH() - From dc82effa5df5e59be6c7de4038f0a832f37d9bdc Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 16 Jun 2021 19:19:10 +0200 Subject: [PATCH 131/251] MDEV-25867 main.trigger-trans failed in bb, Assertion `ticket->m_duration == MDL_EXPLICIT' failed in MDL_context::release_lock release MDL on the trigger as early as possible, after everything that cannot be done concurrently was done (under MDL), but before relocking tables. --- sql/sql_trigger.cc | 48 +++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index a99078362d6..250ff859222 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -393,7 +393,7 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) This is a good candidate for a minor refactoring. */ TABLE *table; - bool result= TRUE; + bool result= TRUE, refresh_metadata= FALSE; String stmt_query; bool lock_upgrade_done= FALSE; bool backup_of_table_list_done= 0;; @@ -606,26 +606,34 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) table->triggers->create_trigger(thd, tables, &stmt_query): table->triggers->drop_trigger(thd, tables, &stmt_query)); - close_all_tables_for_name(thd, table->s, HA_EXTRA_NOT_USED, NULL); - - /* - Reopen the table if we were under LOCK TABLES. - Ignore the return value for now. It's better to - keep master/slave in consistent state. - */ - if (thd->locked_tables_list.reopen_tables(thd, false)) - thd->clear_error(); - - /* - Invalidate SP-cache. That's needed because triggers may change list of - pre-locking tables. - */ - sp_cache_invalidate(); + refresh_metadata= TRUE; end: if (!result) result= write_bin_log(thd, TRUE, stmt_query.ptr(), stmt_query.length()); + if (mdl_request_for_trn.ticket) + thd->mdl_context.release_lock(mdl_request_for_trn.ticket); + + if (refresh_metadata) + { + close_all_tables_for_name(thd, table->s, HA_EXTRA_NOT_USED, NULL); + + /* + Reopen the table if we were under LOCK TABLES. + Ignore the return value for now. It's better to + keep master/slave in consistent state. + */ + if (thd->locked_tables_list.reopen_tables(thd, false)) + thd->clear_error(); + + /* + Invalidate SP-cache. That's needed because triggers may change list of + pre-locking tables. + */ + sp_cache_invalidate(); + } + /* If we are under LOCK TABLES we should restore original state of meta-data locks. Otherwise all locks will be released along @@ -647,14 +655,6 @@ end: thd->lex->spname->m_name.str, static_cast(thd->lex->spname->m_name.length)); } - /* In Locked_tables_list::reopen_tables(), - MDL_context::set_transaction_duration_for_all_locks() may have been invoked, - converting our explicit MDL to transaction scope. In that case, we will not - release the lock, to avoid a debug assertion failure. */ - if (MDL_ticket *ticket= mdl_request_for_trn.ticket) - if (thd->mdl_context.has_explicit_locks()) - thd->mdl_context.release_lock(ticket); - DBUG_RETURN(result); #ifdef WITH_WSREP From cccc7b5f9b180a14a0c0e2f087d387e9b3fd5256 Mon Sep 17 00:00:00 2001 From: Daniel Bartholomew Date: Fri, 18 Jun 2021 11:51:14 -0400 Subject: [PATCH 132/251] bump the VERSION --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index ecd6263f7b4..46c8d25fe95 100644 --- a/VERSION +++ b/VERSION @@ -1,4 +1,4 @@ MYSQL_VERSION_MAJOR=10 MYSQL_VERSION_MINOR=6 -MYSQL_VERSION_PATCH=2 +MYSQL_VERSION_PATCH=3 SERVER_MATURITY=gamma From 8bb225d10a5fb06724a7979d97e6ee936843da74 Mon Sep 17 00:00:00 2001 From: Alice Sherepa Date: Fri, 18 Jun 2021 17:52:44 +0200 Subject: [PATCH 133/251] MDEV-16708: fixed test rpl_innodb_bug28430, failing with --ps --- mysql-test/suite/rpl/t/rpl_innodb_bug28430.test | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/suite/rpl/t/rpl_innodb_bug28430.test b/mysql-test/suite/rpl/t/rpl_innodb_bug28430.test index 12698263da4..0b8fb751726 100644 --- a/mysql-test/suite/rpl/t/rpl_innodb_bug28430.test +++ b/mysql-test/suite/rpl/t/rpl_innodb_bug28430.test @@ -5,7 +5,7 @@ --source include/master-slave.inc # Set the default connection to 'master' - +--enable_prepare_warnings --vertical_results let $engine_type= 'innodb'; @@ -151,7 +151,7 @@ SELECT count(*) "Slave bykey" FROM test.bykey_tbl; SELECT count(*) "Slave byrange" FROM test.byrange_tbl; ###### CLEAN UP SECTION ############## - +--disable_prepare_warnings connection master; DROP PROCEDURE test.proc_norm; DROP PROCEDURE test.proc_bykey; From 83a471344f448950956b914e1150e845833a71ee Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 18 Jun 2021 21:36:10 +0200 Subject: [PATCH 134/251] fix big tests for -ps --- .../suite/funcs_1/t/myisam_views-big.test | 2 ++ mysql-test/suite/innodb/r/doublewrite.result | 24 +++++++------------ mysql-test/suite/innodb/t/doublewrite.test | 16 ++++++------- mysql-test/suite/parts/r/rpl_partition.result | 18 +++----------- mysql-test/suite/parts/t/rpl_partition.test | 6 ++--- 5 files changed, 24 insertions(+), 42 deletions(-) diff --git a/mysql-test/suite/funcs_1/t/myisam_views-big.test b/mysql-test/suite/funcs_1/t/myisam_views-big.test index 565a3b100b9..bf499ee789a 100644 --- a/mysql-test/suite/funcs_1/t/myisam_views-big.test +++ b/mysql-test/suite/funcs_1/t/myisam_views-big.test @@ -9,6 +9,7 @@ # # Set $engine_type SET @@session.sql_mode = 'NO_ENGINE_SUBSTITUTION'; +--enable_prepare_warnings let $engine_type= myisam; # Create some objects needed in many testcases @@ -27,6 +28,7 @@ let $message= Attention: The nesting level @max_level in Testcase 3.3.1.A6 MyISAM(only) performance issues Bug#11948; --source include/show_msg80.inc SET @limit1 = 20; +--disable_prepare_warnings --source suite/funcs_1/views/views_master.inc DROP DATABASE test1; diff --git a/mysql-test/suite/innodb/r/doublewrite.result b/mysql-test/suite/innodb/r/doublewrite.result index 1f26f7d1f5f..322385088b2 100644 --- a/mysql-test/suite/innodb/r/doublewrite.result +++ b/mysql-test/suite/innodb/r/doublewrite.result @@ -28,10 +28,8 @@ commit work; # --------------------------------------------------------------- # Test Begin: Test if recovery works if first page of user # tablespace is full of zeroes. -select space from information_schema.innodb_sys_tables -where name = 'test/t1' into @space_id; -Warnings: -Warning 1287 ' INTO FROM...' instead +select space into @space_id from information_schema.innodb_sys_tables +where name = 'test/t1'; begin; insert into t1 values (6, repeat('%', 12)); # Ensure that dirty pages of table t1 are flushed. @@ -62,10 +60,8 @@ f1 f2 # --------------------------------------------------------------- # Test Begin: Test if recovery works if first page of user # tablespace is corrupted. -select space from information_schema.innodb_sys_tables -where name = 'test/t1' into @space_id; -Warnings: -Warning 1287 ' INTO FROM...' instead +select space into @space_id from information_schema.innodb_sys_tables +where name = 'test/t1'; # Ensure that dirty pages of table t1 is flushed. flush tables t1 for export; unlock tables; @@ -93,10 +89,8 @@ f1 f2 # --------------------------------------------------------------- # Test Begin: Test if recovery works if 2nd page of user # tablespace is full of zeroes. -select space from information_schema.innodb_sys_tables -where name = 'test/t1' into @space_id; -Warnings: -Warning 1287 ' INTO FROM...' instead +select space into @space_id from information_schema.innodb_sys_tables +where name = 'test/t1'; # Ensure that dirty pages of table t1 is flushed. flush tables t1 for export; unlock tables; @@ -124,10 +118,8 @@ f1 f2 # --------------------------------------------------------------- # Test Begin: Test if recovery works if 2nd page of user # tablespace is corrupted. -select space from information_schema.innodb_sys_tables -where name = 'test/t1' into @space_id; -Warnings: -Warning 1287 ' INTO FROM...' instead +select space into @space_id from information_schema.innodb_sys_tables +where name = 'test/t1'; # Ensure that dirty pages of table t1 is flushed. flush tables t1 for export; unlock tables; diff --git a/mysql-test/suite/innodb/t/doublewrite.test b/mysql-test/suite/innodb/t/doublewrite.test index bd4f5fadcc3..fac1812e565 100644 --- a/mysql-test/suite/innodb/t/doublewrite.test +++ b/mysql-test/suite/innodb/t/doublewrite.test @@ -52,8 +52,8 @@ commit work; --echo # Test Begin: Test if recovery works if first page of user --echo # tablespace is full of zeroes. -select space from information_schema.innodb_sys_tables -where name = 'test/t1' into @space_id; +select space into @space_id from information_schema.innodb_sys_tables +where name = 'test/t1'; begin; insert into t1 values (6, repeat('%', 12)); @@ -152,8 +152,8 @@ select f1, f2 from t1; --echo # Test Begin: Test if recovery works if first page of user --echo # tablespace is corrupted. -select space from information_schema.innodb_sys_tables -where name = 'test/t1' into @space_id; +select space into @space_id from information_schema.innodb_sys_tables +where name = 'test/t1'; --echo # Ensure that dirty pages of table t1 is flushed. flush tables t1 for export; @@ -196,8 +196,8 @@ select f1, f2 from t1; --echo # Test Begin: Test if recovery works if 2nd page of user --echo # tablespace is full of zeroes. -select space from information_schema.innodb_sys_tables -where name = 'test/t1' into @space_id; +select space into @space_id from information_schema.innodb_sys_tables +where name = 'test/t1'; --echo # Ensure that dirty pages of table t1 is flushed. flush tables t1 for export; @@ -239,8 +239,8 @@ select f1, f2 from t1; --echo # Test Begin: Test if recovery works if 2nd page of user --echo # tablespace is corrupted. -select space from information_schema.innodb_sys_tables -where name = 'test/t1' into @space_id; +select space into @space_id from information_schema.innodb_sys_tables +where name = 'test/t1'; --echo # Ensure that dirty pages of table t1 is flushed. flush tables t1 for export; diff --git a/mysql-test/suite/parts/r/rpl_partition.result b/mysql-test/suite/parts/r/rpl_partition.result index dcd45ce4fe1..41df816fcc0 100644 --- a/mysql-test/suite/parts/r/rpl_partition.result +++ b/mysql-test/suite/parts/r/rpl_partition.result @@ -59,16 +59,12 @@ INSERT INTO t1 VALUES (NULL, NOW(), USER() , UUID(), ins_count,'Going to test MBR for MySQL'); SET ins_count = ins_count - 1; END WHILE; -SELECT MAX(id) FROM t1 INTO del_count; +SELECT MAX(id) INTO del_count FROM t1; WHILE del_count > 0 DO DELETE FROM t1 WHERE id = del_count; SET del_count = del_count - 2; END WHILE; END| -Warnings: -Level Warning -Code 1287 -Message ' INTO FROM...' instead CREATE PROCEDURE p2() BEGIN DECLARE ins_count INT DEFAULT 1000; @@ -84,16 +80,12 @@ INSERT INTO t2 VALUES (NULL, NOW(), USER() , UUID(), ins_count,'Going to test MBR for MySQL'); SET ins_count = ins_count - 1; END WHILE; -SELECT MAX(id) FROM t2 INTO del_count; +SELECT MAX(id) INTO del_count FROM t2; WHILE del_count > 0 DO DELETE FROM t2 WHERE id = del_count; SET del_count = del_count - 2; END WHILE; END| -Warnings: -Level Warning -Code 1287 -Message ' INTO FROM...' instead CREATE PROCEDURE p3() BEGIN DECLARE ins_count INT DEFAULT 1000; @@ -109,16 +101,12 @@ INSERT INTO t3 VALUES (NULL, NOW(), USER(), UUID(), ins_count,'Going to test MBR for MySQL'); SET ins_count = ins_count - 1; END WHILE; -SELECT MAX(id) FROM t3 INTO del_count; +SELECT MAX(id) INTO del_count FROM t3; WHILE del_count > 0 DO DELETE FROM t3 WHERE id = del_count; SET del_count = del_count - 2; END WHILE; END| -Warnings: -Level Warning -Code 1287 -Message ' INTO FROM...' instead begin; CALL p1(); commit; diff --git a/mysql-test/suite/parts/t/rpl_partition.test b/mysql-test/suite/parts/t/rpl_partition.test index 85b3f348921..30493343b47 100644 --- a/mysql-test/suite/parts/t/rpl_partition.test +++ b/mysql-test/suite/parts/t/rpl_partition.test @@ -74,7 +74,7 @@ BEGIN SET ins_count = ins_count - 1; END WHILE; - SELECT MAX(id) FROM t1 INTO del_count; + SELECT MAX(id) INTO del_count FROM t1; WHILE del_count > 0 DO DELETE FROM t1 WHERE id = del_count; SET del_count = del_count - 2; @@ -99,7 +99,7 @@ BEGIN SET ins_count = ins_count - 1; END WHILE; - SELECT MAX(id) FROM t2 INTO del_count; + SELECT MAX(id) INTO del_count FROM t2; WHILE del_count > 0 DO DELETE FROM t2 WHERE id = del_count; SET del_count = del_count - 2; @@ -124,7 +124,7 @@ BEGIN SET ins_count = ins_count - 1; END WHILE; - SELECT MAX(id) FROM t3 INTO del_count; + SELECT MAX(id) INTO del_count FROM t3; WHILE del_count > 0 DO DELETE FROM t3 WHERE id = del_count; SET del_count = del_count - 2; From a5f6eca50db3b8c6abddc1e373441827c4655edc Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sat, 19 Jun 2021 00:22:15 +0200 Subject: [PATCH 135/251] spider tests aren't big and *never* disable tests in suite.pm based on $::opt_big_test, this will make the test skipped both as too big (for ./mtr) and as too small (for ./mtr --big --big). --- storage/spider/mysql-test/spider/bg/suite.pm | 1 - storage/spider/mysql-test/spider/bugfix/suite.pm | 1 - storage/spider/mysql-test/spider/handler/suite.pm | 1 - storage/spider/mysql-test/spider/suite.pm | 1 - 4 files changed, 4 deletions(-) diff --git a/storage/spider/mysql-test/spider/bg/suite.pm b/storage/spider/mysql-test/spider/bg/suite.pm index f106147deb6..171fa6c4f01 100644 --- a/storage/spider/mysql-test/spider/bg/suite.pm +++ b/storage/spider/mysql-test/spider/bg/suite.pm @@ -4,7 +4,6 @@ package My::Suite::Spider; return "No Spider engine" unless $ENV{HA_SPIDER_SO}; return "Not run for embedded server" if $::opt_embedded_server; -return "Test needs --big-test" unless $::opt_big_test; sub is_default { 1 } diff --git a/storage/spider/mysql-test/spider/bugfix/suite.pm b/storage/spider/mysql-test/spider/bugfix/suite.pm index f106147deb6..171fa6c4f01 100644 --- a/storage/spider/mysql-test/spider/bugfix/suite.pm +++ b/storage/spider/mysql-test/spider/bugfix/suite.pm @@ -4,7 +4,6 @@ package My::Suite::Spider; return "No Spider engine" unless $ENV{HA_SPIDER_SO}; return "Not run for embedded server" if $::opt_embedded_server; -return "Test needs --big-test" unless $::opt_big_test; sub is_default { 1 } diff --git a/storage/spider/mysql-test/spider/handler/suite.pm b/storage/spider/mysql-test/spider/handler/suite.pm index b023e5206ef..af267d047a4 100644 --- a/storage/spider/mysql-test/spider/handler/suite.pm +++ b/storage/spider/mysql-test/spider/handler/suite.pm @@ -4,7 +4,6 @@ package My::Suite::Spider; return "No Spider engine" unless $ENV{HA_SPIDER_SO}; return "Not run for embedded server" if $::opt_embedded_server; -return "Test needs --big-test" unless $::opt_big_test; sub is_default { 1 } diff --git a/storage/spider/mysql-test/spider/suite.pm b/storage/spider/mysql-test/spider/suite.pm index f106147deb6..171fa6c4f01 100644 --- a/storage/spider/mysql-test/spider/suite.pm +++ b/storage/spider/mysql-test/spider/suite.pm @@ -4,7 +4,6 @@ package My::Suite::Spider; return "No Spider engine" unless $ENV{HA_SPIDER_SO}; return "Not run for embedded server" if $::opt_embedded_server; -return "Test needs --big-test" unless $::opt_big_test; sub is_default { 1 } From 068246c006b8f691982194529a32bff7eb010694 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sat, 19 Jun 2021 00:45:49 +0200 Subject: [PATCH 136/251] fix spider tests for --ps spider tests use --let $var= many;sql;statements --eval $var and this doesn't work in ps --- storage/spider/mysql-test/spider/bugfix/t/mdev_20100.test | 4 ++++ storage/spider/mysql-test/spider/bugfix/t/mdev_21884.test | 4 ++++ .../spider/mysql-test/spider/bugfix/t/wrapper_mariadb.test | 2 ++ storage/spider/mysql-test/spider/t/partition_mrr.test | 1 + 4 files changed, 11 insertions(+) diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_20100.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_20100.test index b72facd11a6..3f522b4f6f5 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_20100.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_20100.test @@ -22,7 +22,9 @@ USE auto_test_remote; --connection child2_1 --disable_query_log echo CHILD2_1_CREATE_TABLES; +--disable_ps_protocol eval $CHILD2_1_CREATE_TABLES; +--enable_ps_protocol --enable_query_log TRUNCATE TABLE mysql.general_log; @@ -66,7 +68,9 @@ SELECT a, b, c FROM tbl_a PARTITION (pt2,pt3); --connection child2_1 eval $CHILD2_1_SELECT_ARGUMENT1; +--disable_ps_protocol eval $CHILD2_1_SELECT_TABLES; +--enable_ps_protocol --echo --echo deinit diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_21884.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_21884.test index be4aa6a6330..16836cfce28 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/mdev_21884.test +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_21884.test @@ -22,7 +22,9 @@ USE auto_test_remote; --connection child2_1 --disable_query_log echo CHILD2_1_CREATE_TABLES; +--disable_ps_protocol eval $CHILD2_1_CREATE_TABLES; +--enable_ps_protocol --enable_query_log TRUNCATE TABLE mysql.general_log; @@ -78,7 +80,9 @@ SELECT STRAIGHT_JOIN b.a, b.b FROM tb_l a, tbl_a b WHERE a.a = b.a; --connection child2_1 SET NAMES utf8; eval $CHILD2_1_SELECT_ARGUMENT1; +--disable_ps_protocol eval $CHILD2_1_SELECT_TABLES; +--enable_ps_protocol --echo --echo deinit diff --git a/storage/spider/mysql-test/spider/bugfix/t/wrapper_mariadb.test b/storage/spider/mysql-test/spider/bugfix/t/wrapper_mariadb.test index 0102155b5ab..4f980140a31 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/wrapper_mariadb.test +++ b/storage/spider/mysql-test/spider/bugfix/t/wrapper_mariadb.test @@ -49,6 +49,8 @@ TRUNCATE TABLE mysql.general_log; SELECT * FROM tbl_a ORDER BY pkey; --connection child2_1 +# in --ps a query is logged differently in a general log +replace_regex /order by t0.`pkey`/order by `pkey`/; eval $CHILD2_1_SELECT_ARGUMENT1; eval $CHILD2_1_SELECT_TABLES; diff --git a/storage/spider/mysql-test/spider/t/partition_mrr.test b/storage/spider/mysql-test/spider/t/partition_mrr.test index e7fedce33e6..2816d65cadb 100644 --- a/storage/spider/mysql-test/spider/t/partition_mrr.test +++ b/storage/spider/mysql-test/spider/t/partition_mrr.test @@ -1,3 +1,4 @@ +--source include/no_protocol.inc --source ../include/partition_mrr_init.inc if (!$HAVE_PARTITION) { From 87de0e2129fbc1ade1d129520f1ebf0338672321 Mon Sep 17 00:00:00 2001 From: Monty Date: Thu, 17 Jun 2021 16:06:46 +0300 Subject: [PATCH 137/251] Minor cleanups of atomic ddl code - Rename DDL_IGNORE_LOG_ENTRY_CODE to DDL_LOG_IGNORE_ENTRY_CODE This makes it similar to all other ddl_log_entry_code's. - Added some new comments - ddl_log_revert() now returns != 0 if revert didn't succeed --- sql/ddl_log.cc | 29 ++++++++++++++++++++--------- sql/ddl_log.h | 6 +++--- sql/sql_trigger.cc | 2 +- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/sql/ddl_log.cc b/sql/ddl_log.cc index 8b2813327df..15bb836047b 100644 --- a/sql/ddl_log.cc +++ b/sql/ddl_log.cc @@ -421,7 +421,7 @@ static bool disable_execute_entry(uint entry_pos) uchar buff[1]; DBUG_ENTER("disable_execute_entry"); - buff[0]= DDL_IGNORE_LOG_ENTRY_CODE; + buff[0]= DDL_LOG_IGNORE_ENTRY_CODE; DBUG_RETURN(mysql_file_pwrite(global_ddl_log.file_id, buff, sizeof(buff), global_ddl_log.io_size * entry_pos + DDL_LOG_ENTRY_TYPE_POS, @@ -858,7 +858,7 @@ static bool ddl_log_increment_phase_no_lock(uint entry_pos) if (ddl_log_entry_phases[action] <= phase) { DBUG_ASSERT(phase == ddl_log_entry_phases[action]); - /* Same effect as setting DDL_IGNORE_LOG_ENTRY_CODE */ + /* Same effect as setting DDL_LOG_IGNORE_ENTRY_CODE */ phase= DDL_LOG_FINAL_PHASE; } file_entry_buf[DDL_LOG_PHASE_POS]= phase; @@ -1306,7 +1306,7 @@ static int ddl_log_execute_action(THD *thd, MEM_ROOT *mem_root, ddl_log_entry->from_name.str, ddl_log_entry->tmp_name.str)); - if (ddl_log_entry->entry_type == DDL_IGNORE_LOG_ENTRY_CODE || + if (ddl_log_entry->entry_type == DDL_LOG_IGNORE_ENTRY_CODE || ddl_log_entry->phase == DDL_LOG_FINAL_PHASE) DBUG_RETURN(FALSE); @@ -1421,7 +1421,7 @@ static int ddl_log_execute_action(THD *thd, MEM_ROOT *mem_root, (void) file->ha_rename_table(ddl_log_entry->tmp_name.str, ddl_log_entry->name.str); /* disable the entry and sync */ - file_entry_buf[DDL_LOG_ENTRY_TYPE_POS]= DDL_IGNORE_LOG_ENTRY_CODE; + file_entry_buf[DDL_LOG_ENTRY_TYPE_POS]= DDL_LOG_IGNORE_ENTRY_CODE; (void) write_ddl_log_file_entry(entry_pos); (void) ddl_log_sync_no_lock(); break; @@ -2400,7 +2400,7 @@ static bool ddl_log_execute_entry_no_lock(THD *thd, uint first_entry) break; } DBUG_ASSERT(ddl_log_entry.entry_type == DDL_LOG_ENTRY_CODE || - ddl_log_entry.entry_type == DDL_IGNORE_LOG_ENTRY_CODE); + ddl_log_entry.entry_type == DDL_LOG_IGNORE_ENTRY_CODE); if (ddl_log_execute_action(thd, &mem_root, &ddl_log_entry)) { @@ -2902,23 +2902,24 @@ void ddl_log_complete(DDL_LOG_STATE *state) This is called for failed rename table, create trigger or drop trigger. */ -void ddl_log_revert(THD *thd, DDL_LOG_STATE *state) +bool ddl_log_revert(THD *thd, DDL_LOG_STATE *state) { + bool res= 0; DBUG_ENTER("ddl_log_revert"); if (unlikely(!state->list)) - DBUG_VOID_RETURN; // ddl log not used + DBUG_RETURN(0); // ddl log not used mysql_mutex_lock(&LOCK_gdl); if (likely(state->execute_entry)) { - ddl_log_execute_entry_no_lock(thd, state->list->entry_pos); + res= ddl_log_execute_entry_no_lock(thd, state->list->entry_pos); ddl_log_disable_execute_entry(&state->execute_entry); } ddl_log_release_entries(state); mysql_mutex_unlock(&LOCK_gdl); state->list= 0; - DBUG_VOID_RETURN; + DBUG_RETURN(res); } @@ -3124,6 +3125,16 @@ bool ddl_log_drop_view_init(THD *thd, DDL_LOG_STATE *ddl_state, db, &empty_clex_str); } + +/** + Log DROP TABLE to the ddl log. + + This code does not call ddl_log_write() as we want the events to + be stored in call order instead of reverse order, which is the normal + case for all other events. + See also comment before ddl_log_drop_init(). +*/ + static bool ddl_log_drop(THD *thd, DDL_LOG_STATE *ddl_state, ddl_log_action_code action_code, uint phase, diff --git a/sql/ddl_log.h b/sql/ddl_log.h index 7033539963d..a2a6af76a77 100644 --- a/sql/ddl_log.h +++ b/sql/ddl_log.h @@ -34,13 +34,13 @@ enum ddl_log_entry_code DDL_LOG_ENTRY_CODE: An entry to be executed in a linked list from an execute log entry. - DDL_IGNORE_LOG_ENTRY_CODE: + DDL_LOG_IGNORE_ENTRY_CODE: An entry that is to be ignored */ DDL_LOG_UNKNOWN= 0, DDL_LOG_EXECUTE_CODE= 1, DDL_LOG_ENTRY_CODE= 2, - DDL_IGNORE_LOG_ENTRY_CODE= 3, + DDL_LOG_IGNORE_ENTRY_CODE= 3, DDL_LOG_ENTRY_CODE_LAST= 4 }; @@ -267,7 +267,7 @@ bool ddl_log_write_execute_entry(uint first_entry, bool ddl_log_disable_execute_entry(DDL_LOG_MEMORY_ENTRY **active_entry); void ddl_log_complete(DDL_LOG_STATE *ddl_log_state); -void ddl_log_revert(THD *thd, DDL_LOG_STATE *ddl_log_state); +bool ddl_log_revert(THD *thd, DDL_LOG_STATE *ddl_log_state); bool ddl_log_update_phase(DDL_LOG_STATE *entry, uchar phase); bool ddl_log_add_flag(DDL_LOG_STATE *entry, uint16 flag); diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index 81d6fedb4e3..379461cc32c 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -697,7 +697,7 @@ end: ddl_log_complete(&ddl_log_state); debug_crash_here("ddl_log_drop_before_delete_tmp"); /* delete any created log files */ - ddl_log_revert(thd, &ddl_log_state_tmp_file); + result|= ddl_log_revert(thd, &ddl_log_state_tmp_file); /* If we are under LOCK TABLES we should restore original state of meta-data locks. Otherwise all locks will be released along From 15e1fbc37d5a60967295dc0855c2ef5741856a6d Mon Sep 17 00:00:00 2001 From: Monty Date: Thu, 17 Jun 2021 19:21:35 +0300 Subject: [PATCH 138/251] Fixed flush table issue in MyISAM with CREATE ... SELECT When doing CREATE TABLE ... ENGINE=MyISAM SELECT ... the MyISAM table was not completely flushed at commit which gave some warnings about table not closed in the atomic test suite. Fixed by flushing the table in select_insert::prepare_eof(). --- storage/myisam/mi_extra.c | 1 + 1 file changed, 1 insertion(+) diff --git a/storage/myisam/mi_extra.c b/storage/myisam/mi_extra.c index 4f3326098f6..66238745a04 100644 --- a/storage/myisam/mi_extra.c +++ b/storage/myisam/mi_extra.c @@ -282,6 +282,7 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) mysql_mutex_unlock(&share->intern_lock); mysql_mutex_unlock(&THR_LOCK_myisam); break; + case HA_EXTRA_END_ALTER_COPY: case HA_EXTRA_FLUSH: if (!share->temporary) flush_key_blocks(share->key_cache, share->kfile, &share->dirty_part_map, From 93f5d40656e3faa6cac9fe66934f6d8f3aa15d98 Mon Sep 17 00:00:00 2001 From: Monty Date: Thu, 17 Jun 2021 20:15:24 +0300 Subject: [PATCH 139/251] Fixed debug_sync timeout in deadlock_drop_table The issue was that we sent two different signals to different threads after each other. The DEBUG_SYNC functionality cannot handle this (as the signal is stored in a global variable) and the first one can get lost. Fixed by using the same signal for both threads. --- .../r}/deadlock_drop_table.result | 3 +-- .../t}/deadlock_drop_table.test | 8 ++++++-- sql/backup.cc | 12 ++++++++++-- sql/debug_sync.cc | 9 +++++++++ sql/mysqld.cc | 2 ++ sql/mysqld.h | 2 ++ 6 files changed, 30 insertions(+), 6 deletions(-) rename mysql-test/suite/{mariabackup => stress/r}/deadlock_drop_table.result (89%) rename mysql-test/suite/{mariabackup => stress/t}/deadlock_drop_table.test (76%) diff --git a/mysql-test/suite/mariabackup/deadlock_drop_table.result b/mysql-test/suite/stress/r/deadlock_drop_table.result similarity index 89% rename from mysql-test/suite/mariabackup/deadlock_drop_table.result rename to mysql-test/suite/stress/r/deadlock_drop_table.result index 7e549157c81..326f694e8d9 100644 --- a/mysql-test/suite/mariabackup/deadlock_drop_table.result +++ b/mysql-test/suite/stress/r/deadlock_drop_table.result @@ -19,12 +19,11 @@ a b c 1 NULL NULL set debug_sync='now SIGNAL go'; set debug_sync='now WAIT_FOR parked2'; -set debug_sync='before_wait_for_refs SIGNAL waiting WAIT_FOR go3'; +set debug_sync='before_wait_for_refs SIGNAL waiting WAIT_FOR go2'; drop table t1;; connection con2; set debug_sync='now WAIT_FOR waiting'; set debug_sync='now SIGNAL go2'; -set debug_sync='now SIGNAL go3'; connection default; connection con1; connection default; diff --git a/mysql-test/suite/mariabackup/deadlock_drop_table.test b/mysql-test/suite/stress/t/deadlock_drop_table.test similarity index 76% rename from mysql-test/suite/mariabackup/deadlock_drop_table.test rename to mysql-test/suite/stress/t/deadlock_drop_table.test index 81350726b76..b49ca0b9fb7 100644 --- a/mysql-test/suite/mariabackup/deadlock_drop_table.test +++ b/mysql-test/suite/stress/t/deadlock_drop_table.test @@ -19,12 +19,16 @@ set debug_sync='now WAIT_FOR parked'; select * from t1; set debug_sync='now SIGNAL go'; set debug_sync='now WAIT_FOR parked2'; -set debug_sync='before_wait_for_refs SIGNAL waiting WAIT_FOR go3'; +set debug_sync='before_wait_for_refs SIGNAL waiting WAIT_FOR go2'; --send drop table t1; --connection con2 set debug_sync='now WAIT_FOR waiting'; set debug_sync='now SIGNAL go2'; -set debug_sync='now SIGNAL go3'; + +# Write out show processlist if the debug sync point times out +let $wait_condition= select count(*)=0 from information_schema.processlist where state like "%debug%"; +source include/wait_condition.inc; + --connection default --reap --connection con1 diff --git a/sql/backup.cc b/sql/backup.cc index 1b3007c5a00..5367a75b094 100644 --- a/sql/backup.cc +++ b/sql/backup.cc @@ -258,16 +258,19 @@ static bool backup_flush(THD *thd) static bool backup_block_ddl(THD *thd) { + PSI_stage_info org_stage; DBUG_ENTER("backup_block_ddl"); kill_delayed_threads(); mysql_ha_cleanup_no_free(thd); + thd->backup_stage(&org_stage); + THD_STAGE_INFO(thd, stage_waiting_for_flush); /* Wait until all non trans statements has ended */ if (thd->mdl_context.upgrade_shared_lock(backup_flush_ticket, MDL_BACKUP_WAIT_FLUSH, thd->variables.lock_wait_timeout)) - DBUG_RETURN(1); + goto err; /* Remove not used tables from the table share. Flush all changes to @@ -284,6 +287,7 @@ static bool backup_block_ddl(THD *thd) We didn't do this lock above, as we wanted DDL's to be executed while we wait for non transactional tables (which may take a while). */ + THD_STAGE_INFO(thd, stage_waiting_for_ddl); if (thd->mdl_context.upgrade_shared_lock(backup_flush_ticket, MDL_BACKUP_WAIT_DDL, thd->variables.lock_wait_timeout)) @@ -293,12 +297,16 @@ static bool backup_block_ddl(THD *thd) was called so that this function can be called again */ backup_flush_ticket->downgrade_lock(MDL_BACKUP_FLUSH); - DBUG_RETURN(1); + goto err; } /* There can't be anything more that needs to be logged to ddl log */ + THD_STAGE_INFO(thd, org_stage); stop_ddl_logging(); DBUG_RETURN(0); +err: + THD_STAGE_INFO(thd, org_stage); + DBUG_RETURN(1); } diff --git a/sql/debug_sync.cc b/sql/debug_sync.cc index 1fbb15592a4..debda4c8970 100644 --- a/sql/debug_sync.cc +++ b/sql/debug_sync.cc @@ -995,6 +995,15 @@ static char *debug_sync_number(ulong *number_p, char *actstrptr, The input string needs to be ASCII NUL ('\0') terminated. We split nul-terminated tokens in it without copy. + @note + The current implementation does not support two 'now SIGNAL xxx' commands + in a row for multiple threads as the first one can get lost while + the waiting threads are sleeping on mysql_cond_timedwait(). + One reason for this is that the signal name is stored in a global variable + that is overwritten. A better way would be to store all signals in + an array together with a 'time' when the signal was sent. This array + should be checked on broadcast. + @see the function comment of debug_sync_token() for more constraints for the string. */ diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 249dde9177c..698bcfff0f7 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -9146,6 +9146,8 @@ PSI_stage_info stage_slave_background_process_request= { 0, "Processing requests PSI_stage_info stage_slave_background_wait_request= { 0, "Waiting for requests", 0}; PSI_stage_info stage_waiting_for_deadlock_kill= { 0, "Waiting for parallel replication deadlock handling to complete", 0}; PSI_stage_info stage_starting= { 0, "starting", 0}; +PSI_stage_info stage_waiting_for_flush= { 0, "Waiting for non trans tables to be flushed", 0}; +PSI_stage_info stage_waiting_for_ddl= { 0, "Waiting for DDLs", 0}; PSI_memory_key key_memory_DATE_TIME_FORMAT; PSI_memory_key key_memory_DDL_LOG_MEMORY_ENTRY; diff --git a/sql/mysqld.h b/sql/mysqld.h index 5356fd967c7..a74c6ce8bda 100644 --- a/sql/mysqld.h +++ b/sql/mysqld.h @@ -639,7 +639,9 @@ extern PSI_stage_info stage_upgrading_lock; extern PSI_stage_info stage_user_lock; extern PSI_stage_info stage_user_sleep; extern PSI_stage_info stage_verifying_table; +extern PSI_stage_info stage_waiting_for_ddl; extern PSI_stage_info stage_waiting_for_delay_list; +extern PSI_stage_info stage_waiting_for_flush; extern PSI_stage_info stage_waiting_for_gtid_to_be_written_to_binary_log; extern PSI_stage_info stage_waiting_for_handler_insert; extern PSI_stage_info stage_waiting_for_handler_lock; From bad1440325ba2c96530408fe2fd6484fc1c7c290 Mon Sep 17 00:00:00 2001 From: Monty Date: Fri, 18 Jun 2021 13:16:51 +0300 Subject: [PATCH 140/251] Speed up of innodb_gis.update_root test 10x by adding BEGIN/COMMIT --- mysql-test/suite/innodb_gis/r/update_root.result | 4 ++++ mysql-test/suite/innodb_gis/t/update_root.test | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/mysql-test/suite/innodb_gis/r/update_root.result b/mysql-test/suite/innodb_gis/r/update_root.result index a39910818da..fe43fe79f2f 100644 --- a/mysql-test/suite/innodb_gis/r/update_root.result +++ b/mysql-test/suite/innodb_gis/r/update_root.result @@ -7,10 +7,14 @@ insert into t1 values (i, Point(i, i)); set i = i + 1; end while; end| +BEGIN; CALL insert_t1(70000); +COMMIT; +BEGIN; CALL insert_t1(90); CALL insert_t1(90); CALL insert_t1(83); +COMMIT; insert into t1 values (0, Point(0.9, 0.9)); check table t1; Table Op Msg_type Msg_text diff --git a/mysql-test/suite/innodb_gis/t/update_root.test b/mysql-test/suite/innodb_gis/t/update_root.test index c6d3ba60650..9fd2b36d311 100644 --- a/mysql-test/suite/innodb_gis/t/update_root.test +++ b/mysql-test/suite/innodb_gis/t/update_root.test @@ -26,11 +26,15 @@ end| delimiter ;| # Test level 3 rtree. +BEGIN; CALL insert_t1(70000); +COMMIT; +BEGIN; CALL insert_t1(90); CALL insert_t1(90); CALL insert_t1(83); +COMMIT; insert into t1 values (0, Point(0.9, 0.9)); From a4f485917e4ec18a00280fad3aca87856a62aa70 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sat, 19 Jun 2021 13:45:14 +0200 Subject: [PATCH 141/251] spider tests aren't big in 10.4 see also a5f6eca50db --- storage/spider/mysql-test/spider/feature/suite.pm | 1 - storage/spider/mysql-test/spider/regression/e1121/suite.pm | 1 - storage/spider/mysql-test/spider/regression/e112122/suite.pm | 1 - 3 files changed, 3 deletions(-) diff --git a/storage/spider/mysql-test/spider/feature/suite.pm b/storage/spider/mysql-test/spider/feature/suite.pm index f106147deb6..171fa6c4f01 100644 --- a/storage/spider/mysql-test/spider/feature/suite.pm +++ b/storage/spider/mysql-test/spider/feature/suite.pm @@ -4,7 +4,6 @@ package My::Suite::Spider; return "No Spider engine" unless $ENV{HA_SPIDER_SO}; return "Not run for embedded server" if $::opt_embedded_server; -return "Test needs --big-test" unless $::opt_big_test; sub is_default { 1 } diff --git a/storage/spider/mysql-test/spider/regression/e1121/suite.pm b/storage/spider/mysql-test/spider/regression/e1121/suite.pm index f106147deb6..171fa6c4f01 100644 --- a/storage/spider/mysql-test/spider/regression/e1121/suite.pm +++ b/storage/spider/mysql-test/spider/regression/e1121/suite.pm @@ -4,7 +4,6 @@ package My::Suite::Spider; return "No Spider engine" unless $ENV{HA_SPIDER_SO}; return "Not run for embedded server" if $::opt_embedded_server; -return "Test needs --big-test" unless $::opt_big_test; sub is_default { 1 } diff --git a/storage/spider/mysql-test/spider/regression/e112122/suite.pm b/storage/spider/mysql-test/spider/regression/e112122/suite.pm index f106147deb6..171fa6c4f01 100644 --- a/storage/spider/mysql-test/spider/regression/e112122/suite.pm +++ b/storage/spider/mysql-test/spider/regression/e112122/suite.pm @@ -4,7 +4,6 @@ package My::Suite::Spider; return "No Spider engine" unless $ENV{HA_SPIDER_SO}; return "Not run for embedded server" if $::opt_embedded_server; -return "Test needs --big-test" unless $::opt_big_test; sub is_default { 1 } From 690ae1de45943b549ca792862d6de03fdfb5f923 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sat, 19 Jun 2021 13:45:39 +0200 Subject: [PATCH 142/251] fix spider tests for --ps in 10.4 see also 068246c006b --- .../spider/regression/e1121/t/direct_join_by_pkey_key.test | 4 ++++ .../spider/regression/e1121/t/direct_join_by_pkey_pkey.test | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/storage/spider/mysql-test/spider/regression/e1121/t/direct_join_by_pkey_key.test b/storage/spider/mysql-test/spider/regression/e1121/t/direct_join_by_pkey_key.test index e915a21fd4a..39b5b5535bb 100644 --- a/storage/spider/mysql-test/spider/regression/e1121/t/direct_join_by_pkey_key.test +++ b/storage/spider/mysql-test/spider/regression/e1121/t/direct_join_by_pkey_key.test @@ -21,8 +21,10 @@ USE auto_test_remote; --connection child2_1 --disable_query_log +--disable_ps_protocol echo CHILD2_1_CREATE_TABLES; eval $CHILD2_1_CREATE_TABLES; +--enable_ps_protocol --enable_query_log TRUNCATE TABLE mysql.general_log; @@ -62,8 +64,10 @@ TRUNCATE TABLE mysql.general_log; SELECT a.val, a.akey FROM tbl_a a, tbl_b b WHERE a.akey = b.akey AND b.bkey = 5; --connection child2_1 +--disable_ps_protocol eval $CHILD2_1_SELECT_ARGUMENT1; eval $CHILD2_1_SELECT_TABLES; +--enable_ps_protocol --echo --echo deinit diff --git a/storage/spider/mysql-test/spider/regression/e1121/t/direct_join_by_pkey_pkey.test b/storage/spider/mysql-test/spider/regression/e1121/t/direct_join_by_pkey_pkey.test index dcd6e3a4535..652f7d15177 100644 --- a/storage/spider/mysql-test/spider/regression/e1121/t/direct_join_by_pkey_pkey.test +++ b/storage/spider/mysql-test/spider/regression/e1121/t/direct_join_by_pkey_pkey.test @@ -22,7 +22,9 @@ USE auto_test_remote; --connection child2_1 --disable_query_log echo CHILD2_1_CREATE_TABLES; +--disable_ps_protocol eval $CHILD2_1_CREATE_TABLES; +--enable_ps_protocol --enable_query_log TRUNCATE TABLE mysql.general_log; @@ -62,8 +64,10 @@ TRUNCATE TABLE mysql.general_log; SELECT a.val, a.akey FROM tbl_a a, tbl_b b WHERE a.akey = b.akey AND b.bkey = 5; --connection child2_1 +--disable_ps_protocol eval $CHILD2_1_SELECT_ARGUMENT1; eval $CHILD2_1_SELECT_TABLES; +--enable_ps_protocol --echo --echo deinit From c3a1ba0fd99e77c1e24e2668b11c44572abbea6b Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sat, 19 Jun 2021 14:05:54 +0200 Subject: [PATCH 143/251] fix spider tests for --ps in 10.5 see also 068246c006b and 690ae1de459 --- .../mysql-test/spider/bugfix/t/delete_with_float_column.inc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/storage/spider/mysql-test/spider/bugfix/t/delete_with_float_column.inc b/storage/spider/mysql-test/spider/bugfix/t/delete_with_float_column.inc index 794ebedf355..349808824e7 100644 --- a/storage/spider/mysql-test/spider/bugfix/t/delete_with_float_column.inc +++ b/storage/spider/mysql-test/spider/bugfix/t/delete_with_float_column.inc @@ -21,8 +21,10 @@ USE auto_test_remote; --connection child2_1 --disable_query_log +--disable_ps_protocol echo CHILD2_1_CREATE_TABLES; eval $CHILD2_1_CREATE_TABLES; +--enable_ps_protocol --enable_query_log TRUNCATE TABLE mysql.general_log; From 773a07b65517327add6348c045cee14bdf489fe0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 21 Jun 2021 08:18:34 +0300 Subject: [PATCH 144/251] Remove Travis CI status Builds on travis-ci.org ceased on 2021-06-15. --- README.md | 8 -------- 1 file changed, 8 deletions(-) diff --git a/README.md b/README.md index 03e71af7652..d208d171377 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ Code status: ------------ -* [![Travis CI status](https://secure.travis-ci.org/MariaDB/server.png?branch=10.2)](https://travis-ci.org/MariaDB/server) travis-ci.org (10.2 branch) * [![Appveyor CI status](https://ci.appveyor.com/api/projects/status/4u6pexmtpuf8jq66?svg=true)](https://ci.appveyor.com/project/rasmushoj/server) ci.appveyor.com ## MariaDB: drop-in replacement for MySQL @@ -76,10 +75,3 @@ https://bugs.mysql.com The code for MariaDB, including all revision history, can be found at: https://github.com/MariaDB/server - -*************************************************************************** - -Code status: ------------- - -* [![tests status](https://secure.travis-ci.org/MariaDB/server.png?branch=10.2)](https://travis-ci.org/MariaDB/server) travis-ci.org (10.2 branch) From 241d30d3faac0fbbcb7bcfad3dcc118bb03eceb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 21 Jun 2021 12:09:00 +0300 Subject: [PATCH 145/251] After-merge fixes for MDEV-14180 --- .../suite/encryption/r/innodb-first-page-read.result | 2 ++ .../suite/encryption/r/innodb-key-rotation-disable.result | 2 ++ mysql-test/suite/encryption/t/innodb-first-page-read.test | 8 +++++++- storage/innobase/fil/fil0fil.cc | 8 +++++--- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/mysql-test/suite/encryption/r/innodb-first-page-read.result b/mysql-test/suite/encryption/r/innodb-first-page-read.result index 29253885e83..4c2a2116669 100644 --- a/mysql-test/suite/encryption/r/innodb-first-page-read.result +++ b/mysql-test/suite/encryption/r/innodb-first-page-read.result @@ -66,6 +66,8 @@ VARIABLE_VALUE <= 29 1 set global innodb_encrypt_tables=OFF; # wait until tables are decrypted +SET GLOBAL innodb_max_dirty_pages_pct=0.0; +SET GLOBAL innodb_max_dirty_pages_pct_lwm=0.0; # result should be actual number of tables except remote tables could be read twice # i.e. < 23 + 3*2 = 29 SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'innodb_pages0_read'; diff --git a/mysql-test/suite/encryption/r/innodb-key-rotation-disable.result b/mysql-test/suite/encryption/r/innodb-key-rotation-disable.result index 7d0267d5057..f27f5517e09 100644 --- a/mysql-test/suite/encryption/r/innodb-key-rotation-disable.result +++ b/mysql-test/suite/encryption/r/innodb-key-rotation-disable.result @@ -1,3 +1,5 @@ +SET GLOBAL innodb_file_per_table = ON; +set global innodb_compression_algorithm = 1; create database enctests; use enctests; create table t1(a int not null primary key, b char(200)) engine=innodb; diff --git a/mysql-test/suite/encryption/t/innodb-first-page-read.test b/mysql-test/suite/encryption/t/innodb-first-page-read.test index c86e16c52b8..4e6eeb25080 100644 --- a/mysql-test/suite/encryption/t/innodb-first-page-read.test +++ b/mysql-test/suite/encryption/t/innodb-first-page-read.test @@ -77,7 +77,13 @@ SELECT VARIABLE_VALUE <= 29 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABL set global innodb_encrypt_tables=OFF; --echo # wait until tables are decrypted ---let $wait_condition=SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0 +SET GLOBAL innodb_max_dirty_pages_pct=0.0; +SET GLOBAL innodb_max_dirty_pages_pct_lwm=0.0; + +let $wait_condition = +SELECT variable_value = 0 +FROM information_schema.global_status +WHERE variable_name = 'INNODB_BUFFER_POOL_PAGES_DIRTY'; --source include/wait_condition.inc --echo # result should be actual number of tables except remote tables could be read twice diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index b045f8b16b8..9f9ed51a07f 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -1421,10 +1421,12 @@ fil_space_create( encryption threads. */ fil_system.default_encrypt_tables.push_back(*space); space->is_in_default_encrypt = true; - mutex_exit(&fil_system.mutex); + } + + mutex_exit(&fil_system.mutex); + + if (rotate && srv_n_fil_crypt_threads_started) { os_event_set(fil_crypt_threads_event); - } else { - mutex_exit(&fil_system.mutex); } return(space); From e46f76c9749d7758765ba274a212cfc2dcf3eeb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 21 Jun 2021 12:34:07 +0300 Subject: [PATCH 146/251] MDEV-15912: Remove traces of insert_undo Let us simply refuse an upgrade from earlier versions if the upgrade procedure was not followed. This simplifies the purge, commit, and rollback of transactions. Before upgrading to MariaDB 10.3 or later, a clean shutdown of the server (with innodb_fast_shutdown=1 or 0) is necessary, to ensure that any incomplete transactions are rolled back. The undo log format was changed in MDEV-12288. There is only one persistent undo log for each transaction. --- extra/innochecksum.cc | 39 +--- .../suite/innodb_zip/r/innochecksum_3.result | 8 +- storage/innobase/include/trx0purge.h | 34 ++- storage/innobase/include/trx0rseg.h | 39 ++-- storage/innobase/include/trx0trx.h | 13 +- storage/innobase/include/trx0undo.h | 23 +- storage/innobase/lock/lock0lock.cc | 2 +- storage/innobase/srv/srv0start.cc | 21 +- storage/innobase/trx/trx0purge.cc | 63 +++--- storage/innobase/trx/trx0roll.cc | 40 +--- storage/innobase/trx/trx0rseg.cc | 78 +++---- storage/innobase/trx/trx0trx.cc | 71 ++----- storage/innobase/trx/trx0undo.cc | 197 ++++++++---------- 13 files changed, 248 insertions(+), 380 deletions(-) diff --git a/extra/innochecksum.cc b/extra/innochecksum.cc index 73f62c26dd2..583a0db04f9 100644 --- a/extra/innochecksum.cc +++ b/extra/innochecksum.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. - Copyright (c) 2014, 2019, MariaDB Corporation. + Copyright (c) 2014, 2021, 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 @@ -138,13 +138,10 @@ static ulong write_check; struct innodb_page_type { int n_undo_state_active; int n_undo_state_cached; - int n_undo_state_to_free; int n_undo_state_to_purge; int n_undo_state_prepared; int n_undo_state_other; - int n_undo_insert; - int n_undo_update; - int n_undo_other; + int n_undo; int n_fil_page_index; int n_fil_page_undo_log; int n_fil_page_inode; @@ -955,21 +952,7 @@ parse_page( fprintf(file, "#::%llu\t\t|\t\tUndo log page\t\t\t|", cur_page_num); } - if (undo_page_type == TRX_UNDO_INSERT) { - page_type.n_undo_insert++; - if (page_type_dump) { - fprintf(file, "\t%s", - "Insert Undo log page"); - } - - } else if (undo_page_type == TRX_UNDO_UPDATE) { - page_type.n_undo_update++; - if (page_type_dump) { - fprintf(file, "\t%s", - "Update undo log page"); - } - } - + page_type.n_undo++; undo_page_type = mach_read_from_2(page + TRX_UNDO_SEG_HDR + TRX_UNDO_STATE); switch (undo_page_type) { @@ -989,14 +972,6 @@ parse_page( } break; - case TRX_UNDO_TO_FREE: - page_type.n_undo_state_to_free++; - if (page_type_dump) { - fprintf(file, ", %s", "Insert undo " - "segment that can be freed"); - } - break; - case TRX_UNDO_TO_PURGE: page_type.n_undo_state_to_purge++; if (page_type_dump) { @@ -1220,15 +1195,11 @@ print_summary( fprintf(fil_out, "\n===============================================\n"); fprintf(fil_out, "Additional information:\n"); - fprintf(fil_out, "Undo page type: %d insert, %d update, %d other\n", - page_type.n_undo_insert, - page_type.n_undo_update, - page_type.n_undo_other); - fprintf(fil_out, "Undo page state: %d active, %d cached, %d to_free, %d" + fprintf(fil_out, "Undo page type: %d\n", page_type.n_undo); + fprintf(fil_out, "Undo page state: %d active, %d cached, %d" " to_purge, %d prepared, %d other\n", page_type.n_undo_state_active, page_type.n_undo_state_cached, - page_type.n_undo_state_to_free, page_type.n_undo_state_to_purge, page_type.n_undo_state_prepared, page_type.n_undo_state_other); diff --git a/mysql-test/suite/innodb_zip/r/innochecksum_3.result b/mysql-test/suite/innodb_zip/r/innochecksum_3.result index aaab68b3df9..830888e6b8a 100644 --- a/mysql-test/suite/innodb_zip/r/innochecksum_3.result +++ b/mysql-test/suite/innodb_zip/r/innochecksum_3.result @@ -109,8 +109,8 @@ File::tab#.ibd =============================================== Additional information: -Undo page type: # insert, # update, # other -Undo page state: # active, # cached, # to_free, # to_purge, # prepared, # other +Undo page type: # +Undo page state: # active, # cached, # to_purge, # prepared, # other index_id #pages #leaf_pages #recs_per_page #bytes_per_page # # # # # # # # # # @@ -144,8 +144,8 @@ File::tab#.ibd =============================================== Additional information: -Undo page type: # insert, # update, # other -Undo page state: # active, # cached, # to_free, # to_purge, # prepared, # other +Undo page type: # +Undo page state: # active, # cached, # to_purge, # prepared, # other index_id #pages #leaf_pages #recs_per_page #bytes_per_page # # # # # # # # # # diff --git a/storage/innobase/include/trx0purge.h b/storage/innobase/include/trx0purge.h index 4bc5aded341..f45bd1410f5 100644 --- a/storage/innobase/include/trx0purge.h +++ b/storage/innobase/include/trx0purge.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2018, MariaDB Corporation. +Copyright (c) 2017, 2021, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -78,20 +78,16 @@ public: typedef trx_rsegs_t::iterator iterator; typedef trx_rsegs_t::const_iterator const_iterator; - /** Default constructor */ - TrxUndoRsegs() {} + TrxUndoRsegs() : trx_no(0), m_rsegs() {} /** Constructor */ TrxUndoRsegs(trx_rseg_t& rseg) - : m_commit(rseg.last_commit), m_rsegs(1, &rseg) {} + : trx_no(rseg.last_trx_no()), m_rsegs(1, &rseg) {} /** Constructor */ TrxUndoRsegs(trx_id_t trx_no, trx_rseg_t& rseg) - : m_commit(trx_no << 1), m_rsegs(1, &rseg) {} - - /** @return the transaction commit identifier */ - trx_id_t trx_no() const { return m_commit >> 1; } + : trx_no(trx_no), m_rsegs(1, &rseg) {} bool operator!=(const TrxUndoRsegs& other) const - { return m_commit != other.m_commit; } + { return trx_no != other.trx_no; } bool empty() const { return m_rsegs.empty(); } void erase(iterator& it) { m_rsegs.erase(it); } iterator begin() { return(m_rsegs.begin()); } @@ -105,14 +101,14 @@ public: @return true if elem1 > elem2 else false.*/ bool operator()(const TrxUndoRsegs& lhs, const TrxUndoRsegs& rhs) { - return(lhs.m_commit > rhs.m_commit); + return(lhs.trx_no > rhs.trx_no); } + /** Copy of trx_rseg_t::last_trx_no() */ + trx_id_t trx_no; private: - /** Copy trx_rseg_t::last_commit */ - trx_id_t m_commit; /** Rollback segments of a transaction, scheduled for purge. */ - trx_rsegs_t m_rsegs; + trx_rsegs_t m_rsegs; }; typedef std::priority_queue< @@ -370,17 +366,13 @@ public: { bool operator<=(const iterator& other) const { - if (commit < other.commit) return true; - if (commit > other.commit) return false; + if (trx_no < other.trx_no) return true; + if (trx_no > other.trx_no) return false; return undo_no <= other.undo_no; } - /** @return the commit number of the transaction */ - trx_id_t trx_no() const { return commit >> 1; } - void reset_trx_no(trx_id_t trx_no) { commit = trx_no << 1; } - - /** 2 * trx_t::no + old_insert of the committed transaction */ - trx_id_t commit; + /** trx_t::no of the committed transaction */ + trx_id_t trx_no; /** The record number within the committed transaction's undo log, increasing, purged from from 0 onwards */ undo_no_t undo_no; diff --git a/storage/innobase/include/trx0rseg.h b/storage/innobase/include/trx0rseg.h index d4fdb19a988..687c6fa0e97 100644 --- a/storage/innobase/include/trx0rseg.h +++ b/storage/innobase/include/trx0rseg.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2019, MariaDB Corporation. +Copyright (c) 2017, 2021, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -82,9 +82,8 @@ trx_rseg_header_create( buf_block_t* sys_header, mtr_t* mtr); -/** Initialize the rollback segments in memory at database startup. */ -void -trx_rseg_array_init(); +/** Initialize or recover the rollback segments at startup. */ +dberr_t trx_rseg_array_init(); /** Free a rollback segment in memory. */ void @@ -147,21 +146,13 @@ struct trx_rseg_t { /** List of undo log segments cached for fast reuse */ UT_LIST_BASE_NODE_T(trx_undo_t) undo_cached; - /** List of recovered old insert_undo logs of incomplete - transactions (to roll back or XA COMMIT & purge) */ - UT_LIST_BASE_NODE_T(trx_undo_t) old_insert_list; - /*--------------------------------------------------------*/ - /** Page number of the last not yet purged log header in the history - list; FIL_NULL if all list purged */ - ulint last_page_no; + /** Last not yet purged undo log header; FIL_NULL if all purged */ + uint32_t last_page_no; - /** Byte offset of the last not yet purged log header */ - ulint last_offset; - - /** trx_t::no * 2 + old_insert of the last not yet purged log */ - trx_id_t last_commit; + /** trx_t::no | last_offset << 48 */ + uint64_t last_commit_and_offset; /** Whether the log segment needs purge */ bool needs_purge; @@ -173,13 +164,17 @@ struct trx_rseg_t { UNDO-tablespace marked for truncate. */ bool skip_allocation; - /** @return the commit ID of the last committed transaction */ - trx_id_t last_trx_no() const { return last_commit >> 1; } + /** @return the commit ID of the last committed transaction */ + trx_id_t last_trx_no() const + { return last_commit_and_offset & ((1ULL << 48) - 1); } + /** @return header offset of the last committed transaction */ + uint16_t last_offset() const + { return static_cast(last_commit_and_offset >> 48); } - void set_last_trx_no(trx_id_t trx_no, bool is_update) - { - last_commit = trx_no << 1 | trx_id_t(is_update); - } + void set_last_commit(ulint last_offset, trx_id_t trx_no) + { + last_commit_and_offset= static_cast(last_offset) << 48 | trx_no; + } /** @return whether the rollback segment is persistent */ bool is_persistent() const diff --git a/storage/innobase/include/trx0trx.h b/storage/innobase/include/trx0trx.h index 7cd11bf5496..b4ed45f3565 100644 --- a/storage/innobase/include/trx0trx.h +++ b/storage/innobase/include/trx0trx.h @@ -79,7 +79,7 @@ void trx_free_at_shutdown(trx_t *trx); void trx_disconnect_prepared(trx_t *trx); /** Initialize (resurrect) transactions at startup. */ -void trx_lists_init_at_db_start(); +dberr_t trx_lists_init_at_db_start(); /*************************************************************//** Starts the transaction if it is not yet started. */ @@ -698,10 +698,6 @@ struct trx_undo_ptr_t { yet */ trx_undo_t* undo; /*!< pointer to the undo log, or NULL if nothing logged yet */ - trx_undo_t* old_insert; /*!< pointer to recovered - insert undo log, or NULL if no - INSERT transactions were - recovered from old-format undo logs */ }; /** An instance of temporary rollback segment. */ @@ -1055,13 +1051,6 @@ public: return(has_logged_persistent() || rsegs.m_noredo.undo); } - /** @return whether any undo log has been generated or - recovered */ - bool has_logged_or_recovered() const - { - return(has_logged() || rsegs.m_redo.old_insert); - } - /** @return rollback segment for modifying temporary tables */ trx_rseg_t* get_temp_rseg() { diff --git a/storage/innobase/include/trx0undo.h b/storage/innobase/include/trx0undo.h index 22420f111b5..b0b7ce2941f 100644 --- a/storage/innobase/include/trx0undo.h +++ b/storage/innobase/include/trx0undo.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2020, MariaDB Corporation. +Copyright (c) 2017, 2021, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -253,13 +253,11 @@ trx_undo_set_state_at_prepare( bool rollback, mtr_t* mtr); -/** Free an old insert or temporary undo log after commit or rollback. +/** Free temporary undo log after commit or rollback. The information is not needed after a commit or rollback, therefore the data can be discarded. -@param[in,out] undo undo log -@param[in] is_temp whether this is temporary undo log */ -void -trx_undo_commit_cleanup(trx_undo_t* undo, bool is_temp); +@param undo temporary undo log */ +void trx_undo_commit_cleanup(trx_undo_t *undo); /** At shutdown, frees the undo logs of a transaction. */ void @@ -302,10 +300,11 @@ trx_undo_parse_page_header( @param[in] id rollback segment slot @param[in] page_no undo log segment page number @param[in,out] max_trx_id the largest observed transaction ID -@return size of the undo log in pages */ -ulint -trx_undo_mem_create_at_db_start(trx_rseg_t* rseg, ulint id, ulint page_no, - trx_id_t& max_trx_id); +@return the undo log +@retval nullptr on error */ +trx_undo_t * +trx_undo_mem_create_at_db_start(trx_rseg_t *rseg, ulint id, uint32_t page_no, + trx_id_t &max_trx_id); #endif /* !UNIV_INNOCHECKSUM */ @@ -319,7 +318,6 @@ trx_undo_mem_create_at_db_start(trx_rseg_t* rseg, ulint id, ulint page_no, #define TRX_UNDO_ACTIVE 1 /* contains an undo log of an active transaction */ #define TRX_UNDO_CACHED 2 /* cached for quick reuse */ -#define TRX_UNDO_TO_FREE 3 /* insert undo segment can be freed */ #define TRX_UNDO_TO_PURGE 4 /* update undo segment will not be reused: it can be freed in purge when all undo data in it is removed */ @@ -383,7 +381,8 @@ struct trx_undo_t { /** Transaction undo log page header offsets */ /* @{ */ #define TRX_UNDO_PAGE_TYPE 0 /*!< unused; 0 (before MariaDB 10.3.1: - TRX_UNDO_INSERT or TRX_UNDO_UPDATE) */ + 1=TRX_UNDO_INSERT or + 2=TRX_UNDO_UPDATE) */ #define TRX_UNDO_PAGE_START 2 /*!< Byte offset where the undo log records for the LATEST transaction start on this page (remember that diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc index b3086842624..c584de0fa5d 100644 --- a/storage/innobase/lock/lock0lock.cc +++ b/storage/innobase/lock/lock0lock.cc @@ -4584,7 +4584,7 @@ lock_print_info_summary( "Purge done for trx's n:o < " TRX_ID_FMT " undo n:o < " TRX_ID_FMT " state: %s\n" "History list length %u\n", - purge_sys.tail.trx_no(), + purge_sys.tail.trx_no, purge_sys.tail.undo_no, purge_sys.enabled() ? (purge_sys.running() ? "running" diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc index 7314fd60cd6..7d5679e889e 100644 --- a/storage/innobase/srv/srv0start.cc +++ b/storage/innobase/srv/srv0start.cc @@ -1404,6 +1404,11 @@ dberr_t srv_start(bool create_new_db) || is_mariabackup_restore_or_export()); + if (srv_force_recovery) { + ib::info() << "!!! innodb_force_recovery is set to " + << srv_force_recovery << " !!!"; + } + if (srv_force_recovery == SRV_FORCE_NO_LOG_REDO) { srv_read_only_mode = true; } @@ -1922,7 +1927,11 @@ files_checked: All the remaining rollback segments will be created later, after the double write buffer has been created. */ trx_sys_create_sys_pages(); - trx_lists_init_at_db_start(); + err = trx_lists_init_at_db_start(); + + if (err != DB_SUCCESS) { + return(srv_init_abort(err)); + } err = dict_create(); @@ -1986,7 +1995,10 @@ files_checked: case SRV_OPERATION_RESTORE: /* This must precede recv_apply_hashed_log_recs(true). */ - trx_lists_init_at_db_start(); + err = trx_lists_init_at_db_start(); + if (err != DB_SUCCESS) { + return srv_init_abort(err); + } break; case SRV_OPERATION_RESTORE_DELTA: case SRV_OPERATION_BACKUP: @@ -2453,11 +2465,6 @@ skip_monitors: << "; transaction id " << trx_sys.get_max_trx_id(); } - if (srv_force_recovery > 0) { - ib::info() << "!!! innodb_force_recovery is set to " - << srv_force_recovery << " !!!"; - } - if (srv_force_recovery == 0) { /* In the insert buffer we may have even bigger tablespace id's, because we may have dropped those tablespaces, but diff --git a/storage/innobase/trx/trx0purge.cc b/storage/innobase/trx/trx0purge.cc index 02a524d6850..59d60d204d8 100644 --- a/storage/innobase/trx/trx0purge.cc +++ b/storage/innobase/trx/trx0purge.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2020, MariaDB Corporation. +Copyright (c) 2017, 2021, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -87,7 +87,7 @@ inline bool TrxUndoRsegsIterator::set_next() number shouldn't increase. Undo the increment of expected commit done by caller assuming rollback segments from given transaction are done. */ - purge_sys.tail.commit = (*m_iter)->last_commit; + purge_sys.tail.trx_no = (*m_iter)->last_trx_no(); } else if (!purge_sys.purge_queue.empty()) { m_rsegs = purge_sys.purge_queue.top(); purge_sys.purge_queue.pop(); @@ -108,17 +108,17 @@ inline bool TrxUndoRsegsIterator::set_next() mutex_enter(&purge_sys.rseg->mutex); ut_a(purge_sys.rseg->last_page_no != FIL_NULL); - ut_ad(purge_sys.rseg->last_trx_no() == m_rsegs.trx_no()); + ut_ad(purge_sys.rseg->last_trx_no() == m_rsegs.trx_no); /* We assume in purge of externally stored fields that space id is in the range of UNDO tablespace space ids */ ut_ad(purge_sys.rseg->space->id == TRX_SYS_SPACE || srv_is_undo_tablespace(purge_sys.rseg->space->id)); - ut_a(purge_sys.tail.commit <= purge_sys.rseg->last_commit); + ut_a(purge_sys.tail.trx_no <= purge_sys.rseg->last_trx_no()); - purge_sys.tail.commit = purge_sys.rseg->last_commit; - purge_sys.hdr_offset = purge_sys.rseg->last_offset; + purge_sys.tail.trx_no = purge_sys.rseg->last_trx_no(); + purge_sys.hdr_offset = purge_sys.rseg->last_offset(); purge_sys.hdr_page_no = purge_sys.rseg->last_page_no; mutex_exit(&purge_sys.rseg->mutex); @@ -209,8 +209,7 @@ trx_purge_add_undo_to_history(const trx_t* trx, trx_undo_t*& undo, mtr_t* mtr) { DBUG_PRINT("trx", ("commit(" TRX_ID_FMT "," TRX_ID_FMT ")", trx->id, trx->no)); - ut_ad(undo == trx->rsegs.m_redo.undo - || undo == trx->rsegs.m_redo.old_insert); + ut_ad(undo == trx->rsegs.m_redo.undo); trx_rseg_t* rseg = trx->rsegs.m_redo.rseg; ut_ad(undo->rseg == rseg); trx_rsegf_t* rseg_header = trx_rsegf_get( @@ -302,9 +301,8 @@ trx_purge_add_undo_to_history(const trx_t* trx, trx_undo_t*& undo, mtr_t* mtr) } if (rseg->last_page_no == FIL_NULL) { - rseg->last_page_no = undo->hdr_page_no; - rseg->last_offset = undo->hdr_offset; - rseg->set_last_trx_no(trx->no, undo == trx->rsegs.m_redo.undo); + rseg->last_page_no = static_cast(undo->hdr_page_no); + rseg->set_last_commit(undo->hdr_offset, trx->no); rseg->needs_purge = true; } @@ -460,8 +458,8 @@ func_exit: undo_trx_no = mach_read_from_8(log_hdr + TRX_UNDO_TRX_NO); - if (undo_trx_no >= limit.trx_no()) { - if (undo_trx_no == limit.trx_no()) { + if (undo_trx_no >= limit.trx_no) { + if (undo_trx_no == limit.trx_no) { trx_undo_truncate_start( &rseg, hdr_addr.page, hdr_addr.boffset, limit.undo_no); @@ -884,7 +882,7 @@ trx_purge_initiate_truncate( undo != NULL && all_free; undo = UT_LIST_GET_NEXT(undo_list, undo)) { - if (limit.trx_no() < undo->trx_id) { + if (limit.trx_no < undo->trx_id) { all_free = false; } else { cached_undo_size += undo->size; @@ -986,7 +984,6 @@ not_found: /* Before re-initialization ensure that we free the existing structure. There can't be any active transactions. */ ut_a(UT_LIST_GET_LEN(rseg->undo_list) == 0); - ut_a(UT_LIST_GET_LEN(rseg->old_insert_list) == 0); trx_undo_t* next_undo; @@ -1002,7 +999,6 @@ not_found: UT_LIST_INIT(rseg->undo_list, &trx_undo_t::undo_list); UT_LIST_INIT(rseg->undo_cached, &trx_undo_t::undo_list); - UT_LIST_INIT(rseg->old_insert_list, &trx_undo_t::undo_list); /* These were written by trx_rseg_header_create(). */ ut_ad(!mach_read_from_4(TRX_RSEG + TRX_RSEG_FORMAT @@ -1014,8 +1010,7 @@ not_found: rseg->curr_size = 1; rseg->trx_ref_count = 0; rseg->last_page_no = FIL_NULL; - rseg->last_offset = 0; - rseg->last_commit = 0; + rseg->last_commit_and_offset = 0; rseg->needs_purge = false; } @@ -1076,12 +1071,12 @@ function is called, the caller must not have any latches on undo log pages! static void trx_purge_truncate_history() { ut_ad(purge_sys.head <= purge_sys.tail); - purge_sys_t::iterator& head = purge_sys.head.commit + purge_sys_t::iterator& head = purge_sys.head.trx_no ? purge_sys.head : purge_sys.tail; - if (head.trx_no() >= purge_sys.view.low_limit_no()) { + if (head.trx_no >= purge_sys.view.low_limit_no()) { /* This is sometimes necessary. TODO: find out why. */ - head.reset_trx_no(purge_sys.view.low_limit_no()); + head.trx_no = purge_sys.view.low_limit_no(); head.undo_no = 0; } @@ -1109,7 +1104,6 @@ static void trx_purge_rseg_get_next_history_log( handled */ { page_t* undo_page; - trx_ulogf_t* log_hdr; fil_addr_t prev_log_addr; trx_id_t trx_no; mtr_t mtr; @@ -1118,7 +1112,7 @@ static void trx_purge_rseg_get_next_history_log( ut_a(purge_sys.rseg->last_page_no != FIL_NULL); - purge_sys.tail.commit = purge_sys.rseg->last_commit + 1; + purge_sys.tail.trx_no = purge_sys.rseg->last_trx_no() + 1; purge_sys.tail.undo_no = 0; purge_sys.next_stored = false; @@ -1128,7 +1122,7 @@ static void trx_purge_rseg_get_next_history_log( page_id_t(purge_sys.rseg->space->id, purge_sys.rseg->last_page_no), &mtr); - log_hdr = undo_page + purge_sys.rseg->last_offset; + const trx_ulogf_t* log_hdr = undo_page + purge_sys.rseg->last_offset(); /* Increase the purge page count by one for every handled log */ @@ -1160,17 +1154,16 @@ static void trx_purge_rseg_get_next_history_log( + prev_log_addr.boffset; trx_no = mach_read_from_8(log_hdr + TRX_UNDO_TRX_NO); - unsigned purge = mach_read_from_2(log_hdr + TRX_UNDO_NEEDS_PURGE); - ut_ad(purge <= 1); + ut_ad(mach_read_from_2(log_hdr + TRX_UNDO_NEEDS_PURGE) <= 1); mtr_commit(&mtr); mutex_enter(&purge_sys.rseg->mutex); - purge_sys.rseg->last_page_no = prev_log_addr.page; - purge_sys.rseg->last_offset = prev_log_addr.boffset; - purge_sys.rseg->set_last_trx_no(trx_no, purge != 0); - purge_sys.rseg->needs_purge = purge != 0; + purge_sys.rseg->last_page_no = static_cast( + prev_log_addr.page); + purge_sys.rseg->set_last_commit(prev_log_addr.boffset, trx_no); + purge_sys.rseg->needs_purge = log_hdr[TRX_UNDO_NEEDS_PURGE + 1] != 0; /* Purge can also produce events, however these are already ordered in the rollback segment and any user generated event will be greater @@ -1187,15 +1180,13 @@ static void trx_purge_rseg_get_next_history_log( } /** Position the purge sys "iterator" on the undo record to use for purging. */ -static -void -trx_purge_read_undo_rec() +static void trx_purge_read_undo_rec() { ulint offset; ulint page_no; ib_uint64_t undo_no; - purge_sys.hdr_offset = purge_sys.rseg->last_offset; + purge_sys.hdr_offset = purge_sys.rseg->last_offset(); page_no = purge_sys.hdr_page_no = purge_sys.rseg->last_page_no; if (purge_sys.rseg->needs_purge) { @@ -1268,7 +1259,7 @@ trx_purge_get_next_rec( mtr_t mtr; ut_ad(purge_sys.next_stored); - ut_ad(purge_sys.tail.trx_no() < purge_sys.view.low_limit_no()); + ut_ad(purge_sys.tail.trx_no < purge_sys.view.low_limit_no()); space = purge_sys.rseg->space->id; page_no = purge_sys.page_no; @@ -1361,7 +1352,7 @@ trx_purge_fetch_next_rec( } } - if (purge_sys.tail.trx_no() >= purge_sys.view.low_limit_no()) { + if (purge_sys.tail.trx_no >= purge_sys.view.low_limit_no()) { return(NULL); } diff --git a/storage/innobase/trx/trx0roll.cc b/storage/innobase/trx/trx0roll.cc index 88ff251548c..bffd168359b 100644 --- a/storage/innobase/trx/trx0roll.cc +++ b/storage/innobase/trx/trx0roll.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2016, 2020, MariaDB Corporation. +Copyright (c) 2016, 2021, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -70,12 +70,6 @@ static bool trx_rollback_finish(trx_t* trx) ut_a(!srv_undo_sources); ut_ad(srv_fast_shutdown); ut_d(trx->in_rollback = false); - if (trx_undo_t*& undo = trx->rsegs.m_redo.old_insert) { - UT_LIST_REMOVE(trx->rsegs.m_redo.rseg->old_insert_list, - undo); - ut_free(undo); - undo = NULL; - } if (trx_undo_t*& undo = trx->rsegs.m_redo.undo) { UT_LIST_REMOVE(trx->rsegs.m_redo.rseg->undo_list, undo); @@ -124,7 +118,7 @@ trx_rollback_to_savepoint_low( trx->error_state = DB_SUCCESS; - if (trx->has_logged_or_recovered()) { + if (trx->has_logged()) { ut_ad(trx->rsegs.m_redo.rseg != 0 || trx->rsegs.m_noredo.rseg != 0); @@ -240,7 +234,7 @@ dberr_t trx_rollback_for_mysql(trx_t* trx) case TRX_STATE_PREPARED: case TRX_STATE_PREPARED_RECOVERED: ut_ad(!trx_is_autocommit_non_locking(trx)); - if (trx->rsegs.m_redo.undo || trx->rsegs.m_redo.old_insert) { + if (trx->rsegs.m_redo.undo) { /* The XA ROLLBACK of a XA PREPARE transaction will consist of multiple mini-transactions. @@ -256,11 +250,7 @@ dberr_t trx_rollback_for_mysql(trx_t* trx) killed, and finally, the transaction would be recovered in XA PREPARE state, with some of the actions already having been rolled back. */ - ut_ad(!trx->rsegs.m_redo.undo - || trx->rsegs.m_redo.undo->rseg - == trx->rsegs.m_redo.rseg); - ut_ad(!trx->rsegs.m_redo.old_insert - || trx->rsegs.m_redo.old_insert->rseg + ut_ad(trx->rsegs.m_redo.undo->rseg == trx->rsegs.m_redo.rseg); mtr_t mtr; mtr.start(); @@ -269,10 +259,6 @@ dberr_t trx_rollback_for_mysql(trx_t* trx) trx_undo_set_state_at_prepare(trx, undo, true, &mtr); } - if (trx_undo_t* undo = trx->rsegs.m_redo.old_insert) { - trx_undo_set_state_at_prepare(trx, undo, true, - &mtr); - } mutex_exit(&trx->rsegs.m_redo.rseg->mutex); /* Write the redo log for the XA ROLLBACK state change to the global buffer. It is @@ -959,23 +945,13 @@ trx_roll_pop_top_rec_of_trx(trx_t* trx, roll_ptr_t* roll_ptr, mem_heap_t* heap) } trx_undo_t* undo = NULL; - trx_undo_t* insert = trx->rsegs.m_redo.old_insert; trx_undo_t* update = trx->rsegs.m_redo.undo; trx_undo_t* temp = trx->rsegs.m_noredo.undo; const undo_no_t limit = trx->roll_limit; - ut_ad(!insert || !update || insert->empty() || update->empty() - || insert->top_undo_no != update->top_undo_no); - ut_ad(!insert || !temp || insert->empty() || temp->empty() - || insert->top_undo_no != temp->top_undo_no); ut_ad(!update || !temp || update->empty() || temp->empty() || update->top_undo_no != temp->top_undo_no); - if (UNIV_LIKELY_NULL(insert) - && !insert->empty() && limit <= insert->top_undo_no) { - undo = insert; - } - if (update && !update->empty() && update->top_undo_no >= limit) { if (!undo) { undo = update; @@ -1020,18 +996,12 @@ trx_roll_pop_top_rec_of_trx(trx_t* trx, roll_ptr_t* roll_ptr, mem_heap_t* heap) MDEV-12288 removed the insert_undo log. There is no instant ADD COLUMN for temporary tables. Therefore, this record can only be present in the main undo log. */ - ut_ad(undo == update); /* fall through */ case TRX_UNDO_RENAME_TABLE: - ut_ad(undo == insert || undo == update); + ut_ad(undo == update); /* fall through */ case TRX_UNDO_INSERT_REC: - ut_ad(undo == insert || undo == update || undo == temp); *roll_ptr |= 1ULL << ROLL_PTR_INSERT_FLAG_POS; - break; - default: - ut_ad(undo == update || undo == temp); - break; } trx->undo_no = undo_no; diff --git a/storage/innobase/trx/trx0rseg.cc b/storage/innobase/trx/trx0rseg.cc index d6720979716..f660b3151e6 100644 --- a/storage/innobase/trx/trx0rseg.cc +++ b/storage/innobase/trx/trx0rseg.cc @@ -359,7 +359,6 @@ trx_rseg_mem_free(trx_rseg_t* rseg) /* There can't be any active transactions. */ ut_a(UT_LIST_GET_LEN(rseg->undo_list) == 0); - ut_a(UT_LIST_GET_LEN(rseg->old_insert_list) == 0); for (undo = UT_LIST_GET_FIRST(rseg->undo_cached); undo != NULL; @@ -399,45 +398,45 @@ trx_rseg_mem_create(ulint id, fil_space_t* space, ulint page_no) &rseg->mutex); UT_LIST_INIT(rseg->undo_list, &trx_undo_t::undo_list); - UT_LIST_INIT(rseg->old_insert_list, &trx_undo_t::undo_list); UT_LIST_INIT(rseg->undo_cached, &trx_undo_t::undo_list); return(rseg); } /** Read the undo log lists. -@param[in,out] rseg rollback segment -@param[in,out] max_trx_id maximum observed transaction identifier -@param[in] rseg_header rollback segment header -@return the combined size of undo log segments in pages */ -static -ulint -trx_undo_lists_init(trx_rseg_t* rseg, trx_id_t& max_trx_id, - const trx_rsegf_t* rseg_header) +@param[in,out] rseg rollback segment +@param[in,out] max_trx_id maximum observed transaction identifier +@param[in] rseg_header rollback segment header +@return error code */ +static dberr_t trx_undo_lists_init(trx_rseg_t *rseg, trx_id_t &max_trx_id, + const trx_rsegf_t *rseg_header) { ut_ad(srv_force_recovery < SRV_FORCE_NO_UNDO_LOG_SCAN); - ulint size = 0; + for (ulint i= 0; i < TRX_RSEG_N_SLOTS; i++) + { + uint32_t page_no= trx_rsegf_get_nth_undo(rseg_header, i); + if (page_no != FIL_NULL) + { + const trx_undo_t *undo= trx_undo_mem_create_at_db_start(rseg, i, page_no, + max_trx_id); + if (!undo) + return DB_CORRUPTION; + rseg->curr_size+= undo->size; + MONITOR_INC(MONITOR_NUM_UNDO_SLOT_USED); + } + } - for (ulint i = 0; i < TRX_RSEG_N_SLOTS; i++) { - ulint page_no = trx_rsegf_get_nth_undo(rseg_header, i); - if (page_no != FIL_NULL) { - size += trx_undo_mem_create_at_db_start( - rseg, i, page_no, max_trx_id); - MONITOR_INC(MONITOR_NUM_UNDO_SLOT_USED); - } - } - - return(size); + return DB_SUCCESS; } /** Restore the state of a persistent rollback segment. @param[in,out] rseg persistent rollback segment @param[in,out] max_trx_id maximum observed transaction identifier -@param[in,out] mtr mini-transaction */ -static -void -trx_rseg_mem_restore(trx_rseg_t* rseg, trx_id_t& max_trx_id, mtr_t* mtr) +@param[in,out] mtr mini-transaction +@return error code */ +static dberr_t trx_rseg_mem_restore(trx_rseg_t *rseg, trx_id_t &max_trx_id, + mtr_t *mtr) { /* This is based on trx_rsegf_get_new(). We need to access buf_block_t. */ @@ -484,13 +483,16 @@ trx_rseg_mem_restore(trx_rseg_t* rseg, trx_id_t& max_trx_id, mtr_t* mtr) /* mariabackup --prepare only deals with the redo log and the data files, not with transactions or the data dictionary. */ - return; + return DB_SUCCESS; } /* Initialize the undo log lists according to the rseg header */ rseg->curr_size = mach_read_from_4(rseg_header + TRX_RSEG_HISTORY_SIZE) - + 1 + trx_undo_lists_init(rseg, max_trx_id, rseg_header); + + 1; + if (dberr_t err = trx_undo_lists_init(rseg, max_trx_id, rseg_header)) { + return err; + } if (ulint len = flst_get_len(rseg_header + TRX_RSEG_HISTORY)) { trx_sys.history_add(int32(len)); @@ -498,8 +500,7 @@ trx_rseg_mem_restore(trx_rseg_t* rseg, trx_id_t& max_trx_id, mtr_t* mtr) fil_addr_t node_addr = trx_purge_get_log_from_hist( flst_get_last(rseg_header + TRX_RSEG_HISTORY, mtr)); - rseg->last_page_no = node_addr.page; - rseg->last_offset = node_addr.boffset; + rseg->last_page_no = static_cast(node_addr.page); const trx_ulogf_t* undo_log_hdr = trx_undo_page_get( page_id_t(rseg->space->id, node_addr.page), mtr) @@ -513,10 +514,10 @@ trx_rseg_mem_restore(trx_rseg_t* rseg, trx_id_t& max_trx_id, mtr_t* mtr) if (id > max_trx_id) { max_trx_id = id; } + rseg->set_last_commit(node_addr.boffset, id); unsigned purge = mach_read_from_2( undo_log_hdr + TRX_UNDO_NEEDS_PURGE); ut_ad(purge <= 1); - rseg->set_last_trx_no(id, purge != 0); rseg->needs_purge = purge != 0; if (rseg->last_page_no != FIL_NULL) { @@ -526,6 +527,8 @@ trx_rseg_mem_restore(trx_rseg_t* rseg, trx_id_t& max_trx_id, mtr_t* mtr) purge_sys.purge_queue.push(*rseg); } } + + return DB_SUCCESS; } /** Read binlog metadata from the TRX_SYS page, in case we are upgrading @@ -549,9 +552,8 @@ static void trx_rseg_init_binlog_info(const page_t* page) #endif } -/** Initialize the rollback segments in memory at database startup. */ -void -trx_rseg_array_init() +/** Initialize or recover the rollback segments at startup. */ +dberr_t trx_rseg_array_init() { trx_id_t max_trx_id = 0; @@ -563,9 +565,9 @@ trx_rseg_array_init() wsrep_sys_xid.null(); bool wsrep_xid_in_rseg_found = false; #endif + mtr_t mtr; for (ulint rseg_id = 0; rseg_id < TRX_SYS_N_RSEGS; rseg_id++) { - mtr_t mtr; mtr.start(); if (const buf_block_t* sys = trx_sysf_get(&mtr, false)) { if (rseg_id == 0) { @@ -593,7 +595,11 @@ trx_rseg_array_init() ut_ad(rseg->id == rseg_id); ut_ad(!trx_sys.rseg_array[rseg_id]); trx_sys.rseg_array[rseg_id] = rseg; - trx_rseg_mem_restore(rseg, max_trx_id, &mtr); + if (dberr_t err = trx_rseg_mem_restore( + rseg, max_trx_id, &mtr)) { + mtr.commit(); + return err; + } #ifdef WITH_WSREP if (!wsrep_sys_xid.is_null() && !wsrep_sys_xid.eq(&trx_sys.recovered_wsrep_xid)) { @@ -620,7 +626,6 @@ trx_rseg_array_init() If no rollback segment has a WSREP XID set, we must copy the XID found in TRX_SYS page to rollback segments. */ - mtr_t mtr; mtr.start(); if (!wsrep_xid_in_rseg_found) { @@ -638,6 +643,7 @@ trx_rseg_array_init() #endif trx_sys.init_max_trx_id(max_trx_id + 1); + return DB_SUCCESS; } /** Create a persistent rollback segment. diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc index 2620005269c..c20a1270bb9 100644 --- a/storage/innobase/trx/trx0trx.cc +++ b/storage/innobase/trx/trx0trx.cc @@ -664,8 +664,7 @@ trx_resurrect_table_locks( static void trx_resurrect(trx_undo_t *undo, trx_rseg_t *rseg, time_t start_time, ulonglong start_time_micro, - uint64_t *rows_to_undo, - bool is_old_insert) + uint64_t *rows_to_undo) { trx_state_t state; /* @@ -688,8 +687,6 @@ static void trx_resurrect(trx_undo_t *undo, trx_rseg_t *rseg, state= TRX_STATE_PREPARED; break; default: - if (is_old_insert && srv_force_recovery < SRV_FORCE_NO_TRX_UNDO) - trx_undo_commit_cleanup(undo, false); return; } @@ -699,11 +696,7 @@ static void trx_resurrect(trx_undo_t *undo, trx_rseg_t *rseg, ut_d(trx->start_line= __LINE__); ut_ad(trx->no == TRX_ID_MAX); - if (is_old_insert) - trx->rsegs.m_redo.old_insert= undo; - else - trx->rsegs.m_redo.undo= undo; - + trx->rsegs.m_redo.undo= undo; trx->undo_no= undo->top_undo_no + 1; trx->rsegs.m_redo.rseg= rseg; /* @@ -734,8 +727,7 @@ static void trx_resurrect(trx_undo_t *undo, trx_rseg_t *rseg, /** Initialize (resurrect) transactions at startup. */ -void -trx_lists_init_at_db_start() +dberr_t trx_lists_init_at_db_start() { ut_a(srv_is_being_started); ut_ad(!srv_was_started); @@ -744,16 +736,18 @@ trx_lists_init_at_db_start() /* mariabackup --prepare only deals with the redo log and the data files, not with transactions or the data dictionary. */ - trx_rseg_array_init(); - return; + return trx_rseg_array_init(); } if (srv_force_recovery >= SRV_FORCE_NO_UNDO_LOG_SCAN) { - return; + return DB_SUCCESS; } purge_sys.create(); - trx_rseg_array_init(); + if (dberr_t err = trx_rseg_array_init()) { + ib::info() << "Retry with innodb_force_recovery=5"; + return err; + } /* Look from the rollback segments if there exist undo logs for transactions. */ @@ -771,17 +765,6 @@ trx_lists_init_at_db_start() if (rseg == NULL) { continue; } - - /* Resurrect transactions that were doing inserts - using the old separate insert_undo log. */ - undo = UT_LIST_GET_FIRST(rseg->old_insert_list); - while (undo) { - trx_undo_t* next = UT_LIST_GET_NEXT(undo_list, undo); - trx_resurrect(undo, rseg, start_time, start_time_micro, - &rows_to_undo, true); - undo = next; - } - /* Ressurrect other transactions. */ for (undo = UT_LIST_GET_FIRST(rseg->undo_list); undo != NULL; @@ -789,8 +772,7 @@ trx_lists_init_at_db_start() trx_t *trx = trx_sys.find(0, undo->trx_id, false); if (!trx) { trx_resurrect(undo, rseg, start_time, - start_time_micro, - &rows_to_undo, false); + start_time_micro, &rows_to_undo); } else { ut_ad(trx_state_eq(trx, TRX_STATE_ACTIVE) || trx_state_eq(trx, TRX_STATE_PREPARED)); @@ -825,6 +807,7 @@ trx_lists_init_at_db_start() ib::info() << "Trx id counter is " << trx_sys.get_max_trx_id(); } trx_sys.clone_oldest_view(); + return DB_SUCCESS; } /** Assign a persistent rollback segment in a round-robin fashion, @@ -1121,30 +1104,22 @@ trx_write_serialisation_history( trx_rseg_t* rseg = trx->rsegs.m_redo.rseg; if (!rseg) { ut_ad(!trx->rsegs.m_redo.undo); - ut_ad(!trx->rsegs.m_redo.old_insert); return; } trx_undo_t*& undo = trx->rsegs.m_redo.undo; - trx_undo_t*& old_insert = trx->rsegs.m_redo.old_insert; - if (!undo && !old_insert) { + if (!undo) { return; } ut_ad(!trx->read_only); ut_ad(!undo || undo->rseg == rseg); - ut_ad(!old_insert || old_insert->rseg == rseg); mutex_enter(&rseg->mutex); /* Assign the transaction serialisation number and add any undo log to the purge queue. */ trx_serialise(trx); - - if (UNIV_LIKELY_NULL(old_insert)) { - UT_LIST_REMOVE(rseg->old_insert_list, old_insert); - trx_purge_add_undo_to_history(trx, old_insert, mtr); - } if (undo) { UT_LIST_REMOVE(rseg->undo_list, undo); trx_purge_add_undo_to_history(trx, undo, mtr); @@ -1382,20 +1357,12 @@ trx_commit_in_memory( ut_ad(rseg->trx_ref_count > 0); --rseg->trx_ref_count; mutex_exit(&rseg->mutex); - - if (trx_undo_t*& insert = trx->rsegs.m_redo.old_insert) { - ut_ad(insert->rseg == rseg); - trx_undo_commit_cleanup(insert, false); - insert = NULL; - } } - ut_ad(!trx->rsegs.m_redo.old_insert); - if (mtr != NULL) { if (trx_undo_t*& undo = trx->rsegs.m_noredo.undo) { ut_ad(undo->rseg == trx->rsegs.m_noredo.rseg); - trx_undo_commit_cleanup(undo, true); + trx_undo_commit_cleanup(undo); undo = NULL; } @@ -1490,7 +1457,7 @@ void trx_commit_low(trx_t* trx, mtr_t* mtr) ut_ad(!mtr || mtr->is_active()); ut_d(bool aborted = trx->in_rollback && trx->error_state == DB_DEADLOCK); - ut_ad(!mtr == (aborted || !trx->has_logged_or_recovered())); + ut_ad(!mtr == (aborted || !trx->has_logged())); ut_ad(!mtr || !aborted); /* undo_no is non-zero if we're doing the final commit. */ @@ -1577,10 +1544,7 @@ trx_commit( mtr_t* mtr; mtr_t local_mtr; - DBUG_EXECUTE_IF("ib_trx_commit_crash_before_trx_commit_start", - DBUG_SUICIDE();); - - if (trx->has_logged_or_recovered()) { + if (trx->has_logged()) { mtr = &local_mtr; mtr->start(); } else { @@ -1986,11 +1950,8 @@ trx_weight_ge( /** Prepare a transaction. @return log sequence number that makes the XA PREPARE durable @retval 0 if no changes needed to be made durable */ -static -lsn_t -trx_prepare_low(trx_t* trx) +static lsn_t trx_prepare_low(trx_t *trx) { - ut_ad(!trx->rsegs.m_redo.old_insert); ut_ad(!trx->is_recovered); mtr_t mtr; diff --git a/storage/innobase/trx/trx0undo.cc b/storage/innobase/trx/trx0undo.cc index 7254c830cde..dea85c40473 100644 --- a/storage/innobase/trx/trx0undo.cc +++ b/storage/innobase/trx/trx0undo.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2014, 2020, MariaDB Corporation. +Copyright (c) 2014, 2021, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -34,6 +34,7 @@ Created 3/26/1996 Heikki Tuuri #include "trx0purge.h" #include "trx0rec.h" #include "trx0rseg.h" +#include "log.h" /* How should the old versions in the history list be managed? ---------------------------------------------------------- @@ -1011,13 +1012,8 @@ loop: } /** Frees an undo log segment which is not in the history list. -@param[in] undo undo log -@param[in] noredo whether the undo tablespace is redo logged */ -static -void -trx_undo_seg_free( - const trx_undo_t* undo, - bool noredo) +@param undo temporary undo log */ +static void trx_undo_seg_free(const trx_undo_t *undo) { trx_rseg_t* rseg; fseg_header_t* file_seg; @@ -1029,16 +1025,12 @@ trx_undo_seg_free( rseg = undo->rseg; do { - - mtr_start(&mtr); - - if (noredo) { - mtr.set_log_mode(MTR_LOG_NO_REDO); - } + mtr.start(); + mtr.set_log_mode(MTR_LOG_NO_REDO); mutex_enter(&(rseg->mutex)); - seg_header = trx_undo_page_get(page_id_t(undo->rseg->space->id, + seg_header = trx_undo_page_get(page_id_t(SRV_TMP_SPACE_ID, undo->hdr_page_no), &mtr) + TRX_UNDO_SEG_HDR; @@ -1069,10 +1061,11 @@ trx_undo_seg_free( @param[in] id rollback segment slot @param[in] page_no undo log segment page number @param[in,out] max_trx_id the largest observed transaction ID -@return size of the undo log in pages */ -ulint -trx_undo_mem_create_at_db_start(trx_rseg_t* rseg, ulint id, ulint page_no, - trx_id_t& max_trx_id) +@return the undo log +@retval nullptr on error */ +trx_undo_t * +trx_undo_mem_create_at_db_start(trx_rseg_t *rseg, ulint id, uint32_t page_no, + trx_id_t &max_trx_id) { mtr_t mtr; XID xid; @@ -1082,16 +1075,56 @@ trx_undo_mem_create_at_db_start(trx_rseg_t* rseg, ulint id, ulint page_no, mtr.start(); const page_t* undo_page = trx_undo_page_get( page_id_t(rseg->space->id, page_no), &mtr); - const ulint type = mach_read_from_2( - TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_TYPE + undo_page); - ut_ad(type == 0 || type == TRX_UNDO_INSERT || type == TRX_UNDO_UPDATE); + const uint16_t type = mach_read_from_2(TRX_UNDO_PAGE_HDR + + TRX_UNDO_PAGE_TYPE + + undo_page); + switch (type) { + case 0: + case 2: /* TRX_UNDO_UPDATE */ + break; + case 1: /* TRX_UNDO_INSERT */ + sql_print_error("InnoDB: upgrade from older version than" + " MariaDB 10.3 requires clean shutdown"); + goto corrupted; + default: + sql_print_error("InnoDB: unsupported undo header type %u", + type); + corrupted: + mtr.commit(); + return NULL; + } - uint state = mach_read_from_2(TRX_UNDO_SEG_HDR + TRX_UNDO_STATE - + undo_page); - uint offset = mach_read_from_2(TRX_UNDO_SEG_HDR + TRX_UNDO_LAST_LOG - + undo_page); + uint16_t offset = mach_read_from_2(TRX_UNDO_SEG_HDR + TRX_UNDO_LAST_LOG + + undo_page); + if (offset < TRX_UNDO_SEG_HDR + TRX_UNDO_SEG_HDR_SIZE || + offset >= srv_page_size - TRX_UNDO_LOG_OLD_HDR_SIZE) { + sql_print_error("InnoDB: invalid undo header offset %u", + offset); + goto corrupted; + } - const trx_ulogf_t* undo_header = undo_page + offset; + const trx_ulogf_t* const undo_header = undo_page + offset; + uint16_t state = mach_read_from_2(TRX_UNDO_SEG_HDR + TRX_UNDO_STATE + + undo_page); + switch (state) { + case TRX_UNDO_ACTIVE: + case TRX_UNDO_PREPARED: + break; + default: + sql_print_error("InnoDB: unsupported undo header state %u", + state); + goto corrupted; + case TRX_UNDO_TO_PURGE: + case TRX_UNDO_CACHED: + trx_id_t id = mach_read_from_8(TRX_UNDO_TRX_NO + undo_header); + if (id >> 48) { + sql_print_error("InnoDB: corrupted TRX_NO %llx", id); + goto corrupted; + } + if (id > max_trx_id) { + max_trx_id = id; + } + } /* Read X/Open XA transaction identification if it exists, or set it to NULL. */ @@ -1103,6 +1136,10 @@ trx_undo_mem_create_at_db_start(trx_rseg_t* rseg, ulint id, ulint page_no, } trx_id_t trx_id = mach_read_from_8(undo_header + TRX_UNDO_TRX_ID); + if (trx_id >> 48) { + sql_print_error("InnoDB: corrupted TRX_ID %llx", trx_id); + goto corrupted; + } if (trx_id > max_trx_id) { max_trx_id = trx_id; } @@ -1111,61 +1148,45 @@ trx_undo_mem_create_at_db_start(trx_rseg_t* rseg, ulint id, ulint page_no, trx_undo_t* undo = trx_undo_mem_create( rseg, id, trx_id, &xid, page_no, offset); mutex_exit(&rseg->mutex); + if (!undo) { + return undo; + } undo->dict_operation = undo_header[TRX_UNDO_DICT_TRANS]; undo->table_id = mach_read_from_8(undo_header + TRX_UNDO_TABLE_ID); undo->size = flst_get_len(TRX_UNDO_SEG_HDR + TRX_UNDO_PAGE_LIST + undo_page); - if (UNIV_UNLIKELY(state == TRX_UNDO_TO_FREE)) { - /* This is an old-format insert_undo log segment that - is being freed. The page list is inconsistent. */ - ut_ad(type == TRX_UNDO_INSERT); - state = TRX_UNDO_TO_PURGE; + fil_addr_t last_addr = flst_get_last( + TRX_UNDO_SEG_HDR + TRX_UNDO_PAGE_LIST + undo_page, &mtr); + + undo->last_page_no = last_addr.page; + undo->top_page_no = last_addr.page; + + page_t* last_page = trx_undo_page_get( + page_id_t(rseg->space->id, undo->last_page_no), &mtr); + + if (const trx_undo_rec_t* rec = trx_undo_page_get_last_rec( + last_page, page_no, offset)) { + undo->top_offset = ulint(rec - last_page); + undo->top_undo_no = trx_undo_rec_get_undo_no(rec); + ut_ad(!undo->empty()); } else { - if (state == TRX_UNDO_TO_PURGE - || state == TRX_UNDO_CACHED) { - trx_id_t id = mach_read_from_8(TRX_UNDO_TRX_NO - + undo_header); - if (id > max_trx_id) { - max_trx_id = id; - } - } - - fil_addr_t last_addr = flst_get_last( - TRX_UNDO_SEG_HDR + TRX_UNDO_PAGE_LIST + undo_page, - &mtr); - - undo->last_page_no = last_addr.page; - undo->top_page_no = last_addr.page; - - page_t* last_page = trx_undo_page_get( - page_id_t(rseg->space->id, undo->last_page_no), &mtr); - - if (const trx_undo_rec_t* rec = trx_undo_page_get_last_rec( - last_page, page_no, offset)) { - undo->top_offset = ulint(rec - last_page); - undo->top_undo_no = trx_undo_rec_get_undo_no(rec); - ut_ad(!undo->empty()); - } else { - undo->top_undo_no = IB_ID_MAX; - ut_ad(undo->empty()); - } + undo->top_undo_no = IB_ID_MAX; + ut_ad(undo->empty()); } undo->state = state; if (state != TRX_UNDO_CACHED) { - UT_LIST_ADD_LAST(type == TRX_UNDO_INSERT - ? rseg->old_insert_list - : rseg->undo_list, undo); + UT_LIST_ADD_LAST(rseg->undo_list, undo); } else { UT_LIST_ADD_LAST(rseg->undo_cached, undo); MONITOR_INC(MONITOR_NUM_UNDO_SLOT_CACHED); } mtr.commit(); - return undo->size; + return undo; } /********************************************************************//** @@ -1577,22 +1598,18 @@ trx_undo_set_state_at_prepare( return(undo_page); } -/** Free an old insert or temporary undo log after commit or rollback. +/** Free temporary undo log after commit or rollback. The information is not needed after a commit or rollback, therefore the data can be discarded. -@param[in,out] undo undo log -@param[in] is_temp whether this is temporary undo log */ -void -trx_undo_commit_cleanup(trx_undo_t* undo, bool is_temp) +@param undo temporary undo log */ +void trx_undo_commit_cleanup(trx_undo_t *undo) { trx_rseg_t* rseg = undo->rseg; - ut_ad(is_temp == !rseg->is_persistent()); - ut_ad(!is_temp || 0 == UT_LIST_GET_LEN(rseg->old_insert_list)); + ut_ad(rseg->space == fil_system.temp_space); mutex_enter(&rseg->mutex); - UT_LIST_REMOVE(is_temp ? rseg->undo_list : rseg->old_insert_list, - undo); + UT_LIST_REMOVE(rseg->undo_list, undo); if (undo->state == TRX_UNDO_CACHED) { UT_LIST_ADD_FIRST(rseg->undo_cached, undo); @@ -1602,7 +1619,7 @@ trx_undo_commit_cleanup(trx_undo_t* undo, bool is_temp) /* Delete first the undo log segment in the file */ mutex_exit(&rseg->mutex); - trx_undo_seg_free(undo, is_temp); + trx_undo_seg_free(undo); mutex_enter(&rseg->mutex); ut_ad(rseg->curr_size > undo->size); @@ -1615,15 +1632,13 @@ trx_undo_commit_cleanup(trx_undo_t* undo, bool is_temp) } /** At shutdown, frees the undo logs of a transaction. */ -void -trx_undo_free_at_shutdown(trx_t *trx) +void trx_undo_free_at_shutdown(trx_t *trx) { if (trx_undo_t*& undo = trx->rsegs.m_redo.undo) { switch (undo->state) { case TRX_UNDO_PREPARED: break; case TRX_UNDO_CACHED: - case TRX_UNDO_TO_FREE: case TRX_UNDO_TO_PURGE: ut_ad(trx_state_eq(trx, TRX_STATE_COMMITTED_IN_MEMORY)); @@ -1644,34 +1659,6 @@ trx_undo_free_at_shutdown(trx_t *trx) ut_free(undo); undo = NULL; } - - if (trx_undo_t*& undo = trx->rsegs.m_redo.old_insert) { - switch (undo->state) { - case TRX_UNDO_PREPARED: - break; - case TRX_UNDO_CACHED: - case TRX_UNDO_TO_FREE: - case TRX_UNDO_TO_PURGE: - ut_ad(trx_state_eq(trx, - TRX_STATE_COMMITTED_IN_MEMORY)); - /* fall through */ - case TRX_UNDO_ACTIVE: - /* trx_t::commit_state() assigns - trx->state = TRX_STATE_COMMITTED_IN_MEMORY. */ - ut_a(!srv_was_started - || srv_read_only_mode - || srv_force_recovery >= SRV_FORCE_NO_TRX_UNDO - || srv_fast_shutdown); - break; - default: - ut_error; - } - - UT_LIST_REMOVE(trx->rsegs.m_redo.rseg->old_insert_list, undo); - ut_free(undo); - undo = NULL; - } - if (trx_undo_t*& undo = trx->rsegs.m_noredo.undo) { ut_a(undo->state == TRX_UNDO_PREPARED); From 59e3ac2e67b7bab72f4d3ddd2a07f13f1a557411 Mon Sep 17 00:00:00 2001 From: Jean Weisbuch Date: Mon, 18 May 2020 15:18:56 +0200 Subject: [PATCH 147/251] MDEV-25878: mytop bugs: check for mysql driver and sockets mytop fall-back to DBD::mysql if DBD::MariaDB is not available Apply #1546 --- scripts/mytop.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/mytop.sh b/scripts/mytop.sh index 7d40c44c2d6..a6a31b73199 100644 --- a/scripts/mytop.sh +++ b/scripts/mytop.sh @@ -242,7 +242,11 @@ my $dsn; ## Socket takes precedence. -$dsn ="DBI:MariaDB:database=$config{db};mariadb_read_default_group=mytop;"; +if (eval {DBI->install_driver("MariaDB")}) { + $dsn = "DBI:MariaDB:database=$config{db};mariadb_read_default_group=mytop;"; +} else { + $dsn = "DBI:mysql:database=$config{db};mysql_read_default_group=mytop;"; +} if ($config{socket} and -S $config{socket}) { @@ -2095,7 +2099,7 @@ following: * Perl 5.005 or newer * Getopt::Long - * DBI and DBD::MariaDB + * DBI and DBD::MariaDB or DBD::mysql * Term::ReadKey from CPAN Most systems are likely to have all of those installed--except for From bcedb4200f26468d33f7064c1e6e126d81b21162 Mon Sep 17 00:00:00 2001 From: Anel Husakovic Date: Tue, 13 Oct 2020 14:36:25 +0200 Subject: [PATCH 148/251] MDEV-25878: mytop bugs: check for mysql driver and sockets - Adding socket check for MariaDB/Mysql driver Reviewed by: serg@mariadb.com --- scripts/mytop.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/scripts/mytop.sh b/scripts/mytop.sh index a6a31b73199..65bfb8c976e 100644 --- a/scripts/mytop.sh +++ b/scripts/mytop.sh @@ -6,7 +6,7 @@ =head1 NAME -mytop - display MariaDB server performance info like `top' +mytop - display MariaDB/MySQL server performance info like `top' =cut @@ -241,16 +241,17 @@ my $BOLD = BOLD() || ''; my $dsn; ## Socket takes precedence. - +my $prefix= 'mysql'; if (eval {DBI->install_driver("MariaDB")}) { $dsn = "DBI:MariaDB:database=$config{db};mariadb_read_default_group=mytop;"; + $prefix= 'mariadb' } else { $dsn = "DBI:mysql:database=$config{db};mysql_read_default_group=mytop;"; } if ($config{socket} and -S $config{socket}) { - $dsn .= "mariadb_socket=$config{socket}"; + $dsn .= "${prefix}_socket=$config{socket}"; } else { @@ -272,7 +273,7 @@ my $dbh = DBI->connect($dsn, $config{user}, $config{pass}, if (not ref $dbh) { my $Error = < or B<--socket> I -If you're running B on the same host as MariaDB, you may wish to -have it use the MariaDB socket directly rather than a standard TCP/IP +If you're running B on the same host as MariaDB/MySQL, you may wish to +have it use the MariaDB/MySQL socket directly rather than a standard TCP/IP connection. If you do,just specify one. Note that specifying a socket will make B ignore any host From baf0ef9a18fa69e97deb750d9fa545dd4f162596 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 21 Jun 2021 14:05:43 +0300 Subject: [PATCH 149/251] After-merge fix: Remove duplicated code In the merge commit d3e4fae797b9467828c33c89b55a991067e8bcde a message about innodb_force_recovery was accidentally duplicated. --- storage/innobase/srv/srv0start.cc | 5 ----- 1 file changed, 5 deletions(-) diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc index 49859499666..18b0cbba395 100644 --- a/storage/innobase/srv/srv0start.cc +++ b/storage/innobase/srv/srv0start.cc @@ -1310,11 +1310,6 @@ dberr_t srv_start(bool create_new_db) || is_mariabackup_restore_or_export()); - if (srv_force_recovery) { - ib::info() << "!!! innodb_force_recovery is set to " - << srv_force_recovery << " !!!"; - } - if (srv_force_recovery) { ib::info() << "!!! innodb_force_recovery is set to " << srv_force_recovery << " !!!"; From 09249eb9bde68e56691004e293de69a400311ab0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 21 Jun 2021 17:51:03 +0300 Subject: [PATCH 150/251] MDEV-14180 fixup: Avoid unnecessary dirtying of pages fil_crypt_rotate_page(): If a page is already marked as dirty, do not move it in buf_pool.flush_list. Actual re-encryption will happen in buf_flush_page(), and moving the page in buf_pool.flush_list may only postpone the operation. --- storage/innobase/fil/fil0crypt.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/storage/innobase/fil/fil0crypt.cc b/storage/innobase/fil/fil0crypt.cc index 22b5a839710..44268954d57 100644 --- a/storage/innobase/fil/fil0crypt.cc +++ b/storage/innobase/fil/fil0crypt.cc @@ -1820,6 +1820,9 @@ fil_crypt_rotate_page( if (block->page.status == buf_page_t::FREED) { /* Do not modify freed pages to avoid an assertion failure on recovery.*/ + } else if (block->page.oldest_modification()) { + /* Do not unnecessarily touch pages that are + already dirty. */ } else if (space->is_stopping()) { /* The tablespace is closing (in DROP TABLE or TRUNCATE TABLE or similar): avoid further access */ From 9dc50ea2293640f8153bc806612fd72634498010 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 21 Jun 2021 18:13:28 +0300 Subject: [PATCH 151/251] MDEV-25979 Invalid page number written to DB_ROLL_PTR trx_undo_report_row_operation(): Fix a race condition that was introduced in commit f74023b955b5825fc3e957f644d5ee75c8171c98 (MDEV-15090). We must not access undo_block after the page latch has been released in mtr_t::commit(), because the block could be evicted or replaced. --- storage/innobase/trx/trx0rec.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/storage/innobase/trx/trx0rec.cc b/storage/innobase/trx/trx0rec.cc index 9c7106facaf..e011b3f5d8e 100644 --- a/storage/innobase/trx/trx0rec.cc +++ b/storage/innobase/trx/trx0rec.cc @@ -2054,12 +2054,11 @@ trx_undo_report_row_operation( goto err_exit; } - mtr_commit(&mtr); + mtr.commit(); } else { /* Success */ - mtr_commit(&mtr); - undo->top_page_no = undo_block->page.id.page_no(); + mtr.commit(); undo->top_offset = offset; undo->top_undo_no = trx->undo_no++; undo->guess_block = undo_block; From cc0bd8431f9a2b252697afab78e039b8cd294d01 Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Mon, 21 Jun 2021 16:15:07 -0700 Subject: [PATCH 152/251] MDEV-25679 Wrong result selecting from simple view with LIMIT and ORDER BY This bug affected queries with views / derived_tables / CTEs whose specifications were of the form (SELECT ... LIMIT ) ORDER BY ... Units representing such specifications contains one SELECT_LEX structure for (SELECT ... LIMIT ) and additionally SELECT_LEX structure for fake_select_lex. This fact should have been taken into account in the function mysql_derived_fill(). This patch has to be applied to 10.2 and 10.3 only. --- mysql-test/r/derived_view.result | 21 +++++++++++++++++++++ mysql-test/t/derived_view.test | 17 +++++++++++++++++ sql/sql_derived.cc | 2 +- 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/derived_view.result b/mysql-test/r/derived_view.result index fe25feb5a38..d8ee508f5db 100644 --- a/mysql-test/r/derived_view.result +++ b/mysql-test/r/derived_view.result @@ -3436,3 +3436,24 @@ Warnings: Note 1003 select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`a` AS `a`,3 AS `d`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from `test`.`t1` join `test`.`t2` join `test`.`t3` where `test`.`t1`.`a` = 3 and `test`.`t1`.`pk` <= 2 drop view v1; drop table t1,t2,t3; +# +# MDEV-25679: view / derived table defined as ordered select with LIMIT +# +create table t1 (a int); +insert into t1 values (3), (7), (1); +create view v1 as (select a from t1 limit 2) order by a desc; +(select a from t1 limit 2) order by a desc; +a +7 +3 +select * from v1; +a +7 +3 +select * from ((select a from t1 limit 2) order by a desc) dt; +a +7 +3 +drop view v1; +drop table t1; +# End of 10.2 tests diff --git a/mysql-test/t/derived_view.test b/mysql-test/t/derived_view.test index 46d6a7805ca..89ada40e84c 100644 --- a/mysql-test/t/derived_view.test +++ b/mysql-test/t/derived_view.test @@ -2249,3 +2249,20 @@ eval explain extended $q; drop view v1; drop table t1,t2,t3; + +--echo # +--echo # MDEV-25679: view / derived table defined as ordered select with LIMIT +--echo # + +create table t1 (a int); +insert into t1 values (3), (7), (1); + +create view v1 as (select a from t1 limit 2) order by a desc; +(select a from t1 limit 2) order by a desc; +select * from v1; +select * from ((select a from t1 limit 2) order by a desc) dt; + +drop view v1; +drop table t1; + +--echo # End of 10.2 tests diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index 3ab93840d80..632baf4bc5b 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -1091,7 +1091,7 @@ bool mysql_derived_fill(THD *thd, LEX *lex, TABLE_LIST *derived) res= derived->fill_recursive(thd); } } - else if (unit->is_union()) + else if (unit->is_union() || unit->fake_select_lex) { // execute union without clean up res= unit->exec(); From 6e94ef41859cc628f92224e33dd661d9a4be215b Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Mon, 21 Jun 2021 22:25:37 -0700 Subject: [PATCH 153/251] MDEV-25679 Wrong result selecting from simple view with LIMIT and ORDER BY This bug affected queries with views / derived_tables / CTEs whose specifications were of the form (SELECT ... LIMIT ) ORDER BY ... Units representing such specifications contains one SELECT_LEX structure for (SELECT ... LIMIT ) and additionally SELECT_LEX structure for fake_select_lex. This fact should have been taken into account in the function mysql_derived_fill(). This patch has to be applied to 10.2 and 10.3 only. --- mysql-test/main/derived_view.result | 21 +++++++++++++++++++++ mysql-test/main/derived_view.test | 17 +++++++++++++++++ sql/sql_derived.cc | 2 +- 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/mysql-test/main/derived_view.result b/mysql-test/main/derived_view.result index dd0cac74d28..65a1adcaddd 100644 --- a/mysql-test/main/derived_view.result +++ b/mysql-test/main/derived_view.result @@ -3478,3 +3478,24 @@ Warnings: Note 1003 select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`a` AS `a`,3 AS `d`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from `test`.`t1` join `test`.`t2` join `test`.`t3` where `test`.`t1`.`a` = 3 and `test`.`t1`.`pk` <= 2 drop view v1; drop table t1,t2,t3; +# +# MDEV-25679: view / derived table defined as ordered select with LIMIT +# +create table t1 (a int); +insert into t1 values (3), (7), (1); +create view v1 as (select a from t1 limit 2) order by a desc; +(select a from t1 limit 2) order by a desc; +a +7 +3 +select * from v1; +a +7 +3 +select * from ((select a from t1 limit 2) order by a desc) dt; +a +7 +3 +drop view v1; +drop table t1; +# End of 10.2 tests diff --git a/mysql-test/main/derived_view.test b/mysql-test/main/derived_view.test index 76b15fa8787..9ab1ddd3a76 100644 --- a/mysql-test/main/derived_view.test +++ b/mysql-test/main/derived_view.test @@ -2273,3 +2273,20 @@ eval explain extended $q; drop view v1; drop table t1,t2,t3; + +--echo # +--echo # MDEV-25679: view / derived table defined as ordered select with LIMIT +--echo # + +create table t1 (a int); +insert into t1 values (3), (7), (1); + +create view v1 as (select a from t1 limit 2) order by a desc; +(select a from t1 limit 2) order by a desc; +select * from v1; +select * from ((select a from t1 limit 2) order by a desc) dt; + +drop view v1; +drop table t1; + +--echo # End of 10.2 tests diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index e2e30f35206..8f10013bed1 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -1163,7 +1163,7 @@ bool mysql_derived_fill(THD *thd, LEX *lex, TABLE_LIST *derived) res= derived->fill_recursive(thd); } } - else if (unit->is_unit_op()) + else if (unit->is_unit_op() || unit->fake_select_lex) { // execute union without clean up res= unit->exec(); From 19716ad5a82b979c6817f8e8ee8b623c43d97059 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 22 Jun 2021 09:11:41 +0300 Subject: [PATCH 154/251] MDEV-25982 Upgrade of MariaDB 10.1 log crashes due to missing encryption key init_crypt_key(): On failure, set info->key_version to ENCRYPTION_KEY_VERSION_INVALID. log_crypt_101_read_block(): Refuse to attempt decryption if info->key_version is ENCRYPTION_KEY_VERSION_INVALID. --- storage/innobase/log/log0crypt.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/storage/innobase/log/log0crypt.cc b/storage/innobase/log/log0crypt.cc index f1297921839..fcc2674699f 100644 --- a/storage/innobase/log/log0crypt.cc +++ b/storage/innobase/log/log0crypt.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (C) 2013, 2015, Google Inc. All Rights Reserved. -Copyright (C) 2014, 2018, MariaDB Corporation. +Copyright (C) 2014, 2021, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -163,6 +163,7 @@ static bool init_crypt_key(crypt_info_t* info, bool upgrade = false) << info->key_version << " failed (" << rc << "). Maybe the key or the required encryption " "key management plugin was not found."; + info->key_version = ENCRYPTION_KEY_VERSION_INVALID; return false; } @@ -182,6 +183,7 @@ static bool init_crypt_key(crypt_info_t* info, bool upgrade = false) if (err != MY_AES_OK || dst_len != MY_AES_BLOCK_SIZE) { ib::error() << "Getting redo log crypto key failed: err = " << err << ", len = " << dst_len; + info->key_version = ENCRYPTION_KEY_VERSION_INVALID; return false; } @@ -275,6 +277,7 @@ log_crypt_101_read_block(byte* buf) for (const crypt_info_t* const end = info + infos_used; info < end; info++) { if (info->key_version + && info->key_version != ENCRYPTION_KEY_VERSION_INVALID && info->checkpoint_no == checkpoint_no) { goto found; } @@ -286,6 +289,9 @@ log_crypt_101_read_block(byte* buf) /* MariaDB Server 10.1 would use the first key if it fails to find a key for the current checkpoint. */ info = infos; + if (info->key_version == ENCRYPTION_KEY_VERSION_INVALID) { + return false; + } found: byte dst[OS_FILE_LOG_BLOCK_SIZE]; uint dst_len; From 35a9aaebe23a5b514d5f5fc8e71f09496dedcf06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 22 Jun 2021 09:30:25 +0300 Subject: [PATCH 155/251] MDEV-25981 InnoDB upgrade fails trx_undo_mem_create_at_db_start(): Relax too strict upgrade checks that were introduced in commit e46f76c9749d7758765ba274a212cfc2dcf3eeb8 (MDEV-15912). On commit, pages will typically be set to TRX_UNDO_CACHED state. Having the type TRX_UNDO_INSERT in such pages is common and unproblematic; the type would be reset in trx_undo_reuse_cached(). trx_rseg_array_init(): On failure, clean up the rollback segments that were initialized so far, to avoid an assertion failure later during shutdown. --- storage/innobase/trx/trx0rseg.cc | 25 +++++++++++++++++++++---- storage/innobase/trx/trx0undo.cc | 24 +++++++++++++----------- 2 files changed, 34 insertions(+), 15 deletions(-) diff --git a/storage/innobase/trx/trx0rseg.cc b/storage/innobase/trx/trx0rseg.cc index f660b3151e6..c5ab4d37aae 100644 --- a/storage/innobase/trx/trx0rseg.cc +++ b/storage/innobase/trx/trx0rseg.cc @@ -411,7 +411,7 @@ trx_rseg_mem_create(ulint id, fil_space_t* space, ulint page_no) static dberr_t trx_undo_lists_init(trx_rseg_t *rseg, trx_id_t &max_trx_id, const trx_rsegf_t *rseg_header) { - ut_ad(srv_force_recovery < SRV_FORCE_NO_UNDO_LOG_SCAN); + ut_ad(srv_force_recovery < SRV_FORCE_NO_UNDO_LOG_SCAN); for (ulint i= 0; i < TRX_RSEG_N_SLOTS; i++) { @@ -566,6 +566,7 @@ dberr_t trx_rseg_array_init() bool wsrep_xid_in_rseg_found = false; #endif mtr_t mtr; + dberr_t err = DB_SUCCESS; for (ulint rseg_id = 0; rseg_id < TRX_SYS_N_RSEGS; rseg_id++) { mtr.start(); @@ -595,10 +596,11 @@ dberr_t trx_rseg_array_init() ut_ad(rseg->id == rseg_id); ut_ad(!trx_sys.rseg_array[rseg_id]); trx_sys.rseg_array[rseg_id] = rseg; - if (dberr_t err = trx_rseg_mem_restore( - rseg, max_trx_id, &mtr)) { + if ((err = trx_rseg_mem_restore( + rseg, max_trx_id, &mtr)) + != DB_SUCCESS) { mtr.commit(); - return err; + break; } #ifdef WITH_WSREP if (!wsrep_sys_xid.is_null() && @@ -619,6 +621,21 @@ dberr_t trx_rseg_array_init() mtr.commit(); } + if (err != DB_SUCCESS) { + for (ulint rseg_id = 0; rseg_id < TRX_SYS_N_RSEGS; rseg_id++) { + if (trx_rseg_t*& rseg = trx_sys.rseg_array[rseg_id]) { + while (trx_undo_t* u= UT_LIST_GET_FIRST( + rseg->undo_list)) { + UT_LIST_REMOVE(rseg->undo_list, u); + ut_free(u); + } + trx_rseg_mem_free(rseg); + rseg = NULL; + } + } + return err; + } + #ifdef WITH_WSREP if (!wsrep_sys_xid.is_null()) { /* Upgrade from a version prior to 10.3.5, diff --git a/storage/innobase/trx/trx0undo.cc b/storage/innobase/trx/trx0undo.cc index dea85c40473..928411b1163 100644 --- a/storage/innobase/trx/trx0undo.cc +++ b/storage/innobase/trx/trx0undo.cc @@ -1078,18 +1078,11 @@ trx_undo_mem_create_at_db_start(trx_rseg_t *rseg, ulint id, uint32_t page_no, const uint16_t type = mach_read_from_2(TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_TYPE + undo_page); - switch (type) { - case 0: - case 2: /* TRX_UNDO_UPDATE */ - break; - case 1: /* TRX_UNDO_INSERT */ - sql_print_error("InnoDB: upgrade from older version than" - " MariaDB 10.3 requires clean shutdown"); - goto corrupted; - default: + if (UNIV_UNLIKELY(type > 2)) { +corrupted_type: sql_print_error("InnoDB: unsupported undo header type %u", type); - corrupted: +corrupted: mtr.commit(); return NULL; } @@ -1109,12 +1102,21 @@ trx_undo_mem_create_at_db_start(trx_rseg_t *rseg, ulint id, uint32_t page_no, switch (state) { case TRX_UNDO_ACTIVE: case TRX_UNDO_PREPARED: - break; + if (UNIV_LIKELY(type != 1)) { + break; + } + sql_print_error("InnoDB: upgrade from older version than" + " MariaDB 10.3 requires clean shutdown"); + goto corrupted; default: sql_print_error("InnoDB: unsupported undo header state %u", state); goto corrupted; case TRX_UNDO_TO_PURGE: + if (UNIV_UNLIKELY(type == 1)) { + goto corrupted_type; + } + /* fall through */ case TRX_UNDO_CACHED: trx_id_t id = mach_read_from_8(TRX_UNDO_TRX_NO + undo_header); if (id >> 48) { From aaaed9baa054e8bf8243fbb384c606306ea584b4 Mon Sep 17 00:00:00 2001 From: Alexey Bychko Date: Tue, 22 Jun 2021 18:57:01 +0700 Subject: [PATCH 156/251] MDEV-25960 yum update overwrites customized logrotation config (/etc/logrotate.d/mysql) added %config directive to /etc/logrotate.d/mysql and put it to server package. if file is edited by customer and defaults are changed - new .rpmnew file with defaults will be created next to old one. --- cmake/cpack_rpm.cmake | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmake/cpack_rpm.cmake b/cmake/cpack_rpm.cmake index 1eded9cb48e..d8cd97d5043 100644 --- a/cmake/cpack_rpm.cmake +++ b/cmake/cpack_rpm.cmake @@ -125,7 +125,11 @@ SET(ignored "%ignore ${CMAKE_INSTALL_PREFIX}/share/pkgconfig" ) -SET(CPACK_RPM_server_USER_FILELIST ${ignored} "%config(noreplace) ${INSTALL_SYSCONF2DIR}/*") +SET(CPACK_RPM_server_USER_FILELIST + ${ignored} + "%config(noreplace) ${INSTALL_SYSCONF2DIR}/*" + "%config(noreplace) ${INSTALL_SYSCONFDIR}/logrotate.d/mysql" + ) SET(CPACK_RPM_common_USER_FILELIST ${ignored} "%config(noreplace) ${INSTALL_SYSCONFDIR}/my.cnf") SET(CPACK_RPM_shared_USER_FILELIST ${ignored} "%config(noreplace) ${INSTALL_SYSCONF2DIR}/*") SET(CPACK_RPM_client_USER_FILELIST ${ignored} "%config(noreplace) ${INSTALL_SYSCONF2DIR}/*") From e1c953ef23d010d5e2262524a2cfb57fd792e247 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 22 Jun 2021 15:25:58 +0300 Subject: [PATCH 157/251] MDEV-25989 Crash (or hang) on startup after restoring backup If an ALTER TABLE that affected a table with FULLTEXT INDEX was in progress while a backup was made, InnoDB would crash or hang during the first startup after restoring the backup, while trying to drop the #sql-alter- table for the DDL operation. drop_garbage_tables_after_restore(): Invoke dict_sys.unlock() before invoking the FTS functions. Also, invoke purge_sys.stop_FTS() in debug builds to silence debug assertions. (Purge is not yet running at this point.) --- .../suite/mariabackup/alter_copy_excluded.result | 15 +++++++-------- .../suite/mariabackup/alter_copy_excluded.test | 8 ++++---- storage/innobase/handler/ha_innodb.cc | 6 ++++++ 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/mysql-test/suite/mariabackup/alter_copy_excluded.result b/mysql-test/suite/mariabackup/alter_copy_excluded.result index 18e55f8d46b..45181e355d0 100644 --- a/mysql-test/suite/mariabackup/alter_copy_excluded.result +++ b/mysql-test/suite/mariabackup/alter_copy_excluded.result @@ -1,10 +1,10 @@ # xtrabackup backup -CREATE TABLE t1(i int) ENGINE=InnoDB; -INSERT into t1 values(1); +CREATE TABLE t1(i int, t text, fulltext index(t)) ENGINE=InnoDB; +INSERT into t1 values(1,'foo'); connect con2, localhost, root,,; connection con2; SET debug_sync='copy_data_between_tables_before_reset_backup_lock SIGNAL go WAIT_FOR after_backup_stage_block_commit' ; -SET debug_sync='now WAIT_FOR after_backup_stage_start';ALTER TABLE test.t1 FORCE, algorithm=COPY;| +SET debug_sync='now WAIT_FOR after_backup_stage_start';ALTER TABLE test.t1 DROP t, algorithm=COPY;| connection default; connection con2; SET debug_sync='RESET'; @@ -15,11 +15,10 @@ connection default; # remove datadir # xtrabackup move back # restart -SELECT COUNT(*) AS expect_0 FROM INFORMATION_SCHEMA.innodb_sys_tablespaces WHERE name like '%/#sql%'; -expect_0 -0 SELECT * FROM t1; -i -1 +i t +1 foo DROP TABLE t1; +SELECT * FROM INFORMATION_SCHEMA.innodb_sys_tablespaces WHERE name like '%/#sql%' or name like 'test/%'; +SPACE NAME FLAG ROW_FORMAT PAGE_SIZE FILENAME FS_BLOCK_SIZE FILE_SIZE ALLOCATED_SIZE # restart diff --git a/mysql-test/suite/mariabackup/alter_copy_excluded.test b/mysql-test/suite/mariabackup/alter_copy_excluded.test index 047b83fa66b..195aa09b5df 100644 --- a/mysql-test/suite/mariabackup/alter_copy_excluded.test +++ b/mysql-test/suite/mariabackup/alter_copy_excluded.test @@ -7,14 +7,14 @@ echo # xtrabackup backup; let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; -CREATE TABLE t1(i int) ENGINE=InnoDB; -INSERT into t1 values(1); +CREATE TABLE t1(i int, t text, fulltext index(t)) ENGINE=InnoDB; +INSERT into t1 values(1,'foo'); connect con2, localhost, root,,; connection con2; SET debug_sync='copy_data_between_tables_before_reset_backup_lock SIGNAL go WAIT_FOR after_backup_stage_block_commit' ; DELIMITER |; -send SET debug_sync='now WAIT_FOR after_backup_stage_start';ALTER TABLE test.t1 FORCE, algorithm=COPY;| +send SET debug_sync='now WAIT_FOR after_backup_stage_start';ALTER TABLE test.t1 DROP t, algorithm=COPY;| DELIMITER ;| connection default; @@ -53,9 +53,9 @@ exec $XTRABACKUP --prepare --target-dir=$targetdir; --enable_result_log # Check there are no temp tablespaces in sys_tablespaces, after backup -SELECT COUNT(*) AS expect_0 FROM INFORMATION_SCHEMA.innodb_sys_tablespaces WHERE name like '%/#sql%'; SELECT * FROM t1; DROP TABLE t1; +SELECT * FROM INFORMATION_SCHEMA.innodb_sys_tablespaces WHERE name like '%/#sql%' or name like 'test/%'; # Restart once again to clear first_start_after_backup flag # This is to catch potential warnings, since "missing file" for #sql is suppressed diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 4ca78884009..7606336ff26 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -1969,6 +1969,9 @@ static void drop_garbage_tables_after_restore() mtr_t mtr; trx_t *trx= trx_create(); + ut_ad(!purge_sys.enabled()); + ut_d(purge_sys.stop_FTS()); + mtr.start(); btr_pcur_open_at_index_side(true, dict_sys.sys_tables->indexes.start, BTR_SEARCH_LEAF, &pcur, true, 0, &mtr); @@ -2028,8 +2031,10 @@ static void drop_garbage_tables_after_restore() if (err == DB_SUCCESS && (table->flags2 & (DICT_TF2_FTS_HAS_DOC_ID | DICT_TF2_FTS))) { + dict_sys.unlock(); fts_optimize_remove_table(table); err= fts_lock_tables(trx, *table); + dict_sys.lock(SRW_LOCK_CALL); } table->release(); @@ -2058,6 +2063,7 @@ fail: btr_pcur_close(&pcur); mtr.commit(); trx->free(); + ut_d(purge_sys.resume_FTS()); } static void innodb_ddl_recovery_done(handlerton*) From 9fc67c6bf3b9af632cb80c836e3ec912778d8906 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 22 Jun 2021 17:52:54 +0300 Subject: [PATCH 158/251] MDEV-25950 Ignoring strange row from mysql.innodb_index_stats after DDL commit_try_rebuild(): Invoke trx_t::drop_table_statistics() with the correct (original) name of the table. This fixes a regression that was introduced in commit 1bd681c8b3c5213ce1f7976940a7dc38b48a0d39 (MDEV-25506 part 3). --- .../suite/innodb/r/instant_alter_index_rename.result | 12 ++++++++++++ .../suite/innodb/t/instant_alter_index_rename.test | 4 ++++ storage/innobase/handler/handler0alter.cc | 7 ++++--- 3 files changed, 20 insertions(+), 3 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 41dec275d90..c14043e0ad2 100644 --- a/mysql-test/suite/innodb/r/instant_alter_index_rename.result +++ b/mysql-test/suite/innodb/r/instant_alter_index_rename.result @@ -232,5 +232,17 @@ t1 ind3 n_diff_pfx01 t1 ind3 n_diff_pfx02 t1 ind3 n_leaf_pages t1 ind3 size +ALTER TABLE t1 DROP b, FORCE; +SELECT table_name, index_name, stat_name FROM mysql.innodb_index_stats; +table_name index_name stat_name +t1 GEN_CLUST_INDEX n_diff_pfx01 +t1 GEN_CLUST_INDEX n_leaf_pages +t1 GEN_CLUST_INDEX size +t1 ind2 n_diff_pfx01 +t1 ind2 n_diff_pfx02 +t1 ind2 n_leaf_pages +t1 ind2 size UPDATE t1 SET a = 1 WHERE c = 'foo'; DROP TABLE t1; +SELECT table_name, index_name, stat_name FROM mysql.innodb_index_stats; +table_name index_name stat_name 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 af66c1027cc..9772c859a20 100644 --- a/mysql-test/suite/innodb/t/instant_alter_index_rename.test +++ b/mysql-test/suite/innodb/t/instant_alter_index_rename.test @@ -225,5 +225,9 @@ ALTER TABLE t1 DROP INDEX ind2, ADD INDEX ind3(b), SELECT table_name, index_name, stat_name FROM mysql.innodb_index_stats; +ALTER TABLE t1 DROP b, FORCE; +SELECT table_name, index_name, stat_name FROM mysql.innodb_index_stats; + UPDATE t1 SET a = 1 WHERE c = 'foo'; DROP TABLE t1; +SELECT table_name, index_name, stat_name FROM mysql.innodb_index_stats; diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index e020955502e..b074c86b9d2 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -9961,10 +9961,11 @@ commit_try_rebuild( error = row_rename_table_for_mysql( rebuilt_table->name.m_name, old_name, trx, false); if (error == DB_SUCCESS) { - error = trx->drop_table_statistics( - ctx->old_table->name); + /* The statistics for the surviving indexes will be + re-inserted in alter_stats_rebuild(). */ + error = trx->drop_table_statistics(old_name); if (error == DB_SUCCESS) { - error = trx->drop_table(*ctx->old_table); + error = trx->drop_table(*user_table); } } } From 7f24e37fbecd5af08ec473a7a1449f305977c6d7 Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Tue, 22 Jun 2021 12:23:13 -0700 Subject: [PATCH 159/251] MDEV-25679 Wrong result selecting from simple view with LIMIT and ORDER BY Cherry-picking only test case. --- mysql-test/main/derived_view.result | 21 +++++++++++++++++++++ mysql-test/main/derived_view.test | 17 +++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/mysql-test/main/derived_view.result b/mysql-test/main/derived_view.result index 00940d88805..f761a9f92de 100644 --- a/mysql-test/main/derived_view.result +++ b/mysql-test/main/derived_view.result @@ -3480,3 +3480,24 @@ Warnings: Note 1003 select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`a` AS `a`,3 AS `d`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from `test`.`t1` join `test`.`t2` join `test`.`t3` where `test`.`t1`.`a` = 3 and `test`.`t1`.`pk` <= 2 drop view v1; drop table t1,t2,t3; +# +# MDEV-25679: view / derived table defined as ordered select with LIMIT +# +create table t1 (a int); +insert into t1 values (3), (7), (1); +create view v1 as (select a from t1 limit 2) order by a desc; +(select a from t1 limit 2) order by a desc; +a +7 +3 +select * from v1; +a +7 +3 +select * from ((select a from t1 limit 2) order by a desc) dt; +a +3 +7 +drop view v1; +drop table t1; +# End of 10.2 tests diff --git a/mysql-test/main/derived_view.test b/mysql-test/main/derived_view.test index 76b15fa8787..9ab1ddd3a76 100644 --- a/mysql-test/main/derived_view.test +++ b/mysql-test/main/derived_view.test @@ -2273,3 +2273,20 @@ eval explain extended $q; drop view v1; drop table t1,t2,t3; + +--echo # +--echo # MDEV-25679: view / derived table defined as ordered select with LIMIT +--echo # + +create table t1 (a int); +insert into t1 values (3), (7), (1); + +create view v1 as (select a from t1 limit 2) order by a desc; +(select a from t1 limit 2) order by a desc; +select * from v1; +select * from ((select a from t1 limit 2) order by a desc) dt; + +drop view v1; +drop table t1; + +--echo # End of 10.2 tests From f67aee000df284027a6ecbd0fa639da56ecf8545 Mon Sep 17 00:00:00 2001 From: Daniel Bartholomew Date: Tue, 22 Jun 2021 22:00:23 -0400 Subject: [PATCH 160/251] bump the VERSION --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 07913307754..456c22d6a3f 100644 --- a/VERSION +++ b/VERSION @@ -1,3 +1,3 @@ MYSQL_VERSION_MAJOR=10 MYSQL_VERSION_MINOR=2 -MYSQL_VERSION_PATCH=39 +MYSQL_VERSION_PATCH=40 From 1deb630484caf572c9cdf1b3c2d5bdd4eedc51d0 Mon Sep 17 00:00:00 2001 From: Daniel Bartholomew Date: Tue, 22 Jun 2021 22:21:24 -0400 Subject: [PATCH 161/251] bump the VERSION --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 238726a2d7d..53a575fa7f8 100644 --- a/VERSION +++ b/VERSION @@ -1,4 +1,4 @@ MYSQL_VERSION_MAJOR=10 MYSQL_VERSION_MINOR=3 -MYSQL_VERSION_PATCH=30 +MYSQL_VERSION_PATCH=31 SERVER_MATURITY=stable From bf2680ea09a81864e049eadee1381b4f04ee92f4 Mon Sep 17 00:00:00 2001 From: Daniel Bartholomew Date: Tue, 22 Jun 2021 22:42:42 -0400 Subject: [PATCH 162/251] bump the VERSION --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 716f6b385ed..b8a2d3b2f92 100644 --- a/VERSION +++ b/VERSION @@ -1,4 +1,4 @@ MYSQL_VERSION_MAJOR=10 MYSQL_VERSION_MINOR=4 -MYSQL_VERSION_PATCH=20 +MYSQL_VERSION_PATCH=21 SERVER_MATURITY=stable From 55b3a3f4dde61564f727a12ff89845825556956d Mon Sep 17 00:00:00 2001 From: Daniel Bartholomew Date: Tue, 22 Jun 2021 23:00:01 -0400 Subject: [PATCH 163/251] bump the VERSION --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index cf6ad8afb6e..34e37854e60 100644 --- a/VERSION +++ b/VERSION @@ -1,4 +1,4 @@ MYSQL_VERSION_MAJOR=10 MYSQL_VERSION_MINOR=5 -MYSQL_VERSION_PATCH=11 +MYSQL_VERSION_PATCH=12 SERVER_MATURITY=stable From 83464029cec28b4463309e18fa85974798719932 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Fri, 18 Jun 2021 10:16:38 +0300 Subject: [PATCH 164/251] Fix try for Galera test lp1376747-4 --- mysql-test/suite/galera/r/lp1376747-4.result | 2 +- mysql-test/suite/galera/t/lp1376747-4.test | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/suite/galera/r/lp1376747-4.result b/mysql-test/suite/galera/r/lp1376747-4.result index 3370e1d3d8e..efce740ea88 100644 --- a/mysql-test/suite/galera/r/lp1376747-4.result +++ b/mysql-test/suite/galera/r/lp1376747-4.result @@ -27,8 +27,8 @@ t1 CREATE TABLE `t1` ( `id` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 -set debug_sync= 'RESET'; connection node_2a; +set debug_sync= 'RESET'; UNLOCK TABLES; SET SESSION wsrep_sync_wait = DEFAULT; SHOW CREATE TABLE t1; diff --git a/mysql-test/suite/galera/t/lp1376747-4.test b/mysql-test/suite/galera/t/lp1376747-4.test index d19ff422ab0..724901da068 100644 --- a/mysql-test/suite/galera/t/lp1376747-4.test +++ b/mysql-test/suite/galera/t/lp1376747-4.test @@ -46,10 +46,10 @@ SET debug_sync='now SIGNAL go2'; # the cluster as there is new FTRL that is still pausing it. UNLOCK TABLES; SHOW CREATE TABLE t1; -set debug_sync= 'RESET'; --connection node_2a --reap +set debug_sync= 'RESET'; UNLOCK TABLES; SET SESSION wsrep_sync_wait = DEFAULT; From 9258cfa4b469ab0d841e32ced7e501e04043637f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Tue, 22 Jun 2021 15:44:44 +0300 Subject: [PATCH 165/251] MDEV-25978 : rsync SST does not work with custom binlog name wsrep_sst_common did not correctly set name for binlog index file if custom binlog name was used and this name was not added to script command line. Added test case for both log_basename and log_binlog. --- .../r/galera_sst_rsync_binlogname.result | 96 +++++++++++++++++++ .../r/galera_sst_rsync_logbasename.result | 96 +++++++++++++++++++ .../galera/t/galera_sst_rsync_binlogname.cnf | 12 +++ .../galera/t/galera_sst_rsync_binlogname.test | 9 ++ .../galera/t/galera_sst_rsync_logbasename.cnf | 15 +++ .../t/galera_sst_rsync_logbasename.test | 9 ++ scripts/wsrep_sst_common.sh | 11 ++- sql/wsrep_sst.cc | 17 +++- 8 files changed, 259 insertions(+), 6 deletions(-) create mode 100644 mysql-test/suite/galera/r/galera_sst_rsync_binlogname.result create mode 100644 mysql-test/suite/galera/r/galera_sst_rsync_logbasename.result create mode 100644 mysql-test/suite/galera/t/galera_sst_rsync_binlogname.cnf create mode 100644 mysql-test/suite/galera/t/galera_sst_rsync_binlogname.test create mode 100644 mysql-test/suite/galera/t/galera_sst_rsync_logbasename.cnf create mode 100644 mysql-test/suite/galera/t/galera_sst_rsync_logbasename.test diff --git a/mysql-test/suite/galera/r/galera_sst_rsync_binlogname.result b/mysql-test/suite/galera/r/galera_sst_rsync_binlogname.result new file mode 100644 index 00000000000..0f0a673947c --- /dev/null +++ b/mysql-test/suite/galera/r/galera_sst_rsync_binlogname.result @@ -0,0 +1,96 @@ +connection node_1; +connection node_2; +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; diff --git a/mysql-test/suite/galera/r/galera_sst_rsync_logbasename.result b/mysql-test/suite/galera/r/galera_sst_rsync_logbasename.result new file mode 100644 index 00000000000..0f0a673947c --- /dev/null +++ b/mysql-test/suite/galera/r/galera_sst_rsync_logbasename.result @@ -0,0 +1,96 @@ +connection node_1; +connection node_2; +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; diff --git a/mysql-test/suite/galera/t/galera_sst_rsync_binlogname.cnf b/mysql-test/suite/galera/t/galera_sst_rsync_binlogname.cnf new file mode 100644 index 00000000000..b1e4278dceb --- /dev/null +++ b/mysql-test/suite/galera/t/galera_sst_rsync_binlogname.cnf @@ -0,0 +1,12 @@ +!include ../galera_2nodes.cnf + +[mysqld] +wsrep_sst_method=rsync + +[mysqld.1] +wsrep_provider_options='base_port=@mysqld.1.#galera_port;gcache.size=1;pc.ignore_sb=true' +log_bin=server1_binlog + +[mysqld.2] +wsrep_provider_options='base_port=@mysqld.2.#galera_port;gcache.size=1;pc.ignore_sb=true' +log_bin=server2_binlog diff --git a/mysql-test/suite/galera/t/galera_sst_rsync_binlogname.test b/mysql-test/suite/galera/t/galera_sst_rsync_binlogname.test new file mode 100644 index 00000000000..b4ad6c43a0b --- /dev/null +++ b/mysql-test/suite/galera/t/galera_sst_rsync_binlogname.test @@ -0,0 +1,9 @@ +--source include/galera_cluster.inc + +--let $node_1=node_1 +--let $node_2=node_2 +--source include/auto_increment_offset_save.inc + +--source suite/galera/include/galera_st_shutdown_slave.inc + +--source include/auto_increment_offset_restore.inc diff --git a/mysql-test/suite/galera/t/galera_sst_rsync_logbasename.cnf b/mysql-test/suite/galera/t/galera_sst_rsync_logbasename.cnf new file mode 100644 index 00000000000..4f25af7cd8b --- /dev/null +++ b/mysql-test/suite/galera/t/galera_sst_rsync_logbasename.cnf @@ -0,0 +1,15 @@ +!include ../galera_2nodes.cnf + +[mysqld] +wsrep_sst_method=rsync + +[mysqld.1] +wsrep_provider_options='base_port=@mysqld.1.#galera_port;gcache.size=1;pc.ignore_sb=true' +log_basename=server1 +log_bin + +[mysqld.2] +wsrep_provider_options='base_port=@mysqld.2.#galera_port;gcache.size=1;pc.ignore_sb=true' +log_basename=server2 +log_bin + diff --git a/mysql-test/suite/galera/t/galera_sst_rsync_logbasename.test b/mysql-test/suite/galera/t/galera_sst_rsync_logbasename.test new file mode 100644 index 00000000000..b4ad6c43a0b --- /dev/null +++ b/mysql-test/suite/galera/t/galera_sst_rsync_logbasename.test @@ -0,0 +1,9 @@ +--source include/galera_cluster.inc + +--let $node_1=node_1 +--let $node_2=node_2 +--source include/auto_increment_offset_save.inc + +--source suite/galera/include/galera_st_shutdown_slave.inc + +--source include/auto_increment_offset_restore.inc diff --git a/scripts/wsrep_sst_common.sh b/scripts/wsrep_sst_common.sh index 4dedecb439f..bb9a3b9f1b6 100644 --- a/scripts/wsrep_sst_common.sh +++ b/scripts/wsrep_sst_common.sh @@ -465,8 +465,9 @@ if [ -z "$WSREP_SST_OPT_BINLOG" -a -n "${MYSQLD_OPT_LOG_BIN+x}" ]; then # the "-bin" suffix: readonly WSREP_SST_OPT_BINLOG="$WSREP_SST_OPT_LOG_BASENAME-bin" else - # Take the default name: - readonly WSREP_SST_OPT_BINLOG='mysql-bin' + # the default name, note that base of this name + # is already defined above + readonly WSREP_SST_OPT_BINLOG_INDEX="$WSREP_SST_OPT_BINLOG.index" fi fi @@ -549,9 +550,9 @@ get_binlog() # the "-bin" suffix: readonly WSREP_SST_OPT_BINLOG_INDEX="$WSREP_SST_OPT_LOG_BASENAME-bin.index" else - # If the base name not specified, then we take - # the default name: - readonly WSREP_SST_OPT_BINLOG_INDEX='mysql-bin.index' + # the default name, note that base of this name + # is already defined above + readonly WSREP_SST_OPT_BINLOG_INDEX="$WSREP_SST_OPT_BINLOG.index" fi fi fi diff --git a/sql/wsrep_sst.cc b/sql/wsrep_sst.cc index e844086f5e3..2258a4d8f6d 100644 --- a/sql/wsrep_sst.cc +++ b/sql/wsrep_sst.cc @@ -990,6 +990,8 @@ static ssize_t sst_prepare_other (const char* method, { WSREP_ERROR("sst_prepare_other(): generate_binlog_index_opt_val() failed %d", ret); + if (binlog_opt_val) my_free(binlog_opt_val); + return ret; } make_wsrep_defaults_file(); @@ -1007,6 +1009,7 @@ static ssize_t sst_prepare_other (const char* method, wsrep_defaults_file, (int)getpid(), binlog_opt_val, binlog_index_opt_val); + my_free(binlog_opt_val); my_free(binlog_index_opt_val); @@ -1655,6 +1658,7 @@ static int sst_donate_other (const char* method, } char* binlog_opt_val= NULL; + char* binlog_index_opt_val= NULL; int ret; if ((ret= generate_binlog_opt_val(&binlog_opt_val))) @@ -1663,6 +1667,14 @@ static int sst_donate_other (const char* method, return ret; } + if ((ret= generate_binlog_index_opt_val(&binlog_index_opt_val))) + { + WSREP_ERROR("sst_prepare_other(): generate_binlog_index_opt_val() failed %d", + ret); + if (binlog_opt_val) my_free(binlog_opt_val); + return ret; + } + make_wsrep_defaults_file(); ret= snprintf (cmd_str(), cmd_len, @@ -1676,14 +1688,17 @@ static int sst_donate_other (const char* method, WSREP_SST_OPT_GTID " '%s:%lld' " WSREP_SST_OPT_GTID_DOMAIN_ID " '%d'" "%s" + "%s" "%s", method, addr, mysqld_port, mysqld_unix_port, mysql_real_data_home, wsrep_defaults_file, uuid, (long long) seqno, wsrep_gtid_domain_id, - binlog_opt_val, + binlog_opt_val, binlog_index_opt_val, bypass ? " " WSREP_SST_OPT_BYPASS : ""); + my_free(binlog_opt_val); + my_free(binlog_index_opt_val); if (ret < 0 || size_t(ret) >= cmd_len) { From 592a925c0c467fdbcd0b73ed152c1c2dda46c866 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 23 Jun 2021 13:36:04 +0300 Subject: [PATCH 166/251] MDEV-25996 sux_lock::s_lock(): Assertion !have_s() failed on startup dict_check_sys_tables(): Correctly advance the cursor position. This fixes a regression that was caused by commit 49e2c8f0a6fefdeac50925f758090d6bd099768d (MDEV-25743). --- storage/innobase/dict/dict0load.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/innobase/dict/dict0load.cc b/storage/innobase/dict/dict0load.cc index ac81de9a25c..db11f4ff003 100644 --- a/storage/innobase/dict/dict0load.cc +++ b/storage/innobase/dict/dict0load.cc @@ -834,7 +834,7 @@ static ulint dict_check_sys_tables() for (const rec_t *rec = dict_startscan_system(&pcur, &mtr, dict_sys.sys_tables); - rec; rec = dict_getnext_system(&pcur, &mtr)) { + rec; rec = dict_getnext_system_low(&pcur, &mtr)) { ulint len; table_id_t table_id; ulint space_id; From b3e8788009404f60c3d461c323a1d8a2ccd4b8c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 23 Jun 2021 13:37:11 +0300 Subject: [PATCH 167/251] MDEV-25967: Correctly extend deferred-recovery files recv_sys_t::recover_deferred(): Set the file size to match the number of pages. Mariabackup might copy the file while it was being extended. --- storage/innobase/log/log0recv.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc index 69214139fda..16250928845 100644 --- a/storage/innobase/log/log0recv.cc +++ b/storage/innobase/log/log0recv.cc @@ -837,13 +837,18 @@ bool recv_sys_t::recover_deferred(recv_sys_t::map::iterator &p, block->unfix(); fil_node_t *node= UT_LIST_GET_FIRST(space->chain); node->deferred= true; - if (space->acquire()) + if (!space->acquire()) + goto fail; + if (!os_file_set_size(node->name, node->handle, + size * fil_space_t::physical_size(flags), + space->is_compressed())) { - node->deferred= false; space->release(); - return false; + goto fail; } - goto fail; + node->deferred= false; + space->release(); + return false; } block->unfix(); From 6e12ebd4a748eba738e08ad1d7f5dec782ff63ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 23 Jun 2021 13:42:11 +0300 Subject: [PATCH 168/251] MDEV-25062: Reduce trx_rseg_t::mutex contention redo_rseg_mutex, noredo_rseg_mutex: Remove the PERFORMANCE_SCHEMA keys. The rollback segment mutex will be uninstrumented. trx_sys_t: Remove pointer indirection for rseg_array, temp_rseg. Align each element to the cache line. trx_sys_t::rseg_id(): Replaces trx_rseg_t::id. trx_rseg_t::ref: Replaces needs_purge, trx_ref_count, skip_allocation in a single std::atomic. trx_rseg_t::latch: Replaces trx_rseg_t::mutex. trx_rseg_t::history_size: Replaces trx_sys_t::rseg_history_len trx_sys_t::history_size_approx(): Replaces trx_sys.rseg_history_len in those places where the exact count does not matter. We must not acquire any trx_rseg_t::latch while holding index page latches, because normally the trx_rseg_t::latch is acquired before any page latches. trx_sys_t::history_exists(): Replaces trx_sys.rseg_history_len!=0 with an approximation. We remove some unnecessary trx_rseg_t::latch acquisition around trx_undo_set_state_at_prepare() and trx_undo_set_state_at_finish(). Those operations will only access fields that remain constant after trx_rseg_t::init(). --- storage/innobase/btr/btr0cur.cc | 15 ++- storage/innobase/handler/ha_innodb.cc | 10 +- storage/innobase/include/trx0purge.h | 2 +- storage/innobase/include/trx0rseg.h | 175 +++++++++++++----------- storage/innobase/include/trx0sys.h | 76 +++++++---- storage/innobase/include/trx0types.h | 6 + storage/innobase/lock/lock0lock.cc | 2 +- storage/innobase/row/row0purge.cc | 10 +- storage/innobase/row/row0undo.cc | 9 +- storage/innobase/srv/srv0mon.cc | 27 +--- storage/innobase/srv/srv0srv.cc | 37 +++--- storage/innobase/trx/trx0purge.cc | 182 ++++++++++--------------- storage/innobase/trx/trx0rec.cc | 11 +- storage/innobase/trx/trx0roll.cc | 2 - storage/innobase/trx/trx0rseg.cc | 184 ++++++++++---------------- storage/innobase/trx/trx0sys.cc | 117 +++++++++++++--- storage/innobase/trx/trx0trx.cc | 66 +++------ storage/innobase/trx/trx0undo.cc | 40 ++---- 18 files changed, 477 insertions(+), 494 deletions(-) diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc index 4ceeec9205e..a2cd3253782 100644 --- a/storage/innobase/btr/btr0cur.cc +++ b/storage/innobase/btr/btr0cur.cc @@ -1462,8 +1462,9 @@ btr_cur_search_to_nth_level_func( Free blocks and read IO bandwidth should be prior for them, when the history list is glowing huge. */ if (lock_intention == BTR_INTENTION_DELETE - && trx_sys.rseg_history_len > BTR_CUR_FINE_HISTORY_LENGTH - && buf_pool.n_pend_reads) { + && buf_pool.n_pend_reads + && trx_sys.history_size_approx() + > BTR_CUR_FINE_HISTORY_LENGTH) { x_latch_index: mtr_x_lock_index(index, mtr); } else if (index->is_spatial() @@ -2575,8 +2576,9 @@ btr_cur_open_at_index_side( Free blocks and read IO bandwidth should be prior for them, when the history list is glowing huge. */ if (lock_intention == BTR_INTENTION_DELETE - && trx_sys.rseg_history_len > BTR_CUR_FINE_HISTORY_LENGTH - && buf_pool.n_pend_reads) { + && buf_pool.n_pend_reads + && trx_sys.history_size_approx() + > BTR_CUR_FINE_HISTORY_LENGTH) { mtr_x_lock_index(index, mtr); } else { mtr_sx_lock_index(index, mtr); @@ -2898,8 +2900,9 @@ btr_cur_open_at_rnd_pos( Free blocks and read IO bandwidth should be prior for them, when the history list is glowing huge. */ if (lock_intention == BTR_INTENTION_DELETE - && trx_sys.rseg_history_len > BTR_CUR_FINE_HISTORY_LENGTH - && buf_pool.n_pend_reads) { + && buf_pool.n_pend_reads + && trx_sys.history_size_approx() + > BTR_CUR_FINE_HISTORY_LENGTH) { mtr_x_lock_index(index, mtr); } else { mtr_sx_lock_index(index, mtr); diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 7606336ff26..019859687b8 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -216,15 +216,15 @@ static my_bool innodb_read_only_compressed; /** A dummy variable */ static uint innodb_max_purge_lag_wait; -/** Wait for trx_sys_t::rseg_history_len to be below a limit. */ +/** Wait for trx_sys.history_size() to be below a limit. */ static void innodb_max_purge_lag_wait_update(THD *thd, st_mysql_sys_var *, void *, const void *limit) { const uint l= *static_cast(limit); - if (trx_sys.rseg_history_len <= l) + if (!trx_sys.history_exceeds(l)) return; mysql_mutex_unlock(&LOCK_global_system_variables); - while (trx_sys.rseg_history_len > l) + while (trx_sys.history_exceeds(l)) { if (thd_kill_level(thd)) break; @@ -520,8 +520,6 @@ mysql_pfs_key_t log_flush_order_mutex_key; mysql_pfs_key_t recalc_pool_mutex_key; mysql_pfs_key_t purge_sys_pq_mutex_key; mysql_pfs_key_t recv_sys_mutex_key; -mysql_pfs_key_t redo_rseg_mutex_key; -mysql_pfs_key_t noredo_rseg_mutex_key; mysql_pfs_key_t page_zip_stat_per_index_mutex_key; mysql_pfs_key_t rtr_active_mutex_key; mysql_pfs_key_t rtr_match_mutex_key; @@ -564,8 +562,6 @@ static PSI_mutex_info all_innodb_mutexes[] = { PSI_KEY(page_zip_stat_per_index_mutex), PSI_KEY(purge_sys_pq_mutex), PSI_KEY(recv_sys_mutex), - PSI_KEY(redo_rseg_mutex), - PSI_KEY(noredo_rseg_mutex), PSI_KEY(srv_innodb_monitor_mutex), PSI_KEY(srv_misc_tmpfile_mutex), PSI_KEY(srv_monitor_file_mutex), diff --git a/storage/innobase/include/trx0purge.h b/storage/innobase/include/trx0purge.h index c6c824d8aee..c2c755e183a 100644 --- a/storage/innobase/include/trx0purge.h +++ b/storage/innobase/include/trx0purge.h @@ -27,7 +27,7 @@ Created 3/26/1996 Heikki Tuuri #ifndef trx0purge_h #define trx0purge_h -#include "trx0rseg.h" +#include "trx0sys.h" #include "que0types.h" #include "srw_lock.h" diff --git a/storage/innobase/include/trx0rseg.h b/storage/innobase/include/trx0rseg.h index 10c5df8233c..02e6f290c56 100644 --- a/storage/innobase/include/trx0rseg.h +++ b/storage/innobase/include/trx0rseg.h @@ -24,16 +24,12 @@ Rollback segment Created 3/26/1996 Heikki Tuuri *******************************************************/ -#ifndef trx0rseg_h -#define trx0rseg_h - -#include "trx0sys.h" +#pragma once +#include "trx0types.h" #include "fut0lst.h" - -#ifdef UNIV_PFS_MUTEX -extern mysql_pfs_key_t redo_rseg_mutex_key; -extern mysql_pfs_key_t noredo_rseg_mutex_key; -#endif /* UNIV_PFS_MUTEX */ +#ifdef WITH_WSREP +# include "trx0xa.h" +#endif /* WITH_WSREP */ /** Gets a rollback segment header. @param[in] space space where placed @@ -73,21 +69,8 @@ trx_rseg_header_create( /** Initialize or recover the rollback segments at startup. */ dberr_t trx_rseg_array_init(); -/** Free a rollback segment in memory. */ -void -trx_rseg_mem_free(trx_rseg_t* rseg); - -/** Create a persistent rollback segment. -@param[in] space_id system or undo tablespace id -@return pointer to new rollback segment -@retval NULL on failure */ -trx_rseg_t* -trx_rseg_create(ulint space_id) - MY_ATTRIBUTE((warn_unused_result)); - /** Create the temporary rollback segments. */ -void -trx_temp_rseg_create(); +void trx_temp_rseg_create(); /* Number of undo log slots in a rollback segment file copy */ #define TRX_RSEG_N_SLOTS (srv_page_size / 16) @@ -96,34 +79,93 @@ trx_temp_rseg_create(); #define TRX_RSEG_MAX_N_TRXS (TRX_RSEG_N_SLOTS / 2) /** The rollback segment memory object */ -struct trx_rseg_t { - /*--------------------------------------------------------*/ - /** rollback segment id == the index of its slot in the trx - system file copy */ - ulint id; +struct MY_ALIGNED(CPU_LEVEL1_DCACHE_LINESIZE) trx_rseg_t +{ + /** tablespace containing the rollback segment; constant after init() */ + fil_space_t *space; + /** latch protecting everything except page_no, space */ + srw_lock_low latch; + /** rollback segment header page number; constant after init() */ + uint32_t page_no; + /** length of the TRX_RSEG_HISTORY list (number of transactions) */ + uint32_t history_size; - /** mutex protecting the fields in this struct except id,space,page_no - which are constant */ - mysql_mutex_t mutex; +private: + /** Reference counter to track rseg allocated transactions, + with SKIP and NEEDS_PURGE flags. */ + std::atomic ref; - /** space where the rollback segment header is placed */ - fil_space_t* space; + /** Whether undo tablespace truncation is pending */ + static constexpr uint32_t SKIP= 1; + /** Whether the log segment needs purge */ + static constexpr uint32_t NEEDS_PURGE= 2; + /** Transaction reference count multiplier */ + static constexpr uint32_t REF= 4; - /** page number of the rollback segment header */ - uint32_t page_no; + uint32_t ref_load() const { return ref.load(std::memory_order_relaxed); } +public: - /** current size in pages */ - uint32_t curr_size; + /** Initialize the fields that are not zero-initialized. */ + void init(fil_space_t *space, uint32_t page); + /** Reinitialize the fields on undo tablespace truncation. */ + void reinit(uint32_t page); + /** Clean up. */ + void destroy(); - /*--------------------------------------------------------*/ - /* Fields for undo logs */ - /** List of undo logs */ - UT_LIST_BASE_NODE_T(trx_undo_t) undo_list; + /** Note that undo tablespace truncation was started. */ + void set_skip_allocation() + { ut_ad(is_persistent()); ref.fetch_or(SKIP, std::memory_order_relaxed); } + /** Note that undo tablespace truncation was completed. */ + void clear_skip_allocation() + { + ut_ad(is_persistent()); + ut_d(auto r=) ref.fetch_and(~SKIP, std::memory_order_relaxed); + ut_ad(r == SKIP); + } + /** Note that the rollback segment requires purge. */ + void set_needs_purge() + { ref.fetch_or(NEEDS_PURGE, std::memory_order_relaxed); } + /** Note that the rollback segment will not require purge. */ + void clear_needs_purge() + { ref.fetch_and(~NEEDS_PURGE, std::memory_order_relaxed); } + /** @return whether the segment is marked for undo truncation */ + bool skip_allocation() const { return ref_load() & SKIP; } + /** @return whether the segment needs purge */ + bool needs_purge() const { return ref_load() & NEEDS_PURGE; } + /** Increment the reference count */ + void acquire() + { ut_d(auto r=) ref.fetch_add(REF); ut_ad(!(r & SKIP)); } + /** Increment the reference count if possible + @retval true if the reference count was incremented + @retval false if skip_allocation() holds */ + bool acquire_if_available() + { + uint32_t r= 0; + while (!ref.compare_exchange_weak(r, r + REF, + std::memory_order_relaxed, + std::memory_order_relaxed)) + if (r & SKIP) + return false; + return true; + } - /** List of undo log segments cached for fast reuse */ - UT_LIST_BASE_NODE_T(trx_undo_t) undo_cached; + /** Decrement the reference count */ + void release() + { + ut_d(const auto r=) + ref.fetch_sub(REF, std::memory_order_relaxed); + ut_ad(r >= REF); + } + /** @return whether references exist */ + bool is_referenced() const { return ref_load() >= REF; } - /*--------------------------------------------------------*/ + /** current size in pages */ + uint32_t curr_size; + + /** List of undo logs (transactions) */ + UT_LIST_BASE_NODE_T(trx_undo_t) undo_list; + /** List of undo log segments cached for fast reuse */ + UT_LIST_BASE_NODE_T(trx_undo_t) undo_cached; /** Last not yet purged undo log header; FIL_NULL if all purged */ uint32_t last_page_no; @@ -131,16 +173,6 @@ struct trx_rseg_t { /** trx_t::no | last_offset << 48 */ uint64_t last_commit_and_offset; - /** Whether the log segment needs purge */ - bool needs_purge; - - /** Reference counter to track rseg allocated transactions. */ - ulint trx_ref_count; - - /** If true, then skip allocating this rseg as it reside in - UNDO-tablespace marked for truncate. */ - bool skip_allocation; - /** @return the commit ID of the last committed transaction */ trx_id_t last_trx_no() const { return last_commit_and_offset & ((1ULL << 48) - 1); } @@ -153,24 +185,21 @@ struct trx_rseg_t { last_commit_and_offset= static_cast(last_offset) << 48 | trx_no; } - /** @return whether the rollback segment is persistent */ - bool is_persistent() const - { - ut_ad(space == fil_system.temp_space - || space == fil_system.sys_space - || (srv_undo_space_id_start > 0 - && space->id >= srv_undo_space_id_start - && space->id <= srv_undo_space_id_start - + TRX_SYS_MAX_UNDO_SPACES)); - ut_ad(space == fil_system.temp_space - || space == fil_system.sys_space - || (srv_undo_space_id_start > 0 - && space->id >= srv_undo_space_id_start - && space->id <= srv_undo_space_id_start - + srv_undo_tablespaces_open) - || !srv_was_started); - return(space->id != SRV_TMP_SPACE_ID); - } + /** @return whether the rollback segment is persistent */ + bool is_persistent() const + { + ut_ad(space == fil_system.temp_space || space == fil_system.sys_space || + (srv_undo_space_id_start > 0 && + space->id >= srv_undo_space_id_start && + space->id <= srv_undo_space_id_start + TRX_SYS_MAX_UNDO_SPACES)); + ut_ad(space == fil_system.temp_space || space == fil_system.sys_space || + !srv_was_started || + (srv_undo_space_id_start > 0 && + space->id >= srv_undo_space_id_start + && space->id <= srv_undo_space_id_start + + srv_undo_tablespaces_open)); + return space->id != SRV_TMP_SPACE_ID; + } }; /* Undo log segment slot in a rollback segment header */ @@ -278,5 +307,3 @@ void trx_rseg_update_binlog_offset(buf_block_t *rseg_header, const trx_t *trx, mtr_t *mtr); #include "trx0rseg.ic" - -#endif diff --git a/storage/innobase/include/trx0sys.h b/storage/innobase/include/trx0sys.h index d687f783db5..93cc1fb9019 100644 --- a/storage/innobase/include/trx0sys.h +++ b/storage/innobase/include/trx0sys.h @@ -27,7 +27,7 @@ Created 3/26/1996 Heikki Tuuri #pragma once #include "buf0buf.h" #include "fil0fil.h" -#include "trx0types.h" +#include "trx0rseg.h" #include "mem0mem.h" #include "mtr0mtr.h" #include "ut0byte.h" @@ -35,9 +35,6 @@ Created 3/26/1996 Heikki Tuuri #include "read0types.h" #include "page0types.h" #include "trx0trx.h" -#ifdef WITH_WSREP -#include "trx0xa.h" -#endif /* WITH_WSREP */ #include "ilist.h" #include "my_cpu.h" @@ -157,13 +154,6 @@ from older MySQL or MariaDB versions. */ /*!< the start of the array of rollback segment specification slots */ -/*------------------------------------------------------------- @} */ - -/** The number of rollback segments; rollback segment id must fit in -the 7 bits reserved for it in DB_ROLL_PTR. */ -#define TRX_SYS_N_RSEGS 128 -/** Maximum number of undo tablespaces (not counting the system tablespace) */ -#define TRX_SYS_MAX_UNDO_SPACES (TRX_SYS_N_RSEGS - 1) /* Rollback segment specification slot offsets */ @@ -871,26 +861,14 @@ class trx_sys_t bool m_initialised; public: - /** - TRX_RSEG_HISTORY list length (number of committed transactions to purge) - */ - MY_ALIGNED(CACHE_LINE_SIZE) Atomic_counter rseg_history_len; - /** List of all transactions. */ thread_safe_trx_ilist_t trx_list; - MY_ALIGNED(CACHE_LINE_SIZE) - /** Temporary rollback segments */ - trx_rseg_t* temp_rsegs[TRX_SYS_N_RSEGS]; + /** Temporary rollback segments */ + trx_rseg_t temp_rsegs[TRX_SYS_N_RSEGS]; - MY_ALIGNED(CACHE_LINE_SIZE) - trx_rseg_t* rseg_array[TRX_SYS_N_RSEGS]; - /*!< Pointer array to rollback - segments; NULL if slot not in use; - created and destroyed in - single-threaded mode; not protected - by any mutex, because it is read-only - during multi-threaded operation */ + /** Persistent rollback segments; space==nullptr if slot not in use */ + trx_rseg_t rseg_array[TRX_SYS_N_RSEGS]; /** Lock-free hash of in memory read-write transactions. @@ -922,6 +900,32 @@ public: trx_sys_t(): m_initialised(false) {} + /** + @return TRX_RSEG_HISTORY length (number of committed transactions to purge) + */ + uint32_t history_size(); + + + /** + Check whether history_size() exceeds a specified number. + @param threshold number of committed transactions + @return whether TRX_RSEG_HISTORY length exceeds the threshold + */ + bool history_exceeds(uint32_t threshold); + + + /** + @return approximate history_size(), without latch protection + */ + TPOOL_SUPPRESS_TSAN uint32_t history_size_approx() const; + + + /** + @return whether history_size() is nonzero (with some race condition) + */ + TPOOL_SUPPRESS_TSAN bool history_exists(); + + /** Returns the minimum trx id in rw trx list. @@ -1043,7 +1047,7 @@ public: } - bool is_initialised() { return m_initialised; } + bool is_initialised() const { return m_initialised; } /** Initialise the transaction subsystem. */ @@ -1056,6 +1060,22 @@ public: ulint any_active_transactions(); + /** + Determine the rollback segment identifier. + + @param rseg rollback segment + @param persistent whether the rollback segment is persistent + @return the rollback segment identifier + */ + unsigned rseg_id(const trx_rseg_t *rseg, bool persistent) const + { + const trx_rseg_t *array= persistent ? rseg_array : temp_rsegs; + ut_ad(rseg >= array); + ut_ad(rseg < &array[TRX_SYS_N_RSEGS]); + return static_cast(rseg - array); + } + + /** Registers read-write transaction. diff --git a/storage/innobase/include/trx0types.h b/storage/innobase/include/trx0types.h index 01321778c10..07c1c6a756b 100644 --- a/storage/innobase/include/trx0types.h +++ b/storage/innobase/include/trx0types.h @@ -108,3 +108,9 @@ typedef byte trx_undo_rec_t; /* @} */ typedef std::vector > trx_ids_t; + +/** The number of rollback segments; rollback segment id must fit in +the 7 bits reserved for it in DB_ROLL_PTR. */ +static constexpr unsigned TRX_SYS_N_RSEGS= 128; +/** Maximum number of undo tablespaces (not counting the system tablespace) */ +static constexpr unsigned TRX_SYS_MAX_UNDO_SPACES= TRX_SYS_N_RSEGS - 1; diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc index 887544fcdb3..e455c6ac4af 100644 --- a/storage/innobase/lock/lock0lock.cc +++ b/storage/innobase/lock/lock0lock.cc @@ -4146,7 +4146,7 @@ lock_print_info_summary( ? (purge_sys.running() ? "running" : purge_sys.paused() ? "stopped" : "running but idle") : "disabled", - uint32_t{trx_sys.rseg_history_len}); + trx_sys.history_size()); #ifdef PRINT_NUM_OF_LOCK_STRUCTS fprintf(file, diff --git a/storage/innobase/row/row0purge.cc b/storage/innobase/row/row0purge.cc index 1269c7ae86e..d07288a9e23 100644 --- a/storage/innobase/row/row0purge.cc +++ b/storage/innobase/row/row0purge.cc @@ -893,7 +893,6 @@ skip_secondaries: = upd_get_nth_field(node->update, i); if (dfield_is_ext(&ufield->new_val)) { - trx_rseg_t* rseg; buf_block_t* block; byte* data_field; bool is_insert; @@ -918,11 +917,8 @@ skip_secondaries: &is_insert, &rseg_id, &page_no, &offset); - rseg = trx_sys.rseg_array[rseg_id]; - - ut_a(rseg != NULL); - ut_ad(rseg->id == rseg_id); - ut_ad(rseg->is_persistent()); + const trx_rseg_t &rseg = trx_sys.rseg_array[rseg_id]; + ut_ad(rseg.is_persistent()); mtr.start(); @@ -945,7 +941,7 @@ skip_secondaries: btr_root_get(index, &mtr); block = buf_page_get( - page_id_t(rseg->space->id, page_no), + page_id_t(rseg.space->id, page_no), 0, RW_X_LATCH, &mtr); data_field = buf_block_get_frame(block) diff --git a/storage/innobase/row/row0undo.cc b/storage/innobase/row/row0undo.cc index f81f8ebd8d0..4e51a811a49 100644 --- a/storage/innobase/row/row0undo.cc +++ b/storage/innobase/row/row0undo.cc @@ -287,6 +287,7 @@ static bool row_undo_rec_get(undo_node_t* node) trx_undo_t* update = trx->rsegs.m_redo.undo; trx_undo_t* temp = trx->rsegs.m_noredo.undo; const undo_no_t limit = trx->roll_limit; + bool is_temp = false; ut_ad(!update || !temp || update->empty() || temp->empty() || update->top_undo_no != temp->top_undo_no); @@ -300,10 +301,9 @@ static bool row_undo_rec_get(undo_node_t* node) } if (temp && !temp->empty() && temp->top_undo_no >= limit) { - if (!undo) { - undo = temp; - } else if (undo->top_undo_no < temp->top_undo_no) { + if (!undo || undo->top_undo_no < temp->top_undo_no) { undo = temp; + is_temp = true; } } @@ -321,7 +321,8 @@ static bool row_undo_rec_get(undo_node_t* node) ut_ad(limit <= undo->top_undo_no); node->roll_ptr = trx_undo_build_roll_ptr( - false, undo->rseg->id, undo->top_page_no, undo->top_offset); + false, trx_sys.rseg_id(undo->rseg, !is_temp), + undo->top_page_no, undo->top_offset); mtr_t mtr; mtr.start(); diff --git a/storage/innobase/srv/srv0mon.cc b/storage/innobase/srv/srv0mon.cc index 50d9ebff962..d377d2d7b28 100644 --- a/storage/innobase/srv/srv0mon.cc +++ b/storage/innobase/srv/srv0mon.cc @@ -1387,27 +1387,12 @@ srv_mon_set_module_control( /****************************************************************//** Get transaction system's rollback segment size in pages @return size in pages */ -static -ulint -srv_mon_get_rseg_size(void) -/*=======================*/ +TPOOL_SUPPRESS_TSAN static ulint srv_mon_get_rseg_size() { - ulint i; - ulint value = 0; - - /* rseg_array is a static array, so we can go through it without - mutex protection. In addition, we provide an estimate of the - total rollback segment size and to avoid mutex contention we - don't acquire the rseg->mutex" */ - for (i = 0; i < TRX_SYS_N_RSEGS; ++i) { - const trx_rseg_t* rseg = trx_sys.rseg_array[i]; - - if (rseg != NULL) { - value += rseg->curr_size; - } - } - - return(value); + ulint size= 0; + for (const auto &rseg : trx_sys.rseg_array) + size+= rseg.curr_size; + return size; } /****************************************************************//** @@ -1719,7 +1704,7 @@ srv_mon_process_existing_counter( break; case MONITOR_RSEG_HISTORY_LEN: - value = trx_sys.rseg_history_len; + value = trx_sys.history_size(); break; case MONITOR_RSEG_CUR_SIZE: diff --git a/storage/innobase/srv/srv0srv.cc b/storage/innobase/srv/srv0srv.cc index 2bcd6c52935..446314b9ab9 100644 --- a/storage/innobase/srv/srv0srv.cc +++ b/storage/innobase/srv/srv0srv.cc @@ -1074,7 +1074,7 @@ srv_export_innodb_status(void) - UT_LIST_GET_LEN(buf_pool.free); export_vars.innodb_max_trx_id = trx_sys.get_max_trx_id(); - export_vars.innodb_history_list_length = trx_sys.rseg_history_len; + export_vars.innodb_history_list_length = trx_sys.history_size(); export_vars.innodb_log_waits = srv_stats.log_waits; @@ -1353,7 +1353,7 @@ srv_wake_purge_thread_if_not_active() ut_ad(!srv_read_only_mode); if (purge_sys.enabled() && !purge_sys.paused() - && trx_sys.rseg_history_len) { + && trx_sys.history_exists()) { if(++purge_state.m_running == 1) { srv_thread_pool->submit_task(&purge_coordinator_task); } @@ -1723,7 +1723,8 @@ static bool srv_purge_should_exit() return true; /* Slow shutdown was requested. */ - if (const uint32_t history_size= trx_sys.rseg_history_len) + const uint32_t history_size= trx_sys.history_size(); + if (history_size) { static time_t progress_time; time_t now= time(NULL); @@ -1817,10 +1818,9 @@ static uint32_t srv_do_purge(ulint* n_total_purged) std::lock_guard lk(purge_thread_count_mtx); n_threads = n_use_threads = srv_n_purge_threads; srv_purge_thread_count_changed = 0; - } else if (trx_sys.rseg_history_len > rseg_history_len - || (srv_max_purge_lag > 0 - && rseg_history_len > srv_max_purge_lag)) { - + } else if (trx_sys.history_size_approx() > rseg_history_len + || (srv_max_purge_lag > 0 + && rseg_history_len > srv_max_purge_lag)) { /* History length is now longer than what it was when we took the last snapshot. Use more threads. */ @@ -1844,7 +1844,7 @@ static uint32_t srv_do_purge(ulint* n_total_purged) ut_a(n_use_threads <= n_threads); /* Take a snapshot of the history list before purge. */ - if (!(rseg_history_len = trx_sys.rseg_history_len)) { + if (!(rseg_history_len = trx_sys.history_size())) { break; } @@ -1894,24 +1894,21 @@ void release_thd(THD *thd, void *ctx) } -/* +/** Called by timer when purge coordinator decides to delay processing of purge records. */ static void purge_coordinator_timer_callback(void *) { - if (!purge_sys.enabled() || purge_sys.paused() || - purge_state.m_running || !trx_sys.rseg_history_len) + if (!purge_sys.enabled() || purge_sys.paused() || purge_state.m_running) return; - if (purge_state.m_history_length < 5000 && - purge_state.m_history_length == trx_sys.rseg_history_len) - /* No new records were added since wait started. - Simply wait for new records. The magic number 5000 is an - approximation for the case where we have cached UNDO - log records which prevent truncate of the UNDO segments.*/ - return; - srv_wake_purge_thread_if_not_active(); + /* The magic number 5000 is an approximation for the case where we have + cached undo log records which prevent truncate of the rollback segments. */ + if (const auto history_size= trx_sys.history_size()) + if (purge_state.m_history_length >= 5000 || + purge_state.m_history_length != history_size) + srv_wake_purge_thread_if_not_active(); } static void purge_worker_callback(void*) @@ -1949,7 +1946,7 @@ static void purge_coordinator_callback_low() someone added work and woke us up. */ if (n_total_purged == 0) { - if (trx_sys.rseg_history_len == 0) + if (trx_sys.history_size() == 0) return; if (!woken_during_purge) { diff --git a/storage/innobase/trx/trx0purge.cc b/storage/innobase/trx/trx0purge.cc index a7044dd60c5..9e6c2741b99 100644 --- a/storage/innobase/trx/trx0purge.cc +++ b/storage/innobase/trx/trx0purge.cc @@ -110,7 +110,7 @@ inline bool TrxUndoRsegsIterator::set_next() purge_sys.rseg = *m_iter++; mysql_mutex_unlock(&purge_sys.pq_mutex); - mysql_mutex_lock(&purge_sys.rseg->mutex); + purge_sys.rseg->latch.rd_lock(); ut_a(purge_sys.rseg->last_page_no != FIL_NULL); ut_ad(purge_sys.rseg->last_trx_no() == m_rsegs.trx_no); @@ -126,8 +126,7 @@ inline bool TrxUndoRsegsIterator::set_next() purge_sys.hdr_offset = purge_sys.rseg->last_offset(); purge_sys.hdr_page_no = purge_sys.rseg->last_page_no; - mysql_mutex_unlock(&purge_sys.rseg->mutex); - + purge_sys.rseg->latch.rd_unlock(); return(true); } @@ -312,10 +311,10 @@ trx_purge_add_undo_to_history(const trx_t* trx, trx_undo_t*& undo, mtr_t* mtr) rseg->last_page_no = undo->hdr_page_no; rseg->set_last_commit(undo->hdr_offset, trx->rw_trx_hash_element->no); - rseg->needs_purge = true; + rseg->set_needs_purge(); } - trx_sys.rseg_history_len++; + rseg->history_size++; if (undo->state == TRX_UNDO_CACHED) { UT_LIST_ADD_FIRST(rseg->undo_cached, undo); @@ -338,24 +337,25 @@ static void trx_purge_remove_log_hdr(buf_block_t *rseg, buf_block_t* log, { flst_remove(rseg, TRX_RSEG + TRX_RSEG_HISTORY, log, static_cast(offset + TRX_UNDO_HISTORY_NODE), mtr); - trx_sys.rseg_history_len--; } /** Free an undo log segment, and remove the header from the history list. @param[in,out] rseg rollback segment @param[in] hdr_addr file address of log_hdr */ -static -void -trx_purge_free_segment(trx_rseg_t* rseg, fil_addr_t hdr_addr) +static void trx_purge_free_segment(trx_rseg_t *rseg, fil_addr_t hdr_addr) { mtr_t mtr; mtr.start(); - mysql_mutex_lock(&rseg->mutex); + const page_id_t hdr_page_id(rseg->space->id, hdr_addr.page); + + /* We only need the latch to maintain rseg->curr_size. To follow the + latching order, we must acquire it before acquiring any related + page latch. */ + rseg->latch.wr_lock(); buf_block_t* rseg_hdr = trx_rsegf_get(rseg->space, rseg->page_no, &mtr); - buf_block_t* block = trx_undo_page_get( - page_id_t(rseg->space->id, hdr_addr.page), &mtr); + buf_block_t* block = trx_undo_page_get(hdr_page_id, &mtr); /* Mark the last undo log totally purged, so that if the system crashes, the tail of the undo log will not get accessed @@ -368,17 +368,14 @@ trx_purge_free_segment(trx_rseg_t* rseg, fil_addr_t hdr_addr) while (!fseg_free_step_not_header( TRX_UNDO_SEG_HDR + TRX_UNDO_FSEG_HEADER + block->frame, &mtr)) { - mysql_mutex_unlock(&rseg->mutex); - + rseg->latch.wr_unlock(); mtr.commit(); mtr.start(); - - mysql_mutex_lock(&rseg->mutex); + rseg->latch.wr_lock(); rseg_hdr = trx_rsegf_get(rseg->space, rseg->page_no, &mtr); - block = trx_undo_page_get( - page_id_t(rseg->space->id, hdr_addr.page), &mtr); + block = trx_undo_page_get(hdr_page_id, &mtr); } /* The page list may now be inconsistent, but the length field @@ -412,11 +409,12 @@ trx_purge_free_segment(trx_rseg_t* rseg, fil_addr_t hdr_addr) ut_ad(rseg->curr_size >= seg_size); + rseg->history_size--; rseg->curr_size -= seg_size; - mysql_mutex_unlock(&rseg->mutex); + rseg->latch.wr_unlock(); - mtr_commit(&mtr); + mtr.commit(); } /** Remove unnecessary history data from a rollback segment. @@ -435,7 +433,7 @@ trx_purge_truncate_rseg_history( mtr.start(); ut_ad(rseg.is_persistent()); - mysql_mutex_lock(&rseg.mutex); + rseg.latch.wr_lock(); buf_block_t* rseg_hdr = trx_rsegf_get(rseg.space, rseg.page_no, &mtr); @@ -447,7 +445,7 @@ trx_purge_truncate_rseg_history( loop: if (hdr_addr.page == FIL_NULL) { func_exit: - mysql_mutex_unlock(&rseg.mutex); + rseg.latch.wr_unlock(); mtr.commit(); return; } @@ -480,7 +478,7 @@ func_exit: /* We can free the whole log segment */ - mysql_mutex_unlock(&rseg.mutex); + rseg.latch.wr_unlock(); mtr.commit(); /* calls the trx_purge_remove_log_hdr() @@ -490,13 +488,13 @@ func_exit: /* Remove the log hdr from the rseg history. */ trx_purge_remove_log_hdr(rseg_hdr, block, hdr_addr.boffset, &mtr); - - mysql_mutex_unlock(&rseg.mutex); + rseg.history_size--; + rseg.latch.wr_unlock(); mtr.commit(); } mtr.start(); - mysql_mutex_lock(&rseg.mutex); + rseg.latch.wr_lock(); rseg_hdr = trx_rsegf_get(rseg.space, rseg.page_no, &mtr); @@ -559,10 +557,9 @@ static void trx_purge_truncate_history() head.undo_no = 0; } - for (ulint i = 0; i < TRX_SYS_N_RSEGS; ++i) { - if (trx_rseg_t* rseg = trx_sys.rseg_array[i]) { - ut_ad(rseg->id == i); - trx_purge_truncate_rseg_history(*rseg, head); + for (auto& rseg : trx_sys.rseg_array) { + if (rseg.space) { + trx_purge_truncate_rseg_history(rseg, head); } } @@ -608,40 +605,40 @@ static void trx_purge_truncate_history() DBUG_LOG("undo", "marking for truncate: " << file->name); - for (ulint i = 0; i < TRX_SYS_N_RSEGS; ++i) { - if (trx_rseg_t* rseg = trx_sys.rseg_array[i]) { - ut_ad(rseg->is_persistent()); - if (rseg->space == &space) { - /* Once set, this rseg will - not be allocated to subsequent - transactions, but we will wait - for existing active - transactions to finish. */ - rseg->skip_allocation = true; - } + for (auto& rseg : trx_sys.rseg_array) { + if (rseg.space == &space) { + /* Once set, this rseg will + not be allocated to subsequent + transactions, but we will wait + for existing active + transactions to finish. */ + rseg.set_skip_allocation(); } } - for (ulint i = 0; i < TRX_SYS_N_RSEGS; ++i) { - trx_rseg_t* rseg = trx_sys.rseg_array[i]; - if (!rseg || rseg->space != &space) { + for (auto& rseg : trx_sys.rseg_array) { + if (rseg.space != &space) { continue; } - mysql_mutex_lock(&rseg->mutex); - ut_ad(rseg->skip_allocation); - if (rseg->trx_ref_count) { + ut_ad(rseg.skip_allocation()); + if (rseg.is_referenced()) { + return; + } + rseg.latch.rd_lock(); + ut_ad(rseg.skip_allocation()); + if (rseg.is_referenced()) { not_free: - mysql_mutex_unlock(&rseg->mutex); + rseg.latch.rd_unlock(); return; } - if (rseg->curr_size != 1) { + if (rseg.curr_size != 1) { /* Check if all segments are cached and safe to remove. */ ulint cached = 0; for (trx_undo_t* undo = UT_LIST_GET_FIRST( - rseg->undo_cached); + rseg.undo_cached); undo; undo = UT_LIST_GET_NEXT(undo_list, undo)) { @@ -652,14 +649,14 @@ not_free: } } - ut_ad(rseg->curr_size > cached); + ut_ad(rseg.curr_size > cached); - if (rseg->curr_size > cached + 1) { + if (rseg.curr_size > cached + 1) { goto not_free; } } - mysql_mutex_unlock(&rseg->mutex); + rseg.latch.rd_unlock(); } ib::info() << "Truncating " << file->name; @@ -725,58 +722,22 @@ not_free: buf_block_t* sys_header = trx_sysf_get(&mtr); - for (ulint i = 0; i < TRX_SYS_N_RSEGS; ++i) { - trx_rseg_t* rseg = trx_sys.rseg_array[i]; - if (!rseg || rseg->space != &space) { + for (auto& rseg : trx_sys.rseg_array) { + if (rseg.space != &space) { continue; } - ut_ad(rseg->is_persistent()); - ut_d(const ulint old_page = rseg->page_no); - buf_block_t* rblock = trx_rseg_header_create( purge_sys.truncate.current, - rseg->id, sys_header, &mtr); + i, sys_header, &mtr); ut_ad(rblock); - rseg->page_no = rblock - ? rblock->page.id().page_no() : FIL_NULL; - ut_ad(old_page == rseg->page_no); - - /* Before re-initialization ensure that we - free the existing structure. There can't be - any active transactions. */ - ut_a(UT_LIST_GET_LEN(rseg->undo_list) == 0); - - trx_undo_t* next_undo; - - for (trx_undo_t* undo = UT_LIST_GET_FIRST( - rseg->undo_cached); - undo; undo = next_undo) { - - next_undo = UT_LIST_GET_NEXT(undo_list, undo); - UT_LIST_REMOVE(rseg->undo_cached, undo); - MONITOR_DEC(MONITOR_NUM_UNDO_SLOT_CACHED); - ut_free(undo); - } - - UT_LIST_INIT(rseg->undo_list, - &trx_undo_t::undo_list); - UT_LIST_INIT(rseg->undo_cached, - &trx_undo_t::undo_list); - /* These were written by trx_rseg_header_create(). */ ut_ad(!mach_read_from_4(TRX_RSEG + TRX_RSEG_FORMAT + rblock->frame)); ut_ad(!mach_read_from_4(TRX_RSEG + TRX_RSEG_HISTORY_SIZE + rblock->frame)); - - /* Initialize the undo log lists according to - the rseg header */ - rseg->curr_size = 1; - rseg->trx_ref_count = 0; - rseg->last_page_no = FIL_NULL; - rseg->last_commit_and_offset = 0; - rseg->needs_purge = false; + rseg.reinit(rblock + ? rblock->page.id().page_no() : FIL_NULL); } mtr.commit(); @@ -820,12 +781,9 @@ not_free: log_write_up_to(LSN_MAX, true); DBUG_SUICIDE();); - for (ulint i = 0; i < TRX_SYS_N_RSEGS; ++i) { - if (trx_rseg_t* rseg = trx_sys.rseg_array[i]) { - ut_ad(rseg->is_persistent()); - if (rseg->space == &space) { - rseg->skip_allocation = false; - } + for (auto& rseg : trx_sys.rseg_array) { + if (rseg.space == &space) { + rseg.clear_skip_allocation(); } } @@ -846,7 +804,9 @@ static void trx_purge_rseg_get_next_history_log( trx_id_t trx_no; mtr_t mtr; - mysql_mutex_lock(&purge_sys.rseg->mutex); + mtr.start(); + + purge_sys.rseg->latch.wr_lock(); ut_a(purge_sys.rseg->last_page_no != FIL_NULL); @@ -854,8 +814,6 @@ static void trx_purge_rseg_get_next_history_log( purge_sys.tail.undo_no = 0; purge_sys.next_stored = false; - mtr.start(); - const buf_block_t* undo_page = trx_undo_page_get_s_latched( page_id_t(purge_sys.rseg->space->id, purge_sys.rseg->last_page_no), &mtr); @@ -879,7 +837,7 @@ static void trx_purge_rseg_get_next_history_log( purge_sys.rseg->last_page_no = FIL_NULL; } - mysql_mutex_unlock(&purge_sys.rseg->mutex); + purge_sys.rseg->latch.wr_unlock(); mtr.commit(); if (empty) { @@ -899,11 +857,15 @@ static void trx_purge_rseg_get_next_history_log( mtr_commit(&mtr); - mysql_mutex_lock(&purge_sys.rseg->mutex); + purge_sys.rseg->latch.wr_lock(); purge_sys.rseg->last_page_no = prev_log_addr.page; purge_sys.rseg->set_last_commit(prev_log_addr.boffset, trx_no); - purge_sys.rseg->needs_purge = log_hdr[TRX_UNDO_NEEDS_PURGE + 1] != 0; + if (log_hdr[TRX_UNDO_NEEDS_PURGE + 1]) { + purge_sys.rseg->set_needs_purge(); + } else { + purge_sys.rseg->clear_needs_purge(); + } /* Purge can also produce events, however these are already ordered in the rollback segment and any user generated event will be greater @@ -916,7 +878,7 @@ static void trx_purge_rseg_get_next_history_log( mysql_mutex_unlock(&purge_sys.pq_mutex); - mysql_mutex_unlock(&purge_sys.rseg->mutex); + purge_sys.rseg->latch.wr_unlock(); } /** Position the purge sys "iterator" on the undo record to use for purging. */ @@ -929,7 +891,7 @@ static void trx_purge_read_undo_rec() purge_sys.hdr_offset = purge_sys.rseg->last_offset(); page_no = purge_sys.hdr_page_no = purge_sys.rseg->last_page_no; - if (purge_sys.rseg->needs_purge) { + if (purge_sys.rseg->needs_purge()) { mtr_t mtr; mtr.start(); buf_block_t* undo_page; @@ -1095,7 +1057,7 @@ trx_purge_fetch_next_rec( /* row_purge_record_func() will later set ROLL_PTR_INSERT_FLAG for TRX_UNDO_INSERT_REC */ false, - purge_sys.rseg->id, + trx_sys.rseg_id(purge_sys.rseg, true), purge_sys.page_no, purge_sys.offset); /* The following call will advance the stored values of the @@ -1229,7 +1191,7 @@ trx_purge_dml_delay(void) /* If purge lag is set then calculate the new DML delay. */ if (srv_max_purge_lag > 0) { - double ratio = static_cast(trx_sys.rseg_history_len) / + double ratio = static_cast(trx_sys.history_size()) / static_cast(srv_max_purge_lag); if (ratio > 1.0) { diff --git a/storage/innobase/trx/trx0rec.cc b/storage/innobase/trx/trx0rec.cc index 80b27751cda..08e05edb896 100644 --- a/storage/innobase/trx/trx0rec.cc +++ b/storage/innobase/trx/trx0rec.cc @@ -2112,9 +2112,9 @@ err_exit: mtr.set_log_mode(MTR_LOG_NO_REDO); } - mysql_mutex_lock(&rseg->mutex); + rseg->latch.wr_lock(); trx_undo_free_last_page(undo, &mtr); - mysql_mutex_unlock(&rseg->mutex); + rseg->latch.wr_unlock(); if (m.second) { /* We are not going to modify @@ -2166,8 +2166,8 @@ err_exit: if (!bulk) { *roll_ptr = trx_undo_build_roll_ptr( - !rec, rseg->id, undo->top_page_no, - offset); + !rec, trx_sys.rseg_id(rseg, !is_temp), + undo->top_page_no, offset); } return(DB_SUCCESS); @@ -2220,7 +2220,6 @@ trx_undo_get_undo_rec_low( ulint rseg_id; uint32_t page_no; uint16_t offset; - trx_rseg_t* rseg; bool is_insert; mtr_t mtr; @@ -2228,7 +2227,7 @@ trx_undo_get_undo_rec_low( &offset); ut_ad(page_no > FSP_FIRST_INODE_PAGE_NO); ut_ad(offset >= TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_HDR_SIZE); - rseg = trx_sys.rseg_array[rseg_id]; + trx_rseg_t* rseg = &trx_sys.rseg_array[rseg_id]; ut_ad(rseg->is_persistent()); mtr.start(); diff --git a/storage/innobase/trx/trx0roll.cc b/storage/innobase/trx/trx0roll.cc index 511285b6bcf..a0582413d07 100644 --- a/storage/innobase/trx/trx0roll.cc +++ b/storage/innobase/trx/trx0roll.cc @@ -243,12 +243,10 @@ dberr_t trx_rollback_for_mysql(trx_t* trx) == trx->rsegs.m_redo.rseg); mtr_t mtr; mtr.start(); - mysql_mutex_lock(&trx->rsegs.m_redo.rseg->mutex); if (trx_undo_t* undo = trx->rsegs.m_redo.undo) { trx_undo_set_state_at_prepare(trx, undo, true, &mtr); } - mysql_mutex_unlock(&trx->rsegs.m_redo.rseg->mutex); /* Write the redo log for the XA ROLLBACK state change to the global buffer. It is not necessary to flush the redo log. If diff --git a/storage/innobase/trx/trx0rseg.cc b/storage/innobase/trx/trx0rseg.cc index 0f0709d81f9..6c83feb0b8a 100644 --- a/storage/innobase/trx/trx0rseg.cc +++ b/storage/innobase/trx/trx0rseg.cc @@ -134,7 +134,7 @@ trx_rseg_update_wsrep_checkpoint(const XID* xid, mtr_t* mtr) result. */ const bool must_clear_rsegs = memcmp(wsrep_uuid, xid_uuid, sizeof wsrep_uuid); - const trx_rseg_t* rseg = trx_sys.rseg_array[0]; + const trx_rseg_t* rseg = &trx_sys.rseg_array[0]; buf_block_t* rseg_header = trx_rsegf_get(rseg->space, rseg->page_no, mtr); @@ -151,11 +151,11 @@ trx_rseg_update_wsrep_checkpoint(const XID* xid, mtr_t* mtr) changed, and we must reset the XID in all rollback segment headers. */ for (ulint rseg_id = 1; rseg_id < TRX_SYS_N_RSEGS; ++rseg_id) { - if (const trx_rseg_t* rseg = - trx_sys.rseg_array[rseg_id]) { + const trx_rseg_t &rseg = trx_sys.rseg_array[rseg_id]; + if (rseg.space) { trx_rseg_clear_wsrep_checkpoint( - trx_rsegf_get(rseg->space, - rseg->page_no, mtr), + trx_rsegf_get(rseg.space, rseg.page_no, + mtr), mtr); } } @@ -354,59 +354,59 @@ trx_rseg_header_create( return block; } -/** Free a rollback segment in memory. */ -void -trx_rseg_mem_free(trx_rseg_t* rseg) +void trx_rseg_t::destroy() { - trx_undo_t* undo; - trx_undo_t* next_undo; + latch.destroy(); - mysql_mutex_destroy(&rseg->mutex); + /* There can't be any active transactions. */ + ut_a(!UT_LIST_GET_LEN(undo_list)); - /* There can't be any active transactions. */ - ut_a(UT_LIST_GET_LEN(rseg->undo_list) == 0); - - for (undo = UT_LIST_GET_FIRST(rseg->undo_cached); - undo != NULL; - undo = next_undo) { - - next_undo = UT_LIST_GET_NEXT(undo_list, undo); - - UT_LIST_REMOVE(rseg->undo_cached, undo); - - MONITOR_DEC(MONITOR_NUM_UNDO_SLOT_CACHED); - - ut_free(undo); - } - - ut_free(rseg); + for (trx_undo_t *next, *undo= UT_LIST_GET_FIRST(undo_cached); undo; + undo= next) + { + next= UT_LIST_GET_NEXT(undo_list, undo); + UT_LIST_REMOVE(undo_cached, undo); + ut_free(undo); + } } -/** Create a rollback segment object. -@param[in] id rollback segment id -@param[in] space space where the segment is placed -@param[in] page_no page number of the segment header */ -static -trx_rseg_t* -trx_rseg_mem_create(ulint id, fil_space_t* space, uint32_t page_no) +void trx_rseg_t::init(fil_space_t *space, uint32_t page) { - trx_rseg_t* rseg = static_cast( - ut_zalloc_nokey(sizeof *rseg)); + latch.init(); + ut_ad(!this->space); + this->space= space; + page_no= page; + last_page_no= FIL_NULL; + curr_size= 1; - rseg->id = id; - rseg->space = space; - rseg->page_no = page_no; - rseg->last_page_no = FIL_NULL; - rseg->curr_size = 1; + UT_LIST_INIT(undo_list, &trx_undo_t::undo_list); + UT_LIST_INIT(undo_cached, &trx_undo_t::undo_list); +} - mysql_mutex_init(rseg->is_persistent() - ? redo_rseg_mutex_key - : noredo_rseg_mutex_key, - &rseg->mutex, nullptr); - UT_LIST_INIT(rseg->undo_list, &trx_undo_t::undo_list); - UT_LIST_INIT(rseg->undo_cached, &trx_undo_t::undo_list); +void trx_rseg_t::reinit(uint32_t page) +{ + ut_ad(is_persistent()); + ut_ad(page_no == page); + ut_a(!UT_LIST_GET_LEN(undo_list)); + ut_ad(!history_size || UT_LIST_GET_FIRST(undo_cached)); - return(rseg); + history_size= 0; + page_no= page; + + for (trx_undo_t *next, *undo= UT_LIST_GET_FIRST(undo_cached); undo; + undo= next) + { + next= UT_LIST_GET_NEXT(undo_list, undo); + UT_LIST_REMOVE(undo_cached, undo); + MONITOR_DEC(MONITOR_NUM_UNDO_SLOT_CACHED); + ut_free(undo); + } + + ut_ad(!is_referenced()); + clear_needs_purge(); + last_commit_and_offset= 0; + last_page_no= FIL_NULL; + curr_size= 1; } /** Read the undo log lists. @@ -501,7 +501,7 @@ static dberr_t trx_rseg_mem_restore(trx_rseg_t *rseg, trx_id_t &max_trx_id, if (auto len = flst_get_len(TRX_RSEG + TRX_RSEG_HISTORY + rseg_hdr->frame)) { - trx_sys.rseg_history_len += len; + rseg->history_size += len; fil_addr_t node_addr = flst_get_last(TRX_RSEG + TRX_RSEG_HISTORY @@ -530,7 +530,9 @@ static dberr_t trx_rseg_mem_restore(trx_rseg_t *rseg, trx_id_t &max_trx_id, + node_addr.boffset + TRX_UNDO_NEEDS_PURGE); ut_ad(purge <= 1); - rseg->needs_purge = purge != 0; + if (purge != 0) { + rseg->set_needs_purge(); + } if (rseg->last_page_no != FIL_NULL) { @@ -599,17 +601,14 @@ dberr_t trx_rseg_array_init() const uint32_t page_no = trx_sysf_rseg_get_page_no( sys, rseg_id); if (page_no != FIL_NULL) { - trx_rseg_t* rseg = trx_rseg_mem_create( - rseg_id, - fil_space_get(trx_sysf_rseg_get_space( - sys, rseg_id)), - page_no); - ut_ad(rseg->is_persistent()); - ut_ad(rseg->id == rseg_id); - ut_ad(!trx_sys.rseg_array[rseg_id]); - trx_sys.rseg_array[rseg_id] = rseg; + trx_rseg_t& rseg = trx_sys.rseg_array[rseg_id]; + rseg.init(fil_space_get( + trx_sysf_rseg_get_space( + sys, rseg_id)), + page_no); + ut_ad(rseg.is_persistent()); if ((err = trx_rseg_mem_restore( - rseg, max_trx_id, &mtr)) + &rseg, max_trx_id, &mtr)) != DB_SUCCESS) { mtr.commit(); break; @@ -634,15 +633,10 @@ dberr_t trx_rseg_array_init() } if (err != DB_SUCCESS) { - for (ulint rseg_id = 0; rseg_id < TRX_SYS_N_RSEGS; rseg_id++) { - if (trx_rseg_t*& rseg = trx_sys.rseg_array[rseg_id]) { - while (trx_undo_t* u= UT_LIST_GET_FIRST( - rseg->undo_list)) { - UT_LIST_REMOVE(rseg->undo_list, u); - ut_free(u); - } - trx_rseg_mem_free(rseg); - rseg = NULL; + for (auto& rseg : trx_sys.rseg_array) { + while (auto u = UT_LIST_GET_FIRST(rseg.undo_list)) { + UT_LIST_REMOVE(rseg.undo_list, u); + ut_free(u); } } return err; @@ -673,62 +667,20 @@ dberr_t trx_rseg_array_init() return DB_SUCCESS; } -/** Create a persistent rollback segment. -@param[in] space_id system or undo tablespace id -@return pointer to new rollback segment -@retval NULL on failure */ -trx_rseg_t* -trx_rseg_create(ulint space_id) -{ - trx_rseg_t* rseg = NULL; - mtr_t mtr; - - mtr.start(); - - fil_space_t* space = mtr.x_lock_space(space_id); - ut_ad(space->purpose == FIL_TYPE_TABLESPACE); - - if (buf_block_t* sys_header = trx_sysf_get(&mtr)) { - ulint rseg_id = trx_sys_rseg_find_free(sys_header); - if (buf_block_t* rblock = rseg_id == ULINT_UNDEFINED - ? NULL - : trx_rseg_header_create(space, rseg_id, sys_header, - &mtr)) { - ut_ad(trx_sysf_rseg_get_space(sys_header, rseg_id) - == space_id); - rseg = trx_rseg_mem_create(rseg_id, space, - rblock->page.id(). - page_no()); - ut_ad(rseg->id == rseg_id); - ut_ad(rseg->is_persistent()); - ut_ad(!trx_sys.rseg_array[rseg->id]); - trx_sys.rseg_array[rseg->id] = rseg; - } - } - - mtr.commit(); - - return(rseg); -} - /** Create the temporary rollback segments. */ -void -trx_temp_rseg_create() +void trx_temp_rseg_create() { mtr_t mtr; - for (ulong i = 0; i < TRX_SYS_N_RSEGS; i++) { + for (ulong i = 0; i < array_elements(trx_sys.temp_rsegs); i++) { mtr.start(); mtr.set_log_mode(MTR_LOG_NO_REDO); mtr.x_lock_space(fil_system.temp_space); buf_block_t* rblock = trx_rseg_header_create( fil_system.temp_space, i, NULL, &mtr); - trx_rseg_t* rseg = trx_rseg_mem_create( - i, fil_system.temp_space, rblock->page.id().page_no()); - ut_ad(!rseg->is_persistent()); - ut_ad(!trx_sys.temp_rsegs[i]); - trx_sys.temp_rsegs[i] = rseg; + trx_sys.temp_rsegs[i].init(fil_system.temp_space, + rblock->page.id().page_no()); mtr.commit(); } } diff --git a/storage/innobase/trx/trx0sys.cc b/storage/innobase/trx/trx0sys.cc index 6b7a9e98d46..fd5617fec76 100644 --- a/storage/innobase/trx/trx0sys.cc +++ b/storage/innobase/trx/trx0sys.cc @@ -197,17 +197,67 @@ trx_sysf_create( ut_a(rblock->page.id() == page_id_t(0, FSP_FIRST_RSEG_PAGE_NO)); } -/** Create the instance */ -void -trx_sys_t::create() +void trx_sys_t::create() { - ut_ad(this == &trx_sys); - ut_ad(!is_initialised()); - m_initialised = true; - trx_list.create(); - rseg_history_len= 0; + ut_ad(this == &trx_sys); + ut_ad(!is_initialised()); + m_initialised= true; + trx_list.create(); + rw_trx_hash.init(); +} - rw_trx_hash.init(); +uint32_t trx_sys_t::history_size() +{ + ut_ad(is_initialised()); + uint32_t size= 0; + for (auto &rseg : rseg_array) + { + rseg.latch.rd_lock(); + size+= rseg.history_size; + } + for (auto &rseg : rseg_array) + rseg.latch.rd_unlock(); + return size; +} + +bool trx_sys_t::history_exceeds(uint32_t threshold) +{ + ut_ad(is_initialised()); + uint32_t size= 0; + bool exceeds= false; + size_t i; + for (i= 0; i < array_elements(rseg_array); i++) + { + rseg_array[i].latch.rd_lock(); + size+= rseg_array[i].history_size; + if (size > threshold) + { + exceeds= true; + i++; + break; + } + } + while (i) + rseg_array[--i].latch.rd_unlock(); + return exceeds; +} + +TPOOL_SUPPRESS_TSAN bool trx_sys_t::history_exists() +{ + ut_ad(is_initialised()); + for (auto &rseg : rseg_array) + if (rseg.history_size) + return true; + return false; +} + +TPOOL_SUPPRESS_TSAN uint32_t trx_sys_t::history_size_approx() const +{ + ut_ad(is_initialised()); + uint32_t size= 0; + for (auto &rseg : rseg_array) + size+= rseg.history_size; + return size; } /*****************************************************************//** @@ -225,10 +275,42 @@ trx_sys_create_sys_pages(void) mtr_commit(&mtr); } +/** Create a persistent rollback segment. +@param space_id system or undo tablespace id +@return pointer to new rollback segment +@retval nullptr on failure */ +static trx_rseg_t *trx_rseg_create(ulint space_id) +{ + trx_rseg_t *rseg= nullptr; + mtr_t mtr; + + mtr.start(); + + if (fil_space_t *space= mtr.x_lock_space(space_id)) + { + ut_ad(space->purpose == FIL_TYPE_TABLESPACE); + if (buf_block_t *sys_header= trx_sysf_get(&mtr)) + { + ulint rseg_id= trx_sys_rseg_find_free(sys_header); + if (buf_block_t *rblock= rseg_id == ULINT_UNDEFINED + ? nullptr : trx_rseg_header_create(space, rseg_id, sys_header, + &mtr)) + { + ut_ad(trx_sysf_rseg_get_space(sys_header, rseg_id) == space_id); + rseg= &trx_sys.rseg_array[rseg_id]; + rseg->init(space, rblock->page.id().page_no()); + ut_ad(rseg->is_persistent()); + } + } + } + + mtr.commit(); + return rseg; +} + /** Create the rollback segments. @return whether the creation succeeded */ -bool -trx_sys_create_rsegs() +bool trx_sys_create_rsegs() { /* srv_available_undo_logs reflects the number of persistent rollback segments that have been initialized in the @@ -308,14 +390,11 @@ trx_sys_t::close() /* There can't be any active transactions. */ - for (ulint i = 0; i < TRX_SYS_N_RSEGS; ++i) { - if (trx_rseg_t* rseg = rseg_array[i]) { - trx_rseg_mem_free(rseg); - } - - if (trx_rseg_t* rseg = temp_rsegs[i]) { - trx_rseg_mem_free(rseg); - } + for (ulint i = 0; i < array_elements(temp_rsegs); ++i) { + temp_rsegs[i].destroy(); + } + for (ulint i = 0; i < array_elements(rseg_array); ++i) { + rseg_array[i].destroy(); } ut_a(trx_list.empty()); diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc index 281f80d6164..0f735faacfa 100644 --- a/storage/innobase/trx/trx0trx.cc +++ b/storage/innobase/trx/trx0trx.cc @@ -674,7 +674,7 @@ static void trx_resurrect(trx_undo_t *undo, trx_rseg_t *rseg, or will not qualify for purge limit criteria. So it is safe to increment this trx_ref_count w/o mutex protection. */ - ++trx->rsegs.m_redo.rseg->trx_ref_count; + trx->rsegs.m_redo.rseg->acquire(); *trx->xid= undo->xid; trx->id= undo->trx_id; trx->is_recovered= true; @@ -719,31 +719,30 @@ dberr_t trx_lists_init_at_db_start() const ulonglong start_time_micro= microsecond_interval_timer(); uint64_t rows_to_undo = 0; - for (ulint i = 0; i < TRX_SYS_N_RSEGS; ++i) { + for (auto& rseg : trx_sys.rseg_array) { trx_undo_t* undo; - trx_rseg_t* rseg = trx_sys.rseg_array[i]; /* Some rollback segment may be unavailable, especially if the server was previously run with a non-default value of innodb_undo_logs. */ - if (rseg == NULL) { + if (!rseg.space) { continue; } /* Ressurrect other transactions. */ - for (undo = UT_LIST_GET_FIRST(rseg->undo_list); + for (undo = UT_LIST_GET_FIRST(rseg.undo_list); undo != NULL; undo = UT_LIST_GET_NEXT(undo_list, undo)) { trx_t *trx = trx_sys.find(0, undo->trx_id, false); if (!trx) { - trx_resurrect(undo, rseg, start_time, + trx_resurrect(undo, &rseg, start_time, start_time_micro, &rows_to_undo); } else { ut_ad(trx_state_eq(trx, TRX_STATE_ACTIVE) || trx_state_eq(trx, TRX_STATE_PREPARED)); ut_ad(trx->start_time == start_time); ut_ad(trx->is_recovered); - ut_ad(trx->rsegs.m_redo.rseg == rseg); - ut_ad(trx->rsegs.m_redo.rseg->trx_ref_count); + ut_ad(trx->rsegs.m_redo.rseg == &rseg); + ut_ad(rseg.is_referenced()); trx->rsegs.m_redo.undo = undo; if (undo->top_undo_no >= trx->undo_no) { @@ -787,7 +786,7 @@ static trx_rseg_t* trx_assign_rseg_low() ut_ad(srv_available_undo_logs == TRX_SYS_N_RSEGS); /* The first slot is always assigned to the system tablespace. */ - ut_ad(trx_sys.rseg_array[0]->space == fil_system.sys_space); + ut_ad(trx_sys.rseg_array[0].space == fil_system.sys_space); /* Choose a rollback segment evenly distributed between 0 and innodb_undo_logs-1 in a round-robin fashion, skipping those @@ -806,7 +805,7 @@ static trx_rseg_t* trx_assign_rseg_low() do { for (;;) { - rseg = trx_sys.rseg_array[slot]; + rseg = &trx_sys.rseg_array[slot]; #ifdef UNIV_DEBUG /* Ensure that we are not revisiting the same @@ -820,20 +819,20 @@ static trx_rseg_t* trx_assign_rseg_low() ut_d(if (!trx_rseg_n_slots_debug)) slot = (slot + 1) % TRX_SYS_N_RSEGS; - if (rseg == NULL) { + if (!rseg->space) { continue; } ut_ad(rseg->is_persistent()); if (rseg->space != fil_system.sys_space) { - if (rseg->skip_allocation + if (rseg->skip_allocation() || !srv_undo_tablespaces) { continue; } - } else if (trx_rseg_t* next - = trx_sys.rseg_array[slot]) { - if (next->space != fil_system.sys_space + } else if (const fil_space_t *space = + trx_sys.rseg_array[slot].space) { + if (space != fil_system.sys_space && srv_undo_tablespaces > 0) { /** If dedicated innodb_undo_tablespaces have @@ -849,15 +848,10 @@ static trx_rseg_t* trx_assign_rseg_low() /* By now we have only selected the rseg but not marked it allocated. By marking it allocated we are ensuring that it will never be selected for UNDO truncate purge. */ - mysql_mutex_lock(&rseg->mutex); - if (!rseg->skip_allocation) { - rseg->trx_ref_count++; - allocated = true; - } - mysql_mutex_unlock(&rseg->mutex); + allocated = rseg->acquire_if_available(); } while (!allocated); - ut_ad(rseg->trx_ref_count > 0); + ut_ad(rseg->is_referenced()); ut_ad(rseg->is_persistent()); return(rseg); } @@ -873,7 +867,7 @@ trx_rseg_t *trx_t::assign_temp_rseg() /* Choose a temporary rollback segment between 0 and 127 in a round-robin fashion. */ static Atomic_counter rseg_slot; - trx_rseg_t* rseg = trx_sys.temp_rsegs[ + trx_rseg_t* rseg = &trx_sys.temp_rsegs[ rseg_slot++ & (TRX_SYS_N_RSEGS - 1)]; ut_ad(!rseg->is_persistent()); rsegs.m_noredo.rseg = rseg; @@ -882,7 +876,6 @@ trx_rseg_t *trx_t::assign_temp_rseg() trx_sys.register_rw(this); } - ut_ad(!rseg->is_persistent()); return(rseg); } @@ -984,7 +977,6 @@ trx_serialise(trx_t* trx) { trx_rseg_t *rseg = trx->rsegs.m_redo.rseg; ut_ad(rseg); - mysql_mutex_assert_owner(&rseg->mutex); if (rseg->last_page_no == FIL_NULL) { mysql_mutex_lock(&purge_sys.pq_mutex); @@ -1031,10 +1023,7 @@ trx_write_serialisation_history( mtr_t temp_mtr; temp_mtr.start(); temp_mtr.set_log_mode(MTR_LOG_NO_REDO); - - mysql_mutex_lock(&trx->rsegs.m_noredo.rseg->mutex); trx_undo_set_state_at_finish(undo, &temp_mtr); - mysql_mutex_unlock(&trx->rsegs.m_noredo.rseg->mutex); temp_mtr.commit(); } @@ -1052,7 +1041,7 @@ trx_write_serialisation_history( ut_ad(!trx->read_only); ut_ad(!undo || undo->rseg == rseg); - mysql_mutex_lock(&rseg->mutex); + rseg->latch.wr_lock(); /* Assign the transaction serialisation number and add any undo log to the purge queue. */ @@ -1062,7 +1051,7 @@ trx_write_serialisation_history( trx_purge_add_undo_to_history(trx, undo, mtr); } - mysql_mutex_unlock(&rseg->mutex); + rseg->latch.wr_unlock(); MONITOR_INC(MONITOR_TRX_COMMIT_UNDO); } @@ -1320,12 +1309,7 @@ inline void trx_t::commit_in_memory(const mtr_t *mtr) ut_ad(UT_LIST_GET_LEN(lock.evicted_tables) == 0); if (trx_rseg_t *rseg= rsegs.m_redo.rseg) - { - mysql_mutex_lock(&rseg->mutex); - ut_ad(rseg->trx_ref_count > 0); - --rseg->trx_ref_count; - mysql_mutex_unlock(&rseg->mutex); - } + rseg->release(); if (mtr) { @@ -1821,11 +1805,7 @@ static lsn_t trx_prepare_low(trx_t *trx) mtr.start(); mtr.set_log_mode(MTR_LOG_NO_REDO); - - mysql_mutex_lock(&undo->rseg->mutex); trx_undo_set_state_at_prepare(trx, undo, false, &mtr); - mysql_mutex_unlock(&undo->rseg->mutex); - mtr.commit(); } @@ -1836,8 +1816,7 @@ static lsn_t trx_prepare_low(trx_t *trx) return(0); } - trx_rseg_t* rseg = trx->rsegs.m_redo.rseg; - ut_ad(undo->rseg == rseg); + ut_ad(undo->rseg == trx->rsegs.m_redo.rseg); mtr.start(); @@ -1845,10 +1824,7 @@ static lsn_t trx_prepare_low(trx_t *trx) TRX_UNDO_PREPARED: these modifications to the file data structure define the transaction as prepared in the file-based world, at the serialization point of lsn. */ - - mysql_mutex_lock(&rseg->mutex); trx_undo_set_state_at_prepare(trx, undo, false, &mtr); - mysql_mutex_unlock(&rseg->mutex); /* Make the XA PREPARE durable. */ mtr.commit(); diff --git a/storage/innobase/trx/trx0undo.cc b/storage/innobase/trx/trx0undo.cc index a6166da62fc..8b84cf36258 100644 --- a/storage/innobase/trx/trx0undo.cc +++ b/storage/innobase/trx/trx0undo.cc @@ -554,7 +554,7 @@ buf_block_t* trx_undo_add_page(trx_undo_t* undo, mtr_t* mtr) a pessimistic insert in a B-tree, and we must reserve the counterpart of the tree latch, which is the rseg mutex. */ - mysql_mutex_lock(&rseg->mutex); + rseg->latch.wr_lock(); buf_block_t* header_block = trx_undo_page_get( page_id_t(undo->rseg->space->id, undo->hdr_page_no), mtr); @@ -586,7 +586,7 @@ buf_block_t* trx_undo_add_page(trx_undo_t* undo, mtr_t* mtr) rseg->curr_size++; func_exit: - mysql_mutex_unlock(&rseg->mutex); + rseg->latch.wr_unlock(); return(new_block); } @@ -610,7 +610,6 @@ trx_undo_free_page( const ulint space = rseg->space->id; ut_a(hdr_page_no != page_no); - mysql_mutex_assert_owner(&rseg->mutex); buf_block_t* undo_block = trx_undo_page_get(page_id_t(space, page_no), mtr); @@ -675,7 +674,7 @@ void trx_undo_truncate_end(trx_undo_t& undo, undo_no_t limit, bool is_temp) } trx_undo_rec_t* trunc_here = NULL; - mysql_mutex_lock(&undo.rseg->mutex); + undo.rseg->latch.wr_lock(); buf_block_t* undo_block = trx_undo_page_get( page_id_t(undo.rseg->space->id, undo.last_page_no), &mtr); @@ -695,13 +694,13 @@ void trx_undo_truncate_end(trx_undo_t& undo, undo_no_t limit, bool is_temp) if (undo.last_page_no != undo.hdr_page_no) { trx_undo_free_last_page(&undo, &mtr); - mysql_mutex_unlock(&undo.rseg->mutex); + undo.rseg->latch.wr_unlock(); mtr.commit(); continue; } func_exit: - mysql_mutex_unlock(&undo.rseg->mutex); + undo.rseg->latch.wr_unlock(); if (trunc_here) { mtr.write<2>(*undo_block, @@ -734,8 +733,6 @@ trx_undo_truncate_start( trx_undo_rec_t* last_rec; mtr_t mtr; - mysql_mutex_assert_owner(&rseg->mutex); - if (!limit) { return; } @@ -913,10 +910,8 @@ corrupted: max_trx_id = trx_id; } - mysql_mutex_lock(&rseg->mutex); trx_undo_t* undo = trx_undo_mem_create( rseg, id, trx_id, &xid, page_no, offset); - mysql_mutex_unlock(&rseg->mutex); if (!undo) { return undo; } @@ -974,8 +969,6 @@ trx_undo_mem_create( { trx_undo_t* undo; - mysql_mutex_assert_owner(&rseg->mutex); - ut_a(id < TRX_RSEG_N_SLOTS); undo = static_cast(ut_malloc_nokey(sizeof(*undo))); @@ -1019,8 +1012,6 @@ trx_undo_mem_init_for_reuse( const XID* xid, /*!< in: X/Open XA transaction identification*/ uint16_t offset) /*!< in: undo log header byte offset on page */ { - mysql_mutex_assert_owner(&undo->rseg->mutex); - ut_a(undo->id < TRX_RSEG_N_SLOTS); undo->state = TRX_UNDO_ACTIVE; @@ -1048,9 +1039,6 @@ trx_undo_create(trx_t* trx, trx_rseg_t* rseg, trx_undo_t** undo, dberr_t* err, mtr_t* mtr) { ulint id; - - mysql_mutex_assert_owner(&rseg->mutex); - buf_block_t* block = trx_undo_seg_create( rseg->space, trx_rsegf_get(rseg->space, rseg->page_no, mtr), &id, err, mtr); @@ -1099,8 +1087,6 @@ buf_block_t* trx_undo_reuse_cached(trx_t* trx, trx_rseg_t* rseg, trx_undo_t** pundo, mtr_t* mtr) { - mysql_mutex_assert_owner(&rseg->mutex); - trx_undo_t* undo = UT_LIST_GET_FIRST(rseg->undo_cached); if (!undo) { return NULL; @@ -1163,7 +1149,7 @@ trx_undo_assign(trx_t* trx, dberr_t* err, mtr_t* mtr) trx_rseg_t* rseg = trx->rsegs.m_redo.rseg; - mysql_mutex_lock(&rseg->mutex); + rseg->latch.wr_lock(); buf_block_t* block = trx_undo_reuse_cached( trx, rseg, &trx->rsegs.m_redo.undo, mtr); @@ -1181,7 +1167,7 @@ trx_undo_assign(trx_t* trx, dberr_t* err, mtr_t* mtr) UT_LIST_ADD_FIRST(rseg->undo_list, trx->rsegs.m_redo.undo); func_exit: - mysql_mutex_unlock(&rseg->mutex); + rseg->latch.wr_unlock(); return block; } @@ -1219,7 +1205,7 @@ trx_undo_assign_low(trx_t* trx, trx_rseg_t* rseg, trx_undo_t** undo, *err = DB_TOO_MANY_CONCURRENT_TRXS; return NULL; ); - mysql_mutex_lock(&rseg->mutex); + rseg->latch.wr_lock(); buf_block_t* block = trx_undo_reuse_cached(trx, rseg, undo, mtr); @@ -1236,7 +1222,7 @@ trx_undo_assign_low(trx_t* trx, trx_rseg_t* rseg, trx_undo_t** undo, UT_LIST_ADD_FIRST(rseg->undo_list, *undo); func_exit: - mysql_mutex_unlock(&rseg->mutex); + rseg->latch.wr_unlock(); return block; } @@ -1312,13 +1298,14 @@ void trx_undo_commit_cleanup(trx_undo_t *undo) trx_rseg_t* rseg = undo->rseg; ut_ad(rseg->space == fil_system.temp_space); - mysql_mutex_lock(&rseg->mutex); + rseg->latch.wr_lock(); UT_LIST_REMOVE(rseg->undo_list, undo); if (undo->state == TRX_UNDO_CACHED) { UT_LIST_ADD_FIRST(rseg->undo_cached, undo); MONITOR_INC(MONITOR_NUM_UNDO_SLOT_CACHED); + undo = nullptr; } else { ut_ad(undo->state == TRX_UNDO_TO_PURGE); @@ -1327,11 +1314,10 @@ void trx_undo_commit_cleanup(trx_undo_t *undo) ut_ad(rseg->curr_size > undo->size); rseg->curr_size -= undo->size; - - ut_free(undo); } - mysql_mutex_unlock(&rseg->mutex); + rseg->latch.wr_unlock(); + ut_free(undo); } /** At shutdown, frees the undo logs of a transaction. */ From 6dfd44c828b383ee63c69db334934461bc37e4ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 23 Jun 2021 19:06:49 +0300 Subject: [PATCH 169/251] MDEV-25954: Trim os_aio_wait_until_no_pending_writes() It turns out that we had some unnecessary waits for no outstanding write requests to exist. They were basically working around a bug that was fixed in MDEV-25953. On write completion callback, blocks will be marked clean. So, it is sufficient to consult buf_pool.flush_list to determine which writes have not been completed yet. On FLUSH TABLES...FOR EXPORT we must still wait for all pending asynchronous writes to complete, because buf_flush_file_space() would merely guarantee that writes will have been initiated. --- storage/innobase/buf/buf0dblwr.cc | 1 - storage/innobase/buf/buf0flu.cc | 5 ----- storage/innobase/fil/fil0fil.cc | 2 -- storage/innobase/include/os0file.h | 7 +++---- storage/innobase/os/os0file.cc | 4 ++-- storage/innobase/row/row0import.cc | 10 ++++++++++ 6 files changed, 15 insertions(+), 14 deletions(-) diff --git a/storage/innobase/buf/buf0dblwr.cc b/storage/innobase/buf/buf0dblwr.cc index afaa02e7ab1..95143f475e9 100644 --- a/storage/innobase/buf/buf0dblwr.cc +++ b/storage/innobase/buf/buf0dblwr.cc @@ -689,7 +689,6 @@ void buf_dblwr_t::flush_buffered_writes() { if (!is_initialised() || !srv_use_doublewrite_buf) { - os_aio_wait_until_no_pending_writes(); fil_flush_file_spaces(); return; } diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc index 7d1136043b7..13feba69109 100644 --- a/storage/innobase/buf/buf0flu.cc +++ b/storage/innobase/buf/buf0flu.cc @@ -1546,11 +1546,6 @@ static std::atomic_flag log_flush_pending; /** Advance log_sys.get_flushed_lsn() */ static void log_flush(void *) { - /* Between batches, we try to prevent I/O stalls by these calls. - This should not be needed for correctness. */ - os_aio_wait_until_no_pending_writes(); - fil_flush_file_spaces(); - /* Guarantee progress for buf_flush_lists(). */ log_buffer_flush_to_disk(true); log_flush_pending.clear(); diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index 407e6e96982..283b7326385 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -1743,8 +1743,6 @@ void fil_close_tablespace(ulint id) Thus we can clean the tablespace out of buf_pool completely and permanently. */ while (buf_flush_dirty_pages(id)); - /* Ensure that all asynchronous IO is completed. */ - os_aio_wait_until_no_pending_writes(); ut_ad(space->is_stopping()); /* If the free is successful, the X lock will be released before diff --git a/storage/innobase/include/os0file.h b/storage/innobase/include/os0file.h index fb97d48623e..9b5e5058f46 100644 --- a/storage/innobase/include/os0file.h +++ b/storage/innobase/include/os0file.h @@ -1111,10 +1111,9 @@ void os_aio_free(); @retval DB_IO_ERROR on I/O error */ dberr_t os_aio(const IORequest &type, void *buf, os_offset_t offset, size_t n); -/** Waits until there are no pending writes in os_aio_write_array. There can -be other, synchronous, pending writes. */ -void -os_aio_wait_until_no_pending_writes(); +/** Wait until there are no pending asynchronous writes. +Only used on FLUSH TABLES...FOR EXPORT. */ +void os_aio_wait_until_no_pending_writes(); /** Prints info of the aio arrays. diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc index 6c3f32fc542..b285630e451 100644 --- a/storage/innobase/os/os0file.cc +++ b/storage/innobase/os/os0file.cc @@ -3788,8 +3788,8 @@ static void os_aio_wait_until_no_pending_writes_low() tpool::tpool_wait_end(); } -/** Waits until there are no pending writes. There can -be other, synchronous, pending writes. */ +/** Wait until there are no pending asynchronous writes. +Only used on FLUSH TABLES...FOR EXPORT. */ void os_aio_wait_until_no_pending_writes() { os_aio_wait_until_no_pending_writes_low(); diff --git a/storage/innobase/row/row0import.cc b/storage/innobase/row/row0import.cc index 9ffbe41ed11..1a22c67f8ba 100644 --- a/storage/innobase/row/row0import.cc +++ b/storage/innobase/row/row0import.cc @@ -4234,6 +4234,16 @@ row_import_for_mysql( of delete marked records that couldn't be purged in Phase I. */ while (buf_flush_dirty_pages(prebuilt->table->space_id)); + for (ulint count = 0; prebuilt->table->space->referenced(); count++) { + /* Issue a warning every 10.24 seconds, starting after + 2.56 seconds */ + if ((count & 511) == 128) { + ib::warn() << "Waiting for flush to complete on " + << prebuilt->table->name; + } + os_thread_sleep(20000); + } + ib::info() << "Phase IV - Flush complete"; prebuilt->table->space->set_imported(); From 762bcb81b5bf9bbde61fed59afb26417f4ce1e86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 23 Jun 2021 12:01:41 +0300 Subject: [PATCH 170/251] MDEV-25948 Remove log_flush_task Vladislav Vaintroub suggested that invoking log_flush_up_to() for every page could perform better than invoking a log write between buf_pool.flush_list batches, like we started doing in commit 3a9a3be1c64b14c05648e87ebe0f1dd96457de41 (MDEV-23855). This could depend on the sequence in which pages are being modified. The buf_pool.flush_list is ordered by oldest_modification, while the FIL_PAGE_LSN of the pages is theoretically independent of that. In the pathological case, we will wait for a log write before writing each individual page. It turns out that we can defer the call to log_flush_up_to() until just before submitting the page write. If the doublewrite buffer is being used, we can submit a write batch of "future" pages to the doublewrite buffer, and only wait for the log write right before we are writing an already doublewritten page. The next doublewrite batch will not be initiated before the last page write from the current batch has completed. When a future version introduces asynchronous writes if the log, we could initiate a write at the start of a flushing batch, to reduce waiting further. --- storage/innobase/buf/buf0dblwr.cc | 7 ++++ storage/innobase/buf/buf0flu.cc | 69 ++++++++++--------------------- 2 files changed, 28 insertions(+), 48 deletions(-) diff --git a/storage/innobase/buf/buf0dblwr.cc b/storage/innobase/buf/buf0dblwr.cc index 95143f475e9..a6885059a86 100644 --- a/storage/innobase/buf/buf0dblwr.cc +++ b/storage/innobase/buf/buf0dblwr.cc @@ -676,6 +676,13 @@ void buf_dblwr_t::flush_buffered_writes_completed(const IORequest &request) ut_d(buf_dblwr_check_page_lsn(*bpage, static_cast(frame))); } + const lsn_t lsn= mach_read_from_8(my_assume_aligned<8> + (FIL_PAGE_LSN + + static_cast(frame))); + ut_ad(lsn); + ut_ad(lsn >= bpage->oldest_modification()); + if (lsn > log_sys.get_flushed_lsn()) + log_write_up_to(lsn, true); e.request.node->space->io(e.request, bpage->physical_offset(), e_size, frame, bpage); } diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc index 13feba69109..3376f11a826 100644 --- a/storage/innobase/buf/buf0flu.cc +++ b/storage/innobase/buf/buf0flu.cc @@ -899,24 +899,6 @@ static bool buf_flush_page(buf_page_t *bpage, bool lru, fil_space_t *space) buf_block_t *block= reinterpret_cast(bpage); page_t *frame= bpage->zip.data; - if (UNIV_LIKELY(space->purpose == FIL_TYPE_TABLESPACE)) - { - const lsn_t lsn= mach_read_from_8(my_assume_aligned<8> - (FIL_PAGE_LSN + - (frame ? frame : block->frame))); - ut_ad(lsn); - ut_ad(lsn >= bpage->oldest_modification()); - ut_ad(!srv_read_only_mode); - if (UNIV_UNLIKELY(lsn > log_sys.get_flushed_lsn())) - { - if (rw_lock) - rw_lock_sx_unlock_gen(rw_lock, BUF_IO_WRITE); - mysql_mutex_lock(&buf_pool.mutex); - bpage->set_io_fix(BUF_IO_NONE); - return false; - } - } - if (status == buf_page_t::FREED) buf_release_freed_page(&block->page); else @@ -977,9 +959,22 @@ static bool buf_flush_page(buf_page_t *bpage, bool lru, fil_space_t *space) buf_pool.n_flush_LRU++; else buf_pool.n_flush_list++; + if (status != buf_page_t::NORMAL || !space->use_doublewrite()) + { + if (UNIV_LIKELY(space->purpose == FIL_TYPE_TABLESPACE)) + { + const lsn_t lsn= mach_read_from_8(my_assume_aligned<8> + (FIL_PAGE_LSN + (frame ? frame + : block->frame))); + ut_ad(lsn); + ut_ad(lsn >= bpage->oldest_modification()); + if (lsn > log_sys.get_flushed_lsn()) + log_write_up_to(lsn, true); + } space->io(IORequest(type, bpage), bpage->physical_offset(), size, frame, bpage); + } else buf_dblwr.add_to_batch(IORequest(bpage, space->chain.start, type), size); } @@ -1540,19 +1535,6 @@ void buf_flush_wait_batch_end(bool lru) } } -/** Whether a background log flush is pending */ -static std::atomic_flag log_flush_pending; - -/** Advance log_sys.get_flushed_lsn() */ -static void log_flush(void *) -{ - /* Guarantee progress for buf_flush_lists(). */ - log_buffer_flush_to_disk(true); - log_flush_pending.clear(); -} - -static tpool::waitable_task log_flush_task(log_flush, nullptr, nullptr); - /** Write out dirty blocks from buf_pool.flush_list. @param max_n wished maximum mumber of blocks flushed @param lsn buf_pool.get_oldest_modification(LSN_MAX) target (0=LRU flush) @@ -1565,20 +1547,6 @@ ulint buf_flush_lists(ulint max_n, lsn_t lsn) if (n_flush) return 0; - lsn_t flushed_lsn= log_sys.get_flushed_lsn(); - if (log_sys.get_lsn() > flushed_lsn) - { - log_flush_task.wait(); - flushed_lsn= log_sys.get_flushed_lsn(); - if (log_sys.get_lsn() > flushed_lsn && - !log_flush_pending.test_and_set()) - srv_thread_pool->submit_task(&log_flush_task); -#if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG - if (UNIV_UNLIKELY(ibuf_debug)) - log_buffer_flush_to_disk(true); -#endif - } - auto cond= lsn ? &buf_pool.done_flush_list : &buf_pool.done_flush_LRU; mysql_mutex_lock(&buf_pool.mutex); @@ -1787,7 +1755,15 @@ try_checkpoint: mysql_mutex_unlock(&buf_pool.flush_list_mutex); if (UNIV_UNLIKELY(log_sys.last_checkpoint_lsn < sync_lsn)) + { + /* If the buffer pool was clean, no log write was guaranteed + to happen until now. There could be an outstanding FILE_CHECKPOINT + record from a previous fil_names_clear() call, which we must + write out before we can advance the checkpoint. */ + if (sync_lsn > log_sys.get_flushed_lsn()) + log_write_up_to(sync_lsn, true); log_checkpoint(); + } } /** If innodb_flush_sync=ON, initiate a furious flush. @@ -2275,8 +2251,6 @@ next: buf_flush_wait_batch_end_acquiring_mutex(false); } - log_flush_task.wait(); - mysql_mutex_lock(&buf_pool.flush_list_mutex); lsn_limit= buf_flush_sync_lsn; if (UNIV_UNLIKELY(lsn_limit != 0)) @@ -2343,7 +2317,6 @@ ATTRIBUTE_COLD void buf_flush_buffer_pool() } ut_ad(!buf_pool.any_io_pending()); - log_flush_task.wait(); } /** Synchronously flush dirty blocks. From 8af538979bc9e320b0d7015dc36332e442376bbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 23 Jun 2021 12:14:26 +0300 Subject: [PATCH 171/251] MDEV-25801: buf_flush_dirty_pages() is very slow In commit 7cffb5f6e8a231a041152447be8980ce35d2c9b8 (MDEV-23399) the implementation of buf_flush_dirty_pages() was replaced with a slow one, which would perform excessive scans of the buf_pool.flush_list and make little progress. buf_flush_list(), buf_flush_LRU(): Split from buf_flush_lists(). Vladislav Vaintroub noticed that we will not need to invoke log_flush_task.wait() for the LRU eviction flushing. buf_flush_list_space(): Replaces buf_flush_dirty_pages(). This is like buf_flush_list(), but operating on a single tablespace at a time. Writes at most innodb_io_capacity pages. Returns whether some of the tablespace might remain in the buffer pool. --- storage/innobase/buf/buf0buf.cc | 6 +- storage/innobase/buf/buf0flu.cc | 307 +++++++++++++++++++--------- storage/innobase/buf/buf0lru.cc | 2 +- storage/innobase/fil/fil0crypt.cc | 11 +- storage/innobase/fil/fil0fil.cc | 2 +- storage/innobase/include/buf0flu.h | 27 ++- storage/innobase/row/row0import.cc | 2 +- storage/innobase/row/row0quiesce.cc | 4 +- storage/innobase/trx/trx0purge.cc | 4 +- 9 files changed, 241 insertions(+), 124 deletions(-) diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index 72f44ab9c32..0ba56c346aa 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -1729,10 +1729,10 @@ inline bool buf_pool_t::withdraw_blocks() /* reserve free_list length */ if (UT_LIST_GET_LEN(withdraw) < withdraw_target) { - ulint n_flushed = buf_flush_lists( + ulint n_flushed = buf_flush_LRU( std::max(withdraw_target - UT_LIST_GET_LEN(withdraw), - srv_LRU_scan_depth), 0); + srv_LRU_scan_depth)); buf_flush_wait_batch_end_acquiring_mutex(true); if (n_flushed) { @@ -3321,7 +3321,7 @@ re_evict: fix_block->fix(); mysql_mutex_unlock(&buf_pool.mutex); - buf_flush_lists(ULINT_UNDEFINED, LSN_MAX); + buf_flush_list(); buf_flush_wait_batch_end_acquiring_mutex(false); if (fix_block->page.buf_fix_count() == 1 diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc index 3376f11a826..3978f624e11 100644 --- a/storage/innobase/buf/buf0flu.cc +++ b/storage/innobase/buf/buf0flu.cc @@ -258,33 +258,6 @@ void buf_flush_remove_pages(ulint id) mysql_mutex_unlock(&buf_pool.mutex); } -/** Try to flush all the dirty pages that belong to a given tablespace. -@param id tablespace identifier -@return number dirty pages that there were for this tablespace */ -ulint buf_flush_dirty_pages(ulint id) -{ - ut_ad(!sync_check_iterate(dict_sync_check())); - - ulint n= 0; - - mysql_mutex_lock(&buf_pool.flush_list_mutex); - - for (buf_page_t *bpage= UT_LIST_GET_FIRST(buf_pool.flush_list); bpage; - bpage= UT_LIST_GET_NEXT(list, bpage)) - { - ut_d(const auto s= bpage->state()); - ut_ad(s == BUF_BLOCK_ZIP_PAGE || s == BUF_BLOCK_FILE_PAGE || - s == BUF_BLOCK_REMOVE_HASH); - ut_ad(bpage->oldest_modification()); - if (id == bpage->id().space()) - n++; - } - mysql_mutex_unlock(&buf_pool.flush_list_mutex); - if (n) - buf_flush_lists(srv_max_io_capacity, LSN_MAX); - return n; -} - /*******************************************************************//** Relocates a buffer control block on the flush_list. Note that it is assumed that the contents of bpage have already been @@ -1431,11 +1404,6 @@ static ulint buf_do_flush_list_batch(ulint max_n, lsn_t lsn) mysql_mutex_lock(&buf_pool.flush_list_mutex); ulint len= UT_LIST_GET_LEN(buf_pool.flush_list); - /* In order not to degenerate this scan to O(n*n) we attempt to - preserve pointer of previous block in the flush list. To do so we - declare it a hazard pointer. Any thread working on the flush list - must check the hazard pointer and if it is removing the same block - then it must reset it. */ for (buf_page_t *bpage= UT_LIST_GET_LAST(buf_pool.flush_list); bpage && len && count < max_n; bpage= buf_pool.flush_hp.get(), ++scanned, len--) @@ -1444,55 +1412,66 @@ static ulint buf_do_flush_list_batch(ulint max_n, lsn_t lsn) if (oldest_modification >= lsn) break; ut_ad(oldest_modification); + ut_ad(bpage->in_file()); buf_page_t *prev= UT_LIST_GET_PREV(list, bpage); + + if (!bpage->ready_for_flush()) + { + bpage= prev; + continue; + } + + /* In order not to degenerate this scan to O(n*n) we attempt to + preserve the pointer position. Any thread that would remove 'prev' + from buf_pool.flush_list must adjust the hazard pointer. + + Note: A concurrent execution of buf_flush_list_space() may + terminate this scan prematurely. The buf_pool.n_flush_list() + should prevent multiple threads from executing + buf_do_flush_list_batch() concurrently, + but buf_flush_list_space() is ignoring that. */ buf_pool.flush_hp.set(prev); mysql_mutex_unlock(&buf_pool.flush_list_mutex); - ut_ad(bpage->in_file()); - const bool flushed= bpage->ready_for_flush(); - - if (flushed) + const page_id_t page_id(bpage->id()); + const uint32_t space_id= page_id.space(); + if (!space || space->id != space_id) { - const page_id_t page_id(bpage->id()); - const uint32_t space_id= page_id.space(); - if (!space || space->id != space_id) + if (last_space_id != space_id) { - if (last_space_id != space_id) - { - if (space) - space->release(); - space= buf_flush_space(space_id); - last_space_id= space_id; - } - else - ut_ad(!space); - } - else if (space->is_stopping()) - { - space->release(); - space= nullptr; + if (space) + space->release(); + space= buf_flush_space(space_id); + last_space_id= space_id; } + else + ut_ad(!space); + } + else if (space->is_stopping()) + { + space->release(); + space= nullptr; + } - if (!space) - buf_flush_discard_page(bpage); - else if (neighbors && space->is_rotational()) - { - mysql_mutex_unlock(&buf_pool.mutex); - count+= buf_flush_try_neighbors(space, page_id, neighbors == 1, - false, count, max_n); -reacquire_mutex: - mysql_mutex_lock(&buf_pool.mutex); - } - else if (buf_flush_page(bpage, false, space)) - { - ++count; - goto reacquire_mutex; - } + if (!space) + buf_flush_discard_page(bpage); + else if (neighbors && space->is_rotational()) + { + mysql_mutex_unlock(&buf_pool.mutex); + count+= buf_flush_try_neighbors(space, page_id, neighbors == 1, + false, count, max_n); + reacquire_mutex: + mysql_mutex_lock(&buf_pool.mutex); + } + else if (buf_flush_page(bpage, false, space)) + { + ++count; + goto reacquire_mutex; } mysql_mutex_lock(&buf_pool.flush_list_mutex); - ut_ad(flushed || buf_pool.flush_hp.is_hp(prev)); + bpage= buf_pool.flush_hp.get(); } buf_pool.flush_hp.set(nullptr); @@ -1537,51 +1516,189 @@ void buf_flush_wait_batch_end(bool lru) /** Write out dirty blocks from buf_pool.flush_list. @param max_n wished maximum mumber of blocks flushed -@param lsn buf_pool.get_oldest_modification(LSN_MAX) target (0=LRU flush) +@param lsn buf_pool.get_oldest_modification(LSN_MAX) target @return the number of processed pages -@retval 0 if a batch of the same type (lsn==0 or lsn!=0) is already running */ -ulint buf_flush_lists(ulint max_n, lsn_t lsn) +@retval 0 if a buf_pool.flush_list batch is already running */ +ulint buf_flush_list(ulint max_n, lsn_t lsn) { - auto &n_flush= lsn ? buf_pool.n_flush_list : buf_pool.n_flush_LRU; + ut_ad(lsn); - if (n_flush) + if (buf_pool.n_flush_list) return 0; - auto cond= lsn ? &buf_pool.done_flush_list : &buf_pool.done_flush_LRU; - mysql_mutex_lock(&buf_pool.mutex); - const bool running= n_flush != 0; + const bool running= buf_pool.n_flush_list != 0; /* FIXME: we are performing a dirty read of buf_pool.flush_list.count while not holding buf_pool.flush_list_mutex */ - if (running || (lsn && !UT_LIST_GET_LEN(buf_pool.flush_list))) + if (running || !UT_LIST_GET_LEN(buf_pool.flush_list)) { if (!running) - pthread_cond_broadcast(cond); + pthread_cond_broadcast(&buf_pool.done_flush_list); mysql_mutex_unlock(&buf_pool.mutex); return 0; } - n_flush++; + buf_pool.n_flush_list++; - ulint n_flushed= lsn - ? buf_do_flush_list_batch(max_n, lsn) - : buf_do_LRU_batch(max_n); - - const auto n_flushing= --n_flush; + ulint n_flushed= buf_do_flush_list_batch(max_n, lsn); + const auto n_flushing= --buf_pool.n_flush_list; buf_pool.try_LRU_scan= true; mysql_mutex_unlock(&buf_pool.mutex); if (!n_flushing) - pthread_cond_broadcast(cond); + pthread_cond_broadcast(&buf_pool.done_flush_list); buf_dblwr.flush_buffered_writes(); - DBUG_PRINT("ib_buf", ("%s completed, " ULINTPF " pages", - lsn ? "flush_list" : "LRU flush", n_flushed)); + DBUG_PRINT("ib_buf", ("flush_list completed, " ULINTPF " pages", n_flushed)); return n_flushed; } +/** Try to flush all the dirty pages that belong to a given tablespace. +@param space tablespace +@param n_flushed number of pages written +@return whether any pages might not have been flushed */ +bool buf_flush_list_space(fil_space_t *space, ulint *n_flushed) +{ + const auto space_id= space->id; + ut_ad(space_id <= SRV_SPACE_ID_UPPER_BOUND); + + bool may_have_skipped= false; + ulint max_n_flush= srv_io_capacity; + + mysql_mutex_lock(&buf_pool.mutex); + mysql_mutex_lock(&buf_pool.flush_list_mutex); + + bool acquired= space->acquire(); + buf_flush_freed_pages(space); + + for (buf_page_t *bpage= UT_LIST_GET_LAST(buf_pool.flush_list); bpage; ) + { + ut_d(const auto s= bpage->state()); + ut_ad(s == BUF_BLOCK_ZIP_PAGE || s == BUF_BLOCK_FILE_PAGE || + s == BUF_BLOCK_REMOVE_HASH); + ut_ad(bpage->oldest_modification()); + ut_ad(bpage->in_file()); + + buf_page_t *prev= UT_LIST_GET_PREV(list, bpage); + if (bpage->id().space() != space_id); + else if (!bpage->ready_for_flush()) + may_have_skipped= true; + else + { + /* In order not to degenerate this scan to O(n*n) we attempt to + preserve the pointer position. Any thread that would remove 'prev' + from buf_pool.flush_list must adjust the hazard pointer. + + Note: Multiple executions of buf_flush_list_space() may be + interleaved, and also buf_do_flush_list_batch() may be running + concurrently. This may terminate our iteration prematurely, + leading us to return may_have_skipped=true. */ + buf_pool.flush_hp.set(prev); + mysql_mutex_unlock(&buf_pool.flush_list_mutex); + + if (!acquired) + { + was_freed: + buf_flush_discard_page(bpage); + } + else + { + if (space->is_stopping()) + { + space->release(); + acquired= false; + goto was_freed; + } + if (!buf_flush_page(bpage, false, space)) + { + may_have_skipped= true; + mysql_mutex_lock(&buf_pool.flush_list_mutex); + goto next_after_skip; + } + if (n_flushed) + ++*n_flushed; + if (!--max_n_flush) + { + mysql_mutex_lock(&buf_pool.mutex); + mysql_mutex_lock(&buf_pool.flush_list_mutex); + may_have_skipped= true; + break; + } + mysql_mutex_lock(&buf_pool.mutex); + } + + mysql_mutex_lock(&buf_pool.flush_list_mutex); + if (!buf_pool.flush_hp.is_hp(prev)) + may_have_skipped= true; +next_after_skip: + bpage= buf_pool.flush_hp.get(); + continue; + } + + bpage= prev; + } + + /* Note: this loop may have been executed concurrently with + buf_do_flush_list_batch() as well as other threads executing + buf_flush_list_space(). We should always return true from + buf_flush_list_space() if that should be the case; in + buf_do_flush_list_batch() we will simply perform less work. */ + + buf_pool.flush_hp.set(nullptr); + mysql_mutex_unlock(&buf_pool.flush_list_mutex); + + buf_pool.try_LRU_scan= true; + + mysql_mutex_unlock(&buf_pool.mutex); + + if (acquired) + space->release(); + + if (space->purpose == FIL_TYPE_IMPORT) + os_aio_wait_until_no_pending_writes(); + else + buf_dblwr.flush_buffered_writes(); + + return may_have_skipped; +} + +/** Write out dirty blocks from buf_pool.LRU. +@param max_n wished maximum mumber of blocks flushed +@return the number of processed pages +@retval 0 if a buf_pool.LRU batch is already running */ +ulint buf_flush_LRU(ulint max_n) +{ + if (buf_pool.n_flush_LRU) + return 0; + + log_buffer_flush_to_disk(true); + + mysql_mutex_lock(&buf_pool.mutex); + if (buf_pool.n_flush_LRU) + { + mysql_mutex_unlock(&buf_pool.mutex); + return 0; + } + buf_pool.n_flush_LRU++; + + ulint n_flushed= buf_do_LRU_batch(max_n); + + const auto n_flushing= --buf_pool.n_flush_LRU; + + buf_pool.try_LRU_scan= true; + + mysql_mutex_unlock(&buf_pool.mutex); + + if (!n_flushing) + pthread_cond_broadcast(&buf_pool.done_flush_LRU); + + buf_dblwr.flush_buffered_writes(); + + DBUG_PRINT("ib_buf", ("LRU flush completed, " ULINTPF " pages", n_flushed)); + return n_flushed; +} /** Initiate a log checkpoint, discarding the start of the log. @param oldest_lsn the checkpoint LSN @@ -1715,7 +1832,7 @@ ATTRIBUTE_COLD void buf_flush_wait_flushed(lsn_t sync_lsn) do { mysql_mutex_unlock(&buf_pool.flush_list_mutex); - ulint n_pages= buf_flush_lists(srv_max_io_capacity, sync_lsn); + ulint n_pages= buf_flush_list(srv_max_io_capacity, sync_lsn); buf_flush_wait_batch_end_acquiring_mutex(false); if (n_pages) { @@ -1810,7 +1927,7 @@ ATTRIBUTE_COLD static void buf_flush_sync_for_checkpoint(lsn_t lsn) { mysql_mutex_unlock(&buf_pool.flush_list_mutex); - if (ulint n_flushed= buf_flush_lists(srv_max_io_capacity, lsn)) + if (ulint n_flushed= buf_flush_list(srv_max_io_capacity, lsn)) { MONITOR_INC_VALUE_CUMULATIVE(MONITOR_FLUSH_SYNC_TOTAL_PAGE, MONITOR_FLUSH_SYNC_COUNT, @@ -2173,14 +2290,14 @@ unemployed: if (UNIV_UNLIKELY(lsn_limit != 0)) { - n_flushed= buf_flush_lists(srv_max_io_capacity, lsn_limit); + n_flushed= buf_flush_list(srv_max_io_capacity, lsn_limit); /* wake up buf_flush_wait_flushed() */ pthread_cond_broadcast(&buf_pool.done_flush_list); goto try_checkpoint; } else if (idle_flush || !srv_adaptive_flushing) { - n_flushed= buf_flush_lists(srv_io_capacity, LSN_MAX); + n_flushed= buf_flush_list(srv_io_capacity); try_checkpoint: if (n_flushed) { @@ -2207,7 +2324,7 @@ do_checkpoint: { page_cleaner.flush_pass++; const ulint tm= ut_time_ms(); - last_pages= n_flushed= buf_flush_lists(n, LSN_MAX); + last_pages= n_flushed= buf_flush_list(n); page_cleaner.flush_time+= ut_time_ms() - tm; if (n_flushed) @@ -2299,7 +2416,7 @@ ATTRIBUTE_COLD void buf_flush_buffer_pool() while (buf_pool.n_flush_list || buf_flush_list_length()) { - buf_flush_lists(srv_max_io_capacity, LSN_MAX); + buf_flush_list(srv_max_io_capacity); timespec abstime; if (buf_pool.n_flush_list) @@ -2327,7 +2444,7 @@ void buf_flush_sync() for (;;) { - const ulint n_flushed= buf_flush_lists(srv_max_io_capacity, LSN_MAX); + const ulint n_flushed= buf_flush_list(srv_max_io_capacity); buf_flush_wait_batch_end_acquiring_mutex(false); if (!n_flushed && !buf_flush_list_length()) return; diff --git a/storage/innobase/buf/buf0lru.cc b/storage/innobase/buf/buf0lru.cc index a6e73068787..38394237519 100644 --- a/storage/innobase/buf/buf0lru.cc +++ b/storage/innobase/buf/buf0lru.cc @@ -487,7 +487,7 @@ not_found: involved (particularly in case of ROW_FORMAT=COMPRESSED pages). We can do that in a separate patch sometime in future. */ - if (!buf_flush_lists(innodb_lru_flush_size, 0)) { + if (!buf_flush_LRU(innodb_lru_flush_size)) { MONITOR_INC(MONITOR_LRU_SINGLE_FLUSH_FAILURE_COUNT); ++flush_failures; } diff --git a/storage/innobase/fil/fil0crypt.cc b/storage/innobase/fil/fil0crypt.cc index c4882304206..ee8fc781b67 100644 --- a/storage/innobase/fil/fil0crypt.cc +++ b/storage/innobase/fil/fil0crypt.cc @@ -1098,7 +1098,7 @@ static bool fil_crypt_start_encrypting_space(fil_space_t* space) mtr.commit(); /* 4 - sync tablespace before publishing crypt data */ - while (buf_flush_dirty_pages(space->id)); + while (buf_flush_list_space(space)); /* 5 - publish crypt data */ mutex_enter(&fil_crypt_threads_mutex); @@ -2036,14 +2036,7 @@ fil_crypt_flush_space( if (end_lsn > 0 && !space->is_stopping()) { ulint sum_pages = 0; const ulonglong start = my_interval_timer(); - do { - ulint n_dirty= buf_flush_dirty_pages(state->space->id); - if (!n_dirty) { - break; - } - sum_pages += n_dirty; - } while (!space->is_stopping()); - + while (buf_flush_list_space(space, &sum_pages)); if (sum_pages) { const ulonglong end = my_interval_timer(); diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index 283b7326385..a2591dd9172 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -1742,7 +1742,7 @@ void fil_close_tablespace(ulint id) can no longer read more pages of this tablespace to buf_pool. Thus we can clean the tablespace out of buf_pool completely and permanently. */ - while (buf_flush_dirty_pages(id)); + while (buf_flush_list_space(space)); ut_ad(space->is_stopping()); /* If the free is successful, the X lock will be released before diff --git a/storage/innobase/include/buf0flu.h b/storage/innobase/include/buf0flu.h index 1dd0d35793b..d4a39c93b30 100644 --- a/storage/innobase/include/buf0flu.h +++ b/storage/innobase/include/buf0flu.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2014, 2020, MariaDB Corporation. +Copyright (c) 2014, 2021, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -54,12 +54,6 @@ the list as they age towards the tail of the LRU. @param id tablespace identifier */ void buf_flush_remove_pages(ulint id); -/** Try to flush all the dirty pages that belong to a given tablespace. -@param id tablespace identifier -@return number dirty pages that there were for this tablespace */ -ulint buf_flush_dirty_pages(ulint id) - MY_ATTRIBUTE((warn_unused_result)); - /*******************************************************************//** Relocates a buffer control block on the flush_list. Note that it is assumed that the contents of bpage has already been @@ -93,10 +87,23 @@ buf_flush_init_for_writing( /** Write out dirty blocks from buf_pool.flush_list. @param max_n wished maximum mumber of blocks flushed -@param lsn buf_pool.get_oldest_modification(LSN_MAX) target (0=LRU flush) +@param lsn buf_pool.get_oldest_modification(LSN_MAX) target @return the number of processed pages -@retval 0 if a batch of the same type (lsn==0 or lsn!=0) is already running */ -ulint buf_flush_lists(ulint max_n, lsn_t lsn); +@retval 0 if a buf_pool.flush_list batch is already running */ +ulint buf_flush_list(ulint max_n= ULINT_UNDEFINED, lsn_t lsn= LSN_MAX); + +/** Try to flush dirty pages that belong to a given tablespace. +@param space tablespace +@param n_flushed number of pages written +@return whether any pages might not have been flushed */ +bool buf_flush_list_space(fil_space_t *space, ulint *n_flushed= nullptr) + MY_ATTRIBUTE((warn_unused_result)); + +/** Write out dirty blocks from buf_pool.LRU. +@param max_n wished maximum mumber of blocks flushed +@return the number of processed pages +@retval 0 if a buf_pool.LRU batch is already running */ +ulint buf_flush_LRU(ulint max_n); /** Wait until a flush batch ends. @param lru true=buf_pool.LRU; false=buf_pool.flush_list */ diff --git a/storage/innobase/row/row0import.cc b/storage/innobase/row/row0import.cc index 1a22c67f8ba..52852f21f2c 100644 --- a/storage/innobase/row/row0import.cc +++ b/storage/innobase/row/row0import.cc @@ -4232,7 +4232,7 @@ row_import_for_mysql( /* Ensure that all pages dirtied during the IMPORT make it to disk. The only dirty pages generated should be from the pessimistic purge of delete marked records that couldn't be purged in Phase I. */ - while (buf_flush_dirty_pages(prebuilt->table->space_id)); + while (buf_flush_list_space(prebuilt->table->space)); for (ulint count = 0; prebuilt->table->space->referenced(); count++) { /* Issue a warning every 10.24 seconds, starting after diff --git a/storage/innobase/row/row0quiesce.cc b/storage/innobase/row/row0quiesce.cc index 8e0581dfa9b..f106cc8a39d 100644 --- a/storage/innobase/row/row0quiesce.cc +++ b/storage/innobase/row/row0quiesce.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2012, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2020, MariaDB Corporation. +Copyright (c) 2017, 2021, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -536,7 +536,7 @@ row_quiesce_table_start( } } - while (buf_flush_dirty_pages(table->space_id)) { + while (buf_flush_list_space(table->space)) { if (trx_is_interrupted(trx)) { goto aborted; } diff --git a/storage/innobase/trx/trx0purge.cc b/storage/innobase/trx/trx0purge.cc index 0a1d8ba7532..563ce9d0e23 100644 --- a/storage/innobase/trx/trx0purge.cc +++ b/storage/innobase/trx/trx0purge.cc @@ -596,7 +596,7 @@ static void trx_purge_truncate_history() return; } - const fil_space_t& space = *purge_sys.truncate.current; + fil_space_t& space = *purge_sys.truncate.current; /* Undo tablespace always are a single file. */ ut_a(UT_LIST_GET_LEN(space.chain) == 1); fil_node_t* file = UT_LIST_GET_FIRST(space.chain); @@ -672,7 +672,7 @@ not_free: mini-transaction commit and the server was killed, then discarding the to-be-trimmed pages without flushing would break crash recovery. So, we cannot avoid the write. */ - while (buf_flush_dirty_pages(space.id)); + while (buf_flush_list_space(&space)); log_free_check(); From 22b62edaedddb1cabd5b855cdd39a5e90a5695a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 23 Jun 2021 13:13:11 +0300 Subject: [PATCH 172/251] MDEV-25113: Make page flushing faster buf_page_write_complete(): Reduce the buf_pool.mutex hold time, and do not acquire buf_pool.flush_list_mutex at all. Instead, mark blocks clean by setting oldest_modification to 1. Dirty pages of temporary tables will be identified by the special value 2 instead of the previous special value 1. (By design of the ib_logfile0 format, actual LSN values smaller than 2048 are not possible.) buf_LRU_free_page(), buf_pool_t::get_oldest_modification() and many other functions will remove the garbage (clean blocks) from buf_pool.flush_list while holding buf_pool.flush_list_mutex. buf_pool_t::n_flush_LRU, buf_pool_t::n_flush_list: Replaced with non-atomic variables, protected by buf_pool.mutex, to avoid unnecessary synchronization when modifying the counts. export_vars: Remove unnecessary indirection for innodb_pages_created, innodb_pages_read, innodb_pages_written. --- storage/innobase/btr/btr0cur.cc | 2 +- storage/innobase/buf/buf0buf.cc | 27 +- storage/innobase/buf/buf0flu.cc | 339 ++++++++++++++------------ storage/innobase/buf/buf0lru.cc | 25 +- storage/innobase/dict/dict0dict.cc | 5 - storage/innobase/fil/fil0crypt.cc | 3 + storage/innobase/handler/ha_innodb.cc | 6 +- storage/innobase/include/buf0buf.h | 117 ++++++--- storage/innobase/include/buf0flu.h | 2 +- storage/innobase/include/buf0flu.ic | 23 +- storage/innobase/include/mtr0mtr.ic | 4 +- storage/innobase/include/srv0srv.h | 3 - storage/innobase/srv/srv0srv.cc | 6 - 13 files changed, 313 insertions(+), 249 deletions(-) diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc index 723096bd08c..5bb2a0e22d3 100644 --- a/storage/innobase/btr/btr0cur.cc +++ b/storage/innobase/btr/btr0cur.cc @@ -7101,7 +7101,7 @@ static void btr_blob_free(buf_block_t *block, bool all, mtr_t *mtr) mysql_mutex_lock(&buf_pool.mutex); if (buf_page_t *bpage= buf_pool.page_hash_get_low(page_id, fold)) - if(!buf_LRU_free_page(bpage, all) && all && bpage->zip.data) + if (!buf_LRU_free_page(bpage, all) && all && bpage->zip.data) /* Attempt to deallocate the redundant copy of the uncompressed page if the whole ROW_FORMAT=COMPRESSED block cannot be deallocted. */ buf_LRU_free_page(bpage, false); diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index 0ba56c346aa..b0997c43847 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -1346,13 +1346,15 @@ inline const buf_block_t *buf_pool_t::chunk_t::not_freed() const break; } + const lsn_t lsn= block->page.oldest_modification(); + if (fsp_is_system_temporary(block->page.id().space())) { - ut_ad(block->page.oldest_modification() <= 1); + ut_ad(lsn == 0 || lsn == 2); break; } - if (!block->page.ready_for_replace()) + if (lsn > 1 || !block->page.can_relocate()) return block; break; @@ -1509,9 +1511,9 @@ void buf_pool_t::close() Only on aborted startup (with recovery) or with innodb_fast_shutdown=2 we may discard changes. */ ut_d(const lsn_t oldest= bpage->oldest_modification();) - ut_ad(!oldest || srv_is_being_started || - srv_fast_shutdown == 2 || - (oldest == 1 && fsp_is_system_temporary(bpage->id().space()))); + ut_ad(fsp_is_system_temporary(bpage->id().space()) + ? (oldest == 0 || oldest == 2) + : oldest <= 1 || srv_is_being_started || srv_fast_shutdown == 2); if (bpage->state() != BUF_BLOCK_FILE_PAGE) buf_page_free_descriptor(bpage); @@ -3323,6 +3325,8 @@ re_evict: mysql_mutex_unlock(&buf_pool.mutex); buf_flush_list(); buf_flush_wait_batch_end_acquiring_mutex(false); + while (buf_flush_list_space(space)); + os_aio_wait_until_no_pending_writes(); if (fix_block->page.buf_fix_count() == 1 && !fix_block->page.oldest_modification()) { @@ -4438,8 +4442,8 @@ void buf_pool_t::print() << UT_LIST_GET_LEN(flush_list) << ", n pending decompressions=" << n_pend_unzip << ", n pending reads=" << n_pend_reads - << ", n pending flush LRU=" << n_flush_LRU - << " list=" << n_flush_list + << ", n pending flush LRU=" << n_flush_LRU_ + << " list=" << n_flush_list_ << ", pages made young=" << stat.n_pages_made_young << ", not young=" << stat.n_pages_not_made_young << ", pages read=" << stat.n_pages_read @@ -4538,7 +4542,6 @@ void buf_stats_get_pool_info(buf_pool_info_t *pool_info) double time_elapsed; mysql_mutex_lock(&buf_pool.mutex); - mysql_mutex_lock(&buf_pool.flush_list_mutex); pool_info->pool_size = buf_pool.curr_size; @@ -4548,17 +4551,17 @@ void buf_stats_get_pool_info(buf_pool_info_t *pool_info) pool_info->free_list_len = UT_LIST_GET_LEN(buf_pool.free); + mysql_mutex_lock(&buf_pool.flush_list_mutex); pool_info->flush_list_len = UT_LIST_GET_LEN(buf_pool.flush_list); pool_info->n_pend_unzip = UT_LIST_GET_LEN(buf_pool.unzip_LRU); + mysql_mutex_unlock(&buf_pool.flush_list_mutex); pool_info->n_pend_reads = buf_pool.n_pend_reads; - pool_info->n_pending_flush_lru = buf_pool.n_flush_LRU; + pool_info->n_pending_flush_lru = buf_pool.n_flush_LRU_; - pool_info->n_pending_flush_list = buf_pool.n_flush_list; - - mysql_mutex_unlock(&buf_pool.flush_list_mutex); + pool_info->n_pending_flush_list = buf_pool.n_flush_list_; current_time = time(NULL); time_elapsed = 0.001 + difftime(current_time, diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc index 3978f624e11..aa92ddfcec8 100644 --- a/storage/innobase/buf/buf0flu.cc +++ b/storage/innobase/buf/buf0flu.cc @@ -128,7 +128,7 @@ inline void buf_pool_t::page_cleaner_wakeup() double(UT_LIST_GET_LEN(buf_pool.LRU) + UT_LIST_GET_LEN(buf_pool.free)); double pct_lwm= srv_max_dirty_pages_pct_lwm; - /* if pct_lwm != 0.0 means adpative flushing is enabled. + /* if pct_lwm != 0.0, adaptive flushing is enabled. signal buf page cleaner thread - if pct_lwm <= dirty_pct then it will invoke apdative flushing flow - if pct_lwm > dirty_pct then it will invoke idle flushing flow. @@ -162,53 +162,58 @@ inline void buf_pool_t::page_cleaner_wakeup() } } -/** Insert a modified block into the flush list. -@param[in,out] block modified block -@param[in] lsn oldest modification */ -void buf_flush_insert_into_flush_list(buf_block_t* block, lsn_t lsn) -{ - mysql_mutex_assert_not_owner(&buf_pool.mutex); - mysql_mutex_assert_owner(&log_sys.flush_order_mutex); - ut_ad(lsn); - ut_ad(!fsp_is_system_temporary(block->page.id().space())); - - mysql_mutex_lock(&buf_pool.flush_list_mutex); - block->page.set_oldest_modification(lsn); - MEM_CHECK_DEFINED(block->page.zip.data - ? block->page.zip.data : block->frame, - block->physical_size()); - buf_pool.stat.flush_list_bytes += block->physical_size(); - ut_ad(buf_pool.stat.flush_list_bytes <= buf_pool.curr_pool_size); - - UT_LIST_ADD_FIRST(buf_pool.flush_list, &block->page); - ut_d(buf_flush_validate_skip()); - buf_pool.page_cleaner_wakeup(); - mysql_mutex_unlock(&buf_pool.flush_list_mutex); -} - -/** Remove a block from buf_pool.flush_list */ -static void buf_flush_remove_low(buf_page_t *bpage) +inline void buf_pool_t::delete_from_flush_list_low(buf_page_t *bpage) { ut_ad(!fsp_is_system_temporary(bpage->id().space())); - mysql_mutex_assert_owner(&buf_pool.mutex); - mysql_mutex_assert_owner(&buf_pool.flush_list_mutex); - ut_ad(!bpage->oldest_modification()); - buf_pool.flush_hp.adjust(bpage); - UT_LIST_REMOVE(buf_pool.flush_list, bpage); - buf_pool.stat.flush_list_bytes -= bpage->physical_size(); + mysql_mutex_assert_owner(&flush_list_mutex); + flush_hp.adjust(bpage); + UT_LIST_REMOVE(flush_list, bpage); +} + +/** Insert a modified block into the flush list. +@param block modified block +@param lsn start LSN of the mini-transaction that modified the block */ +void buf_pool_t::insert_into_flush_list(buf_block_t *block, lsn_t lsn) +{ + mysql_mutex_assert_not_owner(&mutex); + mysql_mutex_assert_owner(&log_sys.flush_order_mutex); + ut_ad(lsn > 2); + ut_ad(!fsp_is_system_temporary(block->page.id().space())); + + mysql_mutex_lock(&flush_list_mutex); + if (ut_d(const lsn_t old=) block->page.oldest_modification()) + { + ut_ad(old == 1); + delete_from_flush_list_low(&block->page); + } + else + stat.flush_list_bytes+= block->physical_size(); + ut_ad(stat.flush_list_bytes <= curr_pool_size); + + block->page.set_oldest_modification(lsn); + MEM_CHECK_DEFINED(block->page.zip.data + ? block->page.zip.data : block->frame, + block->physical_size()); + UT_LIST_ADD_FIRST(flush_list, &block->page); + ut_d(buf_flush_validate_skip()); + page_cleaner_wakeup(); + mysql_mutex_unlock(&flush_list_mutex); +} + +/** Remove a block from flush_list. +@param bpage buffer pool page +@param clear whether to invoke buf_page_t::clear_oldest_modification() */ +void buf_pool_t::delete_from_flush_list(buf_page_t *bpage, bool clear) +{ + if (clear) + bpage->clear_oldest_modification(); + delete_from_flush_list_low(bpage); + stat.flush_list_bytes-= bpage->physical_size(); #ifdef UNIV_DEBUG buf_flush_validate_skip(); #endif /* UNIV_DEBUG */ } -/** Remove a block from the flush list of modified blocks. -@param[in,out] bpage block to be removed from the flush list */ -static void buf_flush_remove(buf_page_t *bpage) -{ - bpage->clear_oldest_modification(); - buf_flush_remove_low(bpage); -} - /** Remove all dirty pages belonging to a given tablespace when we are deleting the data file of that tablespace. The pages still remain a part of LRU and are evicted from @@ -239,7 +244,7 @@ void buf_flush_remove_pages(ulint id) else if (bpage->io_fix() != BUF_IO_NONE) deferred= true; else - buf_flush_remove(bpage); + buf_pool.delete_from_flush_list(bpage); bpage= prev; } @@ -281,31 +286,43 @@ buf_flush_relocate_on_flush_list( mysql_mutex_assert_owner(&buf_pool.mutex); ut_ad(!fsp_is_system_temporary(bpage->id().space())); - if (!bpage->oldest_modification()) { + const lsn_t lsn = bpage->oldest_modification(); + + if (!lsn) { return; } + ut_ad(lsn == 1 || lsn > 2); + mysql_mutex_lock(&buf_pool.flush_list_mutex); - /* FIXME: At this point we have both buf_pool and flush_list - mutexes. Theoretically removal of a block from flush list is - only covered by flush_list mutex but currently we do - have buf_pool mutex in buf_flush_remove() therefore this block - is guaranteed to be in the flush list. We need to check if - this will work without the assumption of block removing code - having the buf_pool mutex. */ - ut_ad(dpage->oldest_modification()); + /* FIXME: Can we avoid holding buf_pool.mutex here? */ + ut_ad(dpage->oldest_modification() == lsn); - /* Important that we adjust the hazard pointer before removing - the bpage from the flush list. */ - buf_pool.flush_hp.adjust(bpage); + if (const lsn_t o_lsn = bpage->oldest_modification()) { + ut_ad(o_lsn == lsn); - bpage->clear_oldest_modification(); + /* Important that we adjust the hazard pointer before removing + the bpage from the flush list. */ + buf_pool.flush_hp.adjust(bpage); - prev = UT_LIST_GET_PREV(list, bpage); - UT_LIST_REMOVE(buf_pool.flush_list, bpage); + bpage->clear_oldest_modification(); - if (prev) { + prev = UT_LIST_GET_PREV(list, bpage); + UT_LIST_REMOVE(buf_pool.flush_list, bpage); + } else { + /* bpage was removed from buf_pool.flush_list + since we last checked, and before we acquired + buf_pool.flush_list_mutex. */ + dpage->list.prev = nullptr; + dpage->list.next = nullptr; + goto was_clean; + } + + if (lsn == 1) { +was_clean: + dpage->clear_oldest_modification(); + } else if (prev) { ut_ad(prev->oldest_modification()); UT_LIST_INSERT_AFTER(buf_pool.flush_list, prev, dpage); } else { @@ -326,25 +343,24 @@ void buf_page_write_complete(const IORequest &request) buf_page_t *bpage= request.bpage; ut_ad(bpage); ut_ad(bpage->in_file()); + /* bpage->io_fix() can only be changed by buf_page_write_complete() + and buf_page_read_complete() from BUF_IO_READ or BUF_IO_WRITE */ ut_ad(bpage->io_fix() == BUF_IO_WRITE); ut_ad(!buf_dblwr.is_inside(bpage->id())); - bool dblwr; + ut_ad(request.node->space->id == bpage->id().space()); + if (bpage->status == buf_page_t::INIT_ON_FLUSH) - { bpage->status= buf_page_t::NORMAL; - dblwr= false; - } else { ut_ad(bpage->status == buf_page_t::NORMAL); - dblwr= request.node->space->use_doublewrite(); + if (request.node->space->use_doublewrite()) + { + ut_ad(request.node->space != fil_system.temp_space); + buf_dblwr.write_completed(); + } } - /* We do not need protect io_fix here by mutex to read it because - this and buf_page_read_complete() are the only functions where we can - change the value from BUF_IO_READ or BUF_IO_WRITE to some other - value, and our code ensures that this is the only thread that handles - the i/o for this block. */ if (bpage->slot) { bpage->slot->release(); @@ -355,27 +371,16 @@ void buf_page_write_complete(const IORequest &request) buf_page_monitor(bpage, BUF_IO_WRITE); DBUG_PRINT("ib_buf", ("write page %u:%u", bpage->id().space(), bpage->id().page_no())); - ut_ad(request.is_LRU() ? buf_pool.n_flush_LRU : buf_pool.n_flush_list); const bool temp= fsp_is_system_temporary(bpage->id().space()); mysql_mutex_lock(&buf_pool.mutex); + buf_pool.stat.n_pages_written++; + /* While we do not need any mutex for clearing oldest_modification + here, we hope that it will be in the same cache line with io_fix, + whose changes must be protected by buf_pool.mutex. */ + bpage->clear_oldest_modification(temp); + ut_ad(bpage->io_fix() == BUF_IO_WRITE); bpage->set_io_fix(BUF_IO_NONE); - mysql_mutex_lock(&buf_pool.flush_list_mutex); - ut_ad(!temp || bpage->oldest_modification() == 1); - bpage->clear_oldest_modification(); - - if (!temp) - buf_flush_remove_low(bpage); - else - ut_ad(request.is_LRU()); - - mysql_mutex_unlock(&buf_pool.flush_list_mutex); - - if (dblwr) - { - ut_ad(!fsp_is_system_temporary(bpage->id().space())); - buf_dblwr.write_completed(); - } /* Because this thread which does the unlocking might not be the same that did the locking, we use a pass value != 0 in unlock, which simply @@ -383,17 +388,21 @@ void buf_page_write_complete(const IORequest &request) if (bpage->state() == BUF_BLOCK_FILE_PAGE) rw_lock_sx_unlock_gen(&((buf_block_t*) bpage)->lock, BUF_IO_WRITE); - buf_pool.stat.n_pages_written++; + if (request.is_LRU()) + buf_LRU_free_page(bpage, true); + else + ut_ad(!temp); if (request.is_LRU()) { - buf_LRU_free_page(bpage, true); - if (!--buf_pool.n_flush_LRU) + ut_ad(buf_pool.n_flush_LRU_); + if (!--buf_pool.n_flush_LRU_) pthread_cond_broadcast(&buf_pool.done_flush_LRU); } else { - if (!--buf_pool.n_flush_list) + ut_ad(buf_pool.n_flush_list_); + if (!--buf_pool.n_flush_list_) pthread_cond_broadcast(&buf_pool.done_flush_list); } @@ -780,36 +789,34 @@ not_compressed: return d; } -/** The following function deals with freed page during flushing. - i) Writing zeros to the file asynchronously if scrubbing is enabled - ii) Punch the hole to the file synchoronously if page_compressed is - enabled for the tablespace -This function also resets the IO_FIX to IO_NONE and making the -page status as NORMAL. It initiates the write to the file only after -releasing the page from flush list and its associated mutex. -@param[in,out] bpage freed buffer page */ -static void buf_release_freed_page(buf_page_t *bpage) +/** Free a page whose underlying file page has been freed. */ +inline void buf_pool_t::release_freed_page(buf_page_t *bpage) { ut_ad(bpage->in_file()); const bool uncompressed= bpage->state() == BUF_BLOCK_FILE_PAGE; - mysql_mutex_lock(&buf_pool.mutex); + mysql_mutex_lock(&mutex); bpage->set_io_fix(BUF_IO_NONE); bpage->status= buf_page_t::NORMAL; - const bool temp= fsp_is_system_temporary(bpage->id().space()); - ut_ad(!temp || uncompressed); - ut_ad(!temp || bpage->oldest_modification() == 1); - mysql_mutex_lock(&buf_pool.flush_list_mutex); + mysql_mutex_lock(&flush_list_mutex); + if (fsp_is_system_temporary(bpage->id().space())) + { + ut_ad(uncompressed); + ut_ad(bpage->oldest_modification() == 2); + } + else + { + ut_ad(bpage->oldest_modification() > 2); + delete_from_flush_list(bpage, false); + } bpage->clear_oldest_modification(); - if (!temp) - buf_flush_remove_low(bpage); - mysql_mutex_unlock(&buf_pool.flush_list_mutex); + mysql_mutex_unlock(&flush_list_mutex); if (uncompressed) rw_lock_sx_unlock_gen(&reinterpret_cast(bpage)->lock, BUF_IO_WRITE); buf_LRU_free_page(bpage, true); - mysql_mutex_unlock(&buf_pool.mutex); + mysql_mutex_unlock(&mutex); } /** Write a flushable page from buf_pool to a file. @@ -840,8 +847,22 @@ static bool buf_flush_page(buf_page_t *bpage, bool lru, fil_space_t *space) } bpage->set_io_fix(BUF_IO_WRITE); - buf_flush_page_count++; - mysql_mutex_unlock(&buf_pool.mutex); + /* Because bpage->status can only be changed while buf_block_t + exists, it cannot be modified for ROW_FORMAT=COMPRESSED pages + without first allocating the uncompressed page frame. Such + allocation cannot be completed due to our io_fix. So, bpage->status + is protected even if !rw_lock. */ + const auto status= bpage->status; + + if (status != buf_page_t::FREED) + { + if (lru) + buf_pool.n_flush_LRU_++; + else + buf_pool.n_flush_list_++; + buf_flush_page_count++; + } + mysql_mutex_assert_not_owner(&buf_pool.flush_list_mutex); /* We are holding rw_lock = buf_block_t::lock in SX mode except if @@ -860,20 +881,14 @@ static bool buf_flush_page(buf_page_t *bpage, bool lru, fil_space_t *space) ut_ad(bpage->state() == (rw_lock ? BUF_BLOCK_FILE_PAGE : BUF_BLOCK_ZIP_PAGE)); ut_ad(ULINT_UNDEFINED > - (lru ? buf_pool.n_flush_LRU : buf_pool.n_flush_list)); - - /* Because bpage->status can only be changed while buf_block_t - exists, it cannot be modified for ROW_FORMAT=COMPRESSED pages - without first allocating the uncompressed page frame. Such - allocation cannot be completed due to our io_fix. So, bpage->status - is protected even if !rw_lock. */ - const auto status= bpage->status; + (lru ? buf_pool.n_flush_LRU_ : buf_pool.n_flush_list_)); + mysql_mutex_unlock(&buf_pool.mutex); buf_block_t *block= reinterpret_cast(bpage); page_t *frame= bpage->zip.data; if (status == buf_page_t::FREED) - buf_release_freed_page(&block->page); + buf_pool.release_freed_page(&block->page); else { space->reacquire(); @@ -909,8 +924,8 @@ static bool buf_flush_page(buf_page_t *bpage, bool lru, fil_space_t *space) /* innodb_checksum_algorithm=full_crc32 is not implemented for ROW_FORMAT=COMPRESSED pages. */ ut_ad(!frame); - page= buf_page_encrypt(space, bpage, page, &size); - buf_flush_init_for_writing(block, page, nullptr, true); + page= buf_page_encrypt(space, bpage, page, &size); + buf_flush_init_for_writing(block, page, nullptr, true); } else { @@ -928,11 +943,6 @@ static bool buf_flush_page(buf_page_t *bpage, bool lru, fil_space_t *space) ut_ad(status == bpage->status); - if (lru) - buf_pool.n_flush_LRU++; - else - buf_pool.n_flush_list++; - if (status != buf_page_t::NORMAL || !space->use_doublewrite()) { if (UNIV_LIKELY(space->purpose == FIL_TYPE_TABLESPACE)) @@ -974,8 +984,10 @@ static bool buf_flush_check_neighbor(const page_id_t id, ulint fold, bool lru) /* We avoid flushing 'non-old' blocks in an LRU flush, because the flushed blocks are soon freed */ + if (lru && !bpage->is_old()) + return false; - return (!lru || bpage->is_old()) && bpage->ready_for_flush(); + return bpage->oldest_modification() > 1 && bpage->ready_for_flush(); } /** Check which neighbors of a page can be flushed from the buf_pool. @@ -1135,6 +1147,7 @@ static ulint buf_flush_try_neighbors(fil_space_t *space, if (!lru || id == page_id || bpage->is_old()) { if (!buf_pool.watch_is_sentinel(*bpage) && + bpage->oldest_modification() > 1 && bpage->ready_for_flush() && buf_flush_page(bpage, lru, space)) { ++count; @@ -1247,7 +1260,7 @@ static void buf_flush_discard_page(buf_page_t *bpage) bpage->status= buf_page_t::NORMAL; mysql_mutex_lock(&buf_pool.flush_list_mutex); - buf_flush_remove(bpage); + buf_pool.delete_from_flush_list(bpage); mysql_mutex_unlock(&buf_pool.flush_list_mutex); if (rw_lock) @@ -1278,20 +1291,20 @@ static void buf_flush_LRU_list_batch(ulint max, flush_counters_t *n) for (buf_page_t *bpage= UT_LIST_GET_LAST(buf_pool.LRU); bpage && n->flushed + n->evicted < max && UT_LIST_GET_LEN(buf_pool.LRU) > BUF_LRU_MIN_LEN && - UT_LIST_GET_LEN(buf_pool.free) < free_limit; - ++scanned, bpage= buf_pool.lru_hp.get()) + UT_LIST_GET_LEN(buf_pool.free) < free_limit; ++scanned) { buf_page_t *prev= UT_LIST_GET_PREV(LRU, bpage); + const lsn_t oldest_modification= bpage->oldest_modification(); buf_pool.lru_hp.set(prev); - if (bpage->ready_for_replace()) + if (oldest_modification <= 1 && bpage->can_relocate()) { /* block is ready for eviction i.e., it is clean and is not IO-fixed or buffer fixed. */ if (buf_LRU_free_page(bpage, true)) ++n->evicted; } - else if (bpage->ready_for_flush()) + else if (oldest_modification > 1 && bpage->ready_for_flush()) { /* Block is ready for flush. Dispatch an IO request. The IO helper thread will put it on free list in IO completion routine. */ @@ -1334,6 +1347,7 @@ reacquire_mutex: else /* Can't evict or dispatch this block. Go to previous. */ ut_ad(buf_pool.lru_hp.is_hp(prev)); + bpage= buf_pool.lru_hp.get(); } buf_pool.lru_hp.set(nullptr); @@ -1405,23 +1419,29 @@ static ulint buf_do_flush_list_batch(ulint max_n, lsn_t lsn) ulint len= UT_LIST_GET_LEN(buf_pool.flush_list); for (buf_page_t *bpage= UT_LIST_GET_LAST(buf_pool.flush_list); - bpage && len && count < max_n; - bpage= buf_pool.flush_hp.get(), ++scanned, len--) + bpage && len && count < max_n; ++scanned, len--) { const lsn_t oldest_modification= bpage->oldest_modification(); if (oldest_modification >= lsn) break; - ut_ad(oldest_modification); ut_ad(bpage->in_file()); buf_page_t *prev= UT_LIST_GET_PREV(list, bpage); - if (!bpage->ready_for_flush()) + if (oldest_modification == 1) { + buf_pool.delete_from_flush_list(bpage); + skip: bpage= prev; continue; } + ut_ad(oldest_modification > 2); + ut_ad(bpage->in_file()); + + if (!bpage->ready_for_flush()) + goto skip; + /* In order not to degenerate this scan to O(n*n) we attempt to preserve the pointer position. Any thread that would remove 'prev' from buf_pool.flush_list must adjust the hazard pointer. @@ -1498,7 +1518,7 @@ static ulint buf_do_flush_list_batch(ulint max_n, lsn_t lsn) @param lru true=buf_pool.LRU; false=buf_pool.flush_list */ void buf_flush_wait_batch_end(bool lru) { - const auto &n_flush= lru ? buf_pool.n_flush_LRU : buf_pool.n_flush_list; + const auto &n_flush= lru ? buf_pool.n_flush_LRU_ : buf_pool.n_flush_list_; if (n_flush) { @@ -1523,11 +1543,11 @@ ulint buf_flush_list(ulint max_n, lsn_t lsn) { ut_ad(lsn); - if (buf_pool.n_flush_list) + if (buf_pool.n_flush_list()) return 0; mysql_mutex_lock(&buf_pool.mutex); - const bool running= buf_pool.n_flush_list != 0; + const bool running= buf_pool.n_flush_list_ != 0; /* FIXME: we are performing a dirty read of buf_pool.flush_list.count while not holding buf_pool.flush_list_mutex */ if (running || !UT_LIST_GET_LEN(buf_pool.flush_list)) @@ -1537,10 +1557,10 @@ ulint buf_flush_list(ulint max_n, lsn_t lsn) mysql_mutex_unlock(&buf_pool.mutex); return 0; } - buf_pool.n_flush_list++; - ulint n_flushed= buf_do_flush_list_batch(max_n, lsn); - const auto n_flushing= --buf_pool.n_flush_list; + buf_pool.n_flush_list_++; + const ulint n_flushed= buf_do_flush_list_batch(max_n, lsn); + const ulint n_flushing= --buf_pool.n_flush_list_; buf_pool.try_LRU_scan= true; @@ -1558,7 +1578,7 @@ ulint buf_flush_list(ulint max_n, lsn_t lsn) /** Try to flush all the dirty pages that belong to a given tablespace. @param space tablespace @param n_flushed number of pages written -@return whether any pages might not have been flushed */ +@return whether the flush for some pages might not have been initiated */ bool buf_flush_list_space(fil_space_t *space, ulint *n_flushed) { const auto space_id= space->id; @@ -1583,6 +1603,8 @@ bool buf_flush_list_space(fil_space_t *space, ulint *n_flushed) buf_page_t *prev= UT_LIST_GET_PREV(list, bpage); if (bpage->id().space() != space_id); + else if (bpage->oldest_modification() == 1) + buf_pool.delete_from_flush_list(bpage); else if (!bpage->ready_for_flush()) may_have_skipped= true; else @@ -1632,7 +1654,7 @@ bool buf_flush_list_space(fil_space_t *space, ulint *n_flushed) mysql_mutex_lock(&buf_pool.flush_list_mutex); if (!buf_pool.flush_hp.is_hp(prev)) may_have_skipped= true; -next_after_skip: + next_after_skip: bpage= buf_pool.flush_hp.get(); continue; } @@ -1670,22 +1692,22 @@ next_after_skip: @retval 0 if a buf_pool.LRU batch is already running */ ulint buf_flush_LRU(ulint max_n) { - if (buf_pool.n_flush_LRU) + if (buf_pool.n_flush_LRU()) return 0; log_buffer_flush_to_disk(true); mysql_mutex_lock(&buf_pool.mutex); - if (buf_pool.n_flush_LRU) + if (buf_pool.n_flush_LRU_) { mysql_mutex_unlock(&buf_pool.mutex); return 0; } - buf_pool.n_flush_LRU++; + buf_pool.n_flush_LRU_++; ulint n_flushed= buf_do_LRU_batch(max_n); - const auto n_flushing= --buf_pool.n_flush_LRU; + const ulint n_flushing= --buf_pool.n_flush_LRU_; buf_pool.try_LRU_scan= true; @@ -1908,7 +1930,7 @@ void buf_flush_ahead(lsn_t lsn) /** Wait for pending flushes to complete. */ void buf_flush_wait_batch_end_acquiring_mutex(bool lru) { - if (lru ? buf_pool.n_flush_LRU : buf_pool.n_flush_list) + if (lru ? buf_pool.n_flush_LRU() : buf_pool.n_flush_list()) { mysql_mutex_lock(&buf_pool.mutex); buf_flush_wait_batch_end(lru); @@ -2205,7 +2227,6 @@ furious_flush: else if (srv_shutdown_state > SRV_SHUTDOWN_INITIATED) break; - /* If buf pager cleaner is idle and there is no work (either dirty pages are all flushed or adaptive flushing is not enabled) then opt for non-timed wait */ @@ -2229,9 +2250,9 @@ furious_flush: else if (srv_shutdown_state > SRV_SHUTDOWN_INITIATED) break; - const ulint dirty_blocks= UT_LIST_GET_LEN(buf_pool.flush_list); + const lsn_t oldest_lsn= buf_pool.get_oldest_modification(0); - if (!dirty_blocks) + if (!oldest_lsn) { if (UNIV_UNLIKELY(lsn_limit != 0)) { @@ -2244,16 +2265,14 @@ unemployed: continue; } + const ulint dirty_blocks= UT_LIST_GET_LEN(buf_pool.flush_list); + ut_ad(dirty_blocks); /* We perform dirty reads of the LRU+free list lengths here. Division by zero is not possible, because buf_pool.flush_list is guaranteed to be nonempty, and it is a subset of buf_pool.LRU. */ const double dirty_pct= double(dirty_blocks) * 100.0 / double(UT_LIST_GET_LEN(buf_pool.LRU) + UT_LIST_GET_LEN(buf_pool.free)); - const lsn_t oldest_lsn= buf_pool.get_oldest_modified() - ->oldest_modification(); - ut_ad(oldest_lsn); - bool idle_flush= false; if (lsn_limit); @@ -2414,19 +2433,19 @@ ATTRIBUTE_COLD void buf_flush_buffer_pool() service_manager_extend_timeout(INNODB_EXTEND_TIMEOUT_INTERVAL, "Waiting to flush the buffer pool"); - while (buf_pool.n_flush_list || buf_flush_list_length()) + while (buf_pool.n_flush_list() || buf_flush_list_length()) { buf_flush_list(srv_max_io_capacity); timespec abstime; - if (buf_pool.n_flush_list) + if (buf_pool.n_flush_list()) { service_manager_extend_timeout(INNODB_EXTEND_TIMEOUT_INTERVAL, "Waiting to flush " ULINTPF " pages", buf_flush_list_length()); set_timespec(abstime, INNODB_EXTEND_TIMEOUT_INTERVAL / 2); mysql_mutex_lock(&buf_pool.mutex); - while (buf_pool.n_flush_list) + while (buf_pool.n_flush_list_) my_cond_timedwait(&buf_pool.done_flush_list, &buf_pool.mutex.m_mutex, &abstime); mysql_mutex_unlock(&buf_pool.mutex); @@ -2483,10 +2502,10 @@ static void buf_flush_validate_low() ut_d(const auto s= bpage->state()); ut_ad(s == BUF_BLOCK_ZIP_PAGE || s == BUF_BLOCK_FILE_PAGE || s == BUF_BLOCK_REMOVE_HASH); - ut_ad(om > 0); + ut_ad(om == 1 || om > 2); bpage = UT_LIST_GET_NEXT(list, bpage); - ut_ad(!bpage || recv_recovery_is_on() + ut_ad(om == 1 || !bpage || recv_recovery_is_on() || om >= bpage->oldest_modification()); } } diff --git a/storage/innobase/buf/buf0lru.cc b/storage/innobase/buf/buf0lru.cc index 38394237519..a776ae75949 100644 --- a/storage/innobase/buf/buf0lru.cc +++ b/storage/innobase/buf/buf0lru.cc @@ -108,7 +108,7 @@ uint buf_LRU_old_threshold_ms; /** Remove bpage from buf_pool.LRU and buf_pool.page_hash. -If bpage->state() == BUF_BLOCK_ZIP_PAGE && !bpage->oldest_modification(), +If bpage->state() == BUF_BLOCK_ZIP_PAGE && bpage->oldest_modification() <= 1, the object will be freed. @param bpage buffer block @@ -242,8 +242,8 @@ static bool buf_LRU_free_from_common_LRU_list(ulint limit) buf_pool.lru_scan_itr.set(prev); const auto accessed = bpage->is_accessed(); - if (!bpage->oldest_modification() - && buf_LRU_free_page(bpage, true)) { + + if (buf_LRU_free_page(bpage, true)) { if (!accessed) { /* Keep track of pages that are evicted without ever being accessed. This gives us a measure of @@ -449,8 +449,8 @@ retry: #ifndef DBUG_OFF not_found: #endif + buf_flush_wait_batch_end(true); mysql_mutex_unlock(&buf_pool.mutex); - buf_flush_wait_batch_end_acquiring_mutex(true); if (n_iterations > 20 && !buf_lru_free_blocks_error_printed && srv_buf_pool_old_size == srv_buf_pool_size) { @@ -801,20 +801,33 @@ bool buf_LRU_free_page(buf_page_t *bpage, bool zip) const ulint fold = id.fold(); page_hash_latch* hash_lock = buf_pool.page_hash.lock_get(fold); hash_lock->write_lock(); + lsn_t oldest_modification = bpage->oldest_modification(); if (UNIV_UNLIKELY(!bpage->can_relocate())) { /* Do not free buffer fixed and I/O-fixed blocks. */ goto func_exit; } + if (oldest_modification == 1) { + mysql_mutex_lock(&buf_pool.flush_list_mutex); + oldest_modification = bpage->oldest_modification(); + if (oldest_modification) { + ut_ad(oldest_modification == 1); + buf_pool.delete_from_flush_list(bpage); + } + mysql_mutex_unlock(&buf_pool.flush_list_mutex); + ut_ad(!bpage->oldest_modification()); + oldest_modification = 0; + } + if (zip || !bpage->zip.data) { /* This would completely free the block. */ /* Do not completely free dirty blocks. */ - if (bpage->oldest_modification()) { + if (oldest_modification) { goto func_exit; } - } else if (bpage->oldest_modification() + } else if (oldest_modification && bpage->state() != BUF_BLOCK_FILE_PAGE) { func_exit: hash_lock->write_unlock(); diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc index 37c8453da01..7d80fc7eeae 100644 --- a/storage/innobase/dict/dict0dict.cc +++ b/storage/innobase/dict/dict0dict.cc @@ -40,11 +40,6 @@ Created 1/8/1996 Heikki Tuuri #include "sql_table.h" #include -#if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG -/** Flag to control insert buffer debugging. */ -extern uint ibuf_debug; -#endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */ - #include "btr0btr.h" #include "btr0cur.h" #include "btr0sea.h" diff --git a/storage/innobase/fil/fil0crypt.cc b/storage/innobase/fil/fil0crypt.cc index ee8fc781b67..960cd7f7eeb 100644 --- a/storage/innobase/fil/fil0crypt.cc +++ b/storage/innobase/fil/fil0crypt.cc @@ -1892,6 +1892,9 @@ fil_crypt_rotate_page( if (block->page.status == buf_page_t::FREED) { /* Do not modify freed pages to avoid an assertion failure on recovery.*/ + } else if (block->page.oldest_modification() > 1) { + /* Do not unnecessarily touch pages that are + already dirty. */ } else if (space->is_stopping()) { /* The tablespace is closing (in DROP TABLE or TRUNCATE TABLE or similar): avoid further access */ diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 6c6ebb47810..d61624a5e37 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -955,9 +955,9 @@ static SHOW_VAR innodb_status_variables[]= { SHOW_SIZE_T}, {"os_log_written", &export_vars.innodb_os_log_written, SHOW_SIZE_T}, {"page_size", &srv_page_size, SHOW_ULONG}, - {"pages_created", &export_vars.innodb_pages_created, SHOW_SIZE_T}, - {"pages_read", &export_vars.innodb_pages_read, SHOW_SIZE_T}, - {"pages_written", &export_vars.innodb_pages_written, SHOW_SIZE_T}, + {"pages_created", &buf_pool.stat.n_pages_created, SHOW_SIZE_T}, + {"pages_read", &buf_pool.stat.n_pages_read, SHOW_SIZE_T}, + {"pages_written", &buf_pool.stat.n_pages_written, SHOW_SIZE_T}, {"row_lock_current_waits", &export_vars.innodb_row_lock_current_waits, SHOW_SIZE_T}, {"row_lock_time", &export_vars.innodb_row_lock_time, SHOW_LONGLONG}, diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h index deff8054362..404c46aa9f3 100644 --- a/storage/innobase/include/buf0buf.h +++ b/storage/innobase/include/buf0buf.h @@ -763,6 +763,16 @@ private: /** Count of how manyfold this block is currently bufferfixed. */ Atomic_counter buf_fix_count_; + /** log sequence number of the START of the log entry written of the + oldest modification to this block which has not yet been written + to the data file; + + 0 if no modifications are pending; + 1 if no modifications are pending, but the block is in buf_pool.flush_list; + 2 if modifications are pending, but the block is not in buf_pool.flush_list + (because id().space() is the temporary tablespace). */ + Atomic_counter oldest_modification_; + /** type of pending I/O operation; protected by buf_pool.mutex if in_LRU_list */ Atomic_relaxed io_fix_; @@ -812,12 +822,6 @@ public: or if state() is BUF_BLOCK_MEMORY or BUF_BLOCK_REMOVE_HASH. */ UT_LIST_NODE_T(buf_page_t) list; -private: - /** log sequence number of the START of the log entry written of the - oldest modification to this block which has not yet been written - to the data file; 0 if no modifications are pending. */ - Atomic_counter oldest_modification_; -public: /** @name LRU replacement algorithm fields. Protected by buf_pool.mutex. */ /* @{ */ @@ -932,12 +936,19 @@ public: inline void set_io_fix(buf_io_fix io_fix); inline void set_corrupt_id(); - /** @return the oldest modification */ + /** @return the log sequence number of the oldest pending modification + @retval 0 if the block is not in buf_pool.flush_list + @retval 1 if the block is in buf_pool.flush_list but not modified + @retval 2 if the block belongs to the temporary tablespace and + has unwritten changes */ lsn_t oldest_modification() const { return oldest_modification_; } /** Set oldest_modification when adding to buf_pool.flush_list */ inline void set_oldest_modification(lsn_t lsn); /** Clear oldest_modification when removing from buf_pool.flush_list */ inline void clear_oldest_modification(); + /** Note that a block is no longer dirty, while not removing + it from buf_pool.flush_list */ + inline void clear_oldest_modification(bool temporary); /** Notify that a page in a temporary tablespace has been modified. */ void set_temp_modified() @@ -945,7 +956,7 @@ public: ut_ad(fsp_is_system_temporary(id().space())); ut_ad(state() == BUF_BLOCK_FILE_PAGE); ut_ad(!oldest_modification()); - oldest_modification_= 1; + oldest_modification_= 2; } /** Prepare to release a file page to buf_pool.free. */ @@ -1562,23 +1573,24 @@ public: bool is_block_lock(const rw_lock_t *l) const { return is_block_field(static_cast(l)); } - /** @return the block that was made dirty the longest time ago */ - const buf_page_t *get_oldest_modified() const - { - mysql_mutex_assert_owner(&flush_list_mutex); - const buf_page_t *bpage= UT_LIST_GET_LAST(flush_list); - ut_ad(!bpage || !fsp_is_system_temporary(bpage->id().space())); - ut_ad(!bpage || bpage->oldest_modification()); - return bpage; - } - /** @return the smallest oldest_modification lsn for any page @retval empty_lsn if all modified persistent pages have been flushed */ - lsn_t get_oldest_modification(lsn_t empty_lsn) const + lsn_t get_oldest_modification(lsn_t empty_lsn) { - const buf_page_t *bpage= get_oldest_modified(); - return bpage ? bpage->oldest_modification() : empty_lsn; + mysql_mutex_assert_owner(&flush_list_mutex); + while (buf_page_t *bpage= UT_LIST_GET_LAST(flush_list)) + { + ut_ad(!fsp_is_system_temporary(bpage->id().space())); + lsn_t lsn= bpage->oldest_modification(); + if (lsn != 1) + { + ut_ad(lsn > 2); + return lsn; + } + delete_from_flush_list(bpage); + } + return empty_lsn; } /** Determine if a buffer block was created by chunk_t::create(). @@ -1792,15 +1804,18 @@ public: /** Buffer pool mutex */ MY_ALIGNED(CPU_LEVEL1_DCACHE_LINESIZE) mysql_mutex_t mutex; - /** Number of pending LRU flush. */ - Atomic_counter n_flush_LRU; + /** Number of pending LRU flush; protected by mutex. */ + ulint n_flush_LRU_; /** broadcast when n_flush_LRU reaches 0; protected by mutex */ pthread_cond_t done_flush_LRU; - /** Number of pending flush_list flush. */ - Atomic_counter n_flush_list; + /** Number of pending flush_list flush; protected by mutex */ + ulint n_flush_list_; /** broadcast when n_flush_list reaches 0; protected by mutex */ pthread_cond_t done_flush_list; + TPOOL_SUPPRESS_TSAN ulint n_flush_LRU() const { return n_flush_LRU_; } + TPOOL_SUPPRESS_TSAN ulint n_flush_list() const { return n_flush_list_; } + /** @name General fields */ /* @{ */ ulint curr_pool_size; /*!< Current pool size in bytes */ @@ -1975,8 +1990,8 @@ public: last_activity_count= activity_count; } - // n_flush_LRU + n_flush_list is approximately COUNT(io_fix()==BUF_IO_WRITE) - // in flush_list + // n_flush_LRU() + n_flush_list() + // is approximately COUNT(io_fix()==BUF_IO_WRITE) in flush_list unsigned freed_page_clock;/*!< a sequence number used to count the number of buffer @@ -2061,13 +2076,35 @@ public: /** @return whether any I/O is pending */ bool any_io_pending() const { - return n_pend_reads || n_flush_LRU || n_flush_list; + return n_pend_reads || n_flush_LRU() || n_flush_list(); } /** @return total amount of pending I/O */ ulint io_pending() const { - return n_pend_reads + n_flush_LRU + n_flush_list; + return n_pend_reads + n_flush_LRU() + n_flush_list(); } + +private: + /** Remove a block from the flush list. */ + inline void delete_from_flush_list_low(buf_page_t *bpage); + /** Remove a block from flush_list. + @param bpage buffer pool page + @param clear whether to invoke buf_page_t::clear_oldest_modification() */ + void delete_from_flush_list(buf_page_t *bpage, bool clear); +public: + /** Remove a block from flush_list. + @param bpage buffer pool page */ + void delete_from_flush_list(buf_page_t *bpage) + { delete_from_flush_list(bpage, true); } + + /** Insert a modified block into the flush list. + @param block modified block + @param lsn start LSN of the mini-transaction that modified the block */ + void insert_into_flush_list(buf_block_t *block, lsn_t lsn); + + /** Free a page whose underlying file page has been freed. */ + inline void release_freed_page(buf_page_t *bpage); + private: /** Temporary memory for page_compressed and encrypted I/O */ struct io_buf_t @@ -2180,7 +2217,7 @@ inline void buf_page_t::set_corrupt_id() switch (oldest_modification()) { case 0: break; - case 1: + case 2: ut_ad(fsp_is_system_temporary(id().space())); ut_d(oldest_modification_= 0); /* for buf_LRU_block_free_non_file_page() */ break; @@ -2206,7 +2243,7 @@ inline void buf_page_t::set_corrupt_id() inline void buf_page_t::set_oldest_modification(lsn_t lsn) { mysql_mutex_assert_owner(&buf_pool.flush_list_mutex); - ut_ad(!oldest_modification()); + ut_ad(oldest_modification() <= 1); oldest_modification_= lsn; } @@ -2221,13 +2258,27 @@ inline void buf_page_t::clear_oldest_modification() oldest_modification_= 0; } +/** Note that a block is no longer dirty, while not removing +it from buf_pool.flush_list */ +inline void buf_page_t::clear_oldest_modification(bool temporary) +{ + mysql_mutex_assert_not_owner(&buf_pool.flush_list_mutex); + ut_ad(temporary == fsp_is_system_temporary(id().space())); + ut_ad(io_fix_ == BUF_IO_WRITE); + ut_ad(temporary ? oldest_modification() == 2 : oldest_modification() > 2); + oldest_modification_= !temporary; +} + /** @return whether the block is modified and ready for flushing */ inline bool buf_page_t::ready_for_flush() const { mysql_mutex_assert_owner(&buf_pool.mutex); ut_ad(in_LRU_list); ut_a(in_file()); - return oldest_modification() && io_fix_ == BUF_IO_NONE; + ut_ad(fsp_is_system_temporary(id().space()) + ? oldest_modification() == 2 + : oldest_modification() > 2); + return io_fix_ == BUF_IO_NONE; } /** @return whether the block can be relocated in memory. @@ -2304,7 +2355,7 @@ MEMORY: is not in free list, LRU list, or flush list, nor page hash table FILE_PAGE: space and offset are defined, is in page hash table if io_fix == BUF_IO_WRITE, - buf_pool.n_flush_LRU > 0 || buf_pool.n_flush_list > 0 + buf_pool.n_flush_LRU() || buf_pool.n_flush_list() (1) if buf_fix_count == 0, then is in LRU list, not in free list diff --git a/storage/innobase/include/buf0flu.h b/storage/innobase/include/buf0flu.h index d4a39c93b30..76a4ecff950 100644 --- a/storage/innobase/include/buf0flu.h +++ b/storage/innobase/include/buf0flu.h @@ -95,7 +95,7 @@ ulint buf_flush_list(ulint max_n= ULINT_UNDEFINED, lsn_t lsn= LSN_MAX); /** Try to flush dirty pages that belong to a given tablespace. @param space tablespace @param n_flushed number of pages written -@return whether any pages might not have been flushed */ +@return whether the flush for some pages might not have been initiated */ bool buf_flush_list_space(fil_space_t *space, ulint *n_flushed= nullptr) MY_ATTRIBUTE((warn_unused_result)); diff --git a/storage/innobase/include/buf0flu.ic b/storage/innobase/include/buf0flu.ic index cd853fc05cd..b8a9b6d1f5d 100644 --- a/storage/innobase/include/buf0flu.ic +++ b/storage/innobase/include/buf0flu.ic @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2019, 2020, MariaDB Corporation. +Copyright (c) 2019, 2021, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -26,17 +26,7 @@ Created 11/5/1995 Heikki Tuuri #include "assume_aligned.h" #include "buf0buf.h" -#include "mtr0mtr.h" #include "srv0srv.h" -#include "fsp0types.h" - -/********************************************************************//** -Inserts a modified block into the flush list. */ -void -buf_flush_insert_into_flush_list( -/*=============================*/ - buf_block_t* block, /*!< in/out: block which is modified */ - lsn_t lsn); /*!< in: oldest modification */ /********************************************************************//** This function should be called at a mini-transaction commit, if a page was @@ -52,8 +42,7 @@ buf_flush_note_modification( lsn_t end_lsn) /*!< in: end lsn of the mtr that modified this block */ { - ut_ad(!srv_read_only_mode - || fsp_is_system_temporary(block->page.id().space())); + ut_ad(!srv_read_only_mode); ut_ad(block->page.state() == BUF_BLOCK_FILE_PAGE); ut_ad(block->page.buf_fix_count()); ut_ad(mach_read_from_8(block->frame + FIL_PAGE_LSN) <= end_lsn); @@ -65,12 +54,12 @@ buf_flush_note_modification( const lsn_t oldest_modification = block->page.oldest_modification(); - if (oldest_modification) { + if (oldest_modification > 1) { ut_ad(oldest_modification <= start_lsn); - } else if (!fsp_is_system_temporary(block->page.id().space())) { - buf_flush_insert_into_flush_list(block, start_lsn); - } else { + } else if (fsp_is_system_temporary(block->page.id().space())) { block->page.set_temp_modified(); + } else { + buf_pool.insert_into_flush_list(block, start_lsn); } srv_stats.buf_pool_write_requests.inc(); diff --git a/storage/innobase/include/mtr0mtr.ic b/storage/innobase/include/mtr0mtr.ic index 9540290fd19..4a483379e21 100644 --- a/storage/innobase/include/mtr0mtr.ic +++ b/storage/innobase/include/mtr0mtr.ic @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2014, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2020, MariaDB Corporation. +Copyright (c) 2017, 2021, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -32,7 +32,7 @@ inline bool mtr_t::is_block_dirtied(const buf_block_t *block) { ut_ad(block->page.state() == BUF_BLOCK_FILE_PAGE); ut_ad(block->page.buf_fix_count()); - return !block->page.oldest_modification(); + return block->page.oldest_modification() <= 1; } /** diff --git a/storage/innobase/include/srv0srv.h b/storage/innobase/include/srv0srv.h index 11270d9b7f9..a5bebc34c39 100644 --- a/storage/innobase/include/srv0srv.h +++ b/storage/innobase/include/srv0srv.h @@ -737,9 +737,6 @@ struct export_var_t{ ulint innodb_os_log_fsyncs; /*!< n_log_flushes */ ulint innodb_os_log_pending_writes; /*!< srv_os_log_pending_writes */ ulint innodb_os_log_pending_fsyncs; /*!< n_pending_log_flushes */ - ulint innodb_pages_created; /*!< buf_pool.stat.n_pages_created */ - ulint innodb_pages_read; /*!< buf_pool.stat.n_pages_read*/ - ulint innodb_pages_written; /*!< buf_pool.stat.n_pages_written */ ulint innodb_row_lock_waits; /*!< srv_n_lock_wait_count */ ulint innodb_row_lock_current_waits; /*!< srv_n_lock_wait_current_count */ int64_t innodb_row_lock_time; /*!< srv_n_lock_wait_time diff --git a/storage/innobase/srv/srv0srv.cc b/storage/innobase/srv/srv0srv.cc index 4898b9e4e44..02711e99c07 100644 --- a/storage/innobase/srv/srv0srv.cc +++ b/storage/innobase/srv/srv0srv.cc @@ -1137,12 +1137,6 @@ srv_export_innodb_status(void) export_vars.innodb_log_writes = srv_stats.log_writes; - export_vars.innodb_pages_created = buf_pool.stat.n_pages_created; - - export_vars.innodb_pages_read = buf_pool.stat.n_pages_read; - - export_vars.innodb_pages_written = buf_pool.stat.n_pages_written; - export_vars.innodb_row_lock_waits = srv_stats.n_lock_wait_count; export_vars.innodb_row_lock_current_waits = From 6441bc614a99f5cd6357c8a23b9f583c56d0a90c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 23 Jun 2021 13:13:16 +0300 Subject: [PATCH 173/251] MDEV-25113: Introduce a page cleaner mode before 'furious flush' MDEV-23855 changed the way how the page cleaner is signaled by user threads. If a threshold is exceeded, a mini-transaction commit would invoke buf_flush_ahead() in order to initiate page flushing before all writers would eventually grind to halt in log_free_check(), waiting for the checkpoint age to reduce. However, buf_flush_ahead() would always initiate 'furious flushing', making the buf_flush_page_cleaner thread write innodb_io_capacity_max pages per batch, and sleeping no time between batches, until the limit LSN is reached. Because this could saturate the I/O subsystem, system throughput could significantly reduce during these 'furious flushing' spikes. With this change, we introduce a gentler version of flush-ahead, which would write innodb_io_capacity_max pages per second until the 'soft limit' is reached. buf_flush_ahead(): Add a parameter to specify whether furious flushing is requested. buf_flush_async_lsn: Similar to buf_flush_sync_lsn, a limit for the less intrusive flushing. buf_flush_page_cleaner(): Keep working until buf_flush_async_lsn has been reached. log_close(): Suppress a warning message in the event that a new log is being created during startup, when old logs did not exist. Return what type of page cleaning will be needed. mtr_t::finish_write(): Also when m_log.is_small(), invoke log_close(). Return what type of page cleaning will be needed. mtr_t::commit(): Invoke buf_flush_ahead() based on the return value of mtr_t::finish_write(). --- storage/innobase/buf/buf0flu.cc | 45 ++++++++++++++++++--------- storage/innobase/include/buf0flu.h | 7 +++-- storage/innobase/include/mtr0mtr.h | 13 +++++++- storage/innobase/mtr/mtr0mtr.cc | 50 ++++++++++++++++-------------- 4 files changed, 73 insertions(+), 42 deletions(-) diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc index aa92ddfcec8..2e5d1f2332d 100644 --- a/storage/innobase/buf/buf0flu.cc +++ b/storage/innobase/buf/buf0flu.cc @@ -63,8 +63,11 @@ static constexpr ulint buf_flush_lsn_scan_factor = 3; /** Average redo generation rate */ static lsn_t lsn_avg_rate = 0; -/** Target oldest_modification for the page cleaner; writes are protected by -buf_pool.flush_list_mutex */ +/** Target oldest_modification for the page cleaner background flushing; +writes are protected by buf_pool.flush_list_mutex */ +static Atomic_relaxed buf_flush_async_lsn; +/** Target oldest_modification for the page cleaner furious flushing; +writes are protected by buf_pool.flush_list_mutex */ static Atomic_relaxed buf_flush_sync_lsn; #ifdef UNIV_PFS_THREAD @@ -1905,9 +1908,10 @@ try_checkpoint: } } -/** If innodb_flush_sync=ON, initiate a furious flush. -@param lsn buf_pool.get_oldest_modification(LSN_MAX) target */ -void buf_flush_ahead(lsn_t lsn) +/** Initiate more eager page flushing if the log checkpoint age is too old. +@param lsn buf_pool.get_oldest_modification(LSN_MAX) target +@param furious true=furious flushing, false=limit to innodb_io_capacity */ +ATTRIBUTE_COLD void buf_flush_ahead(lsn_t lsn, bool furious) { mysql_mutex_assert_not_owner(&log_sys.mutex); ut_ad(!srv_read_only_mode); @@ -1915,14 +1919,15 @@ void buf_flush_ahead(lsn_t lsn) if (recv_recovery_is_on()) recv_sys.apply(true); - if (buf_flush_sync_lsn < lsn) + Atomic_relaxed &limit= furious + ? buf_flush_sync_lsn : buf_flush_async_lsn; + + if (limit < lsn) { mysql_mutex_lock(&buf_pool.flush_list_mutex); - if (buf_flush_sync_lsn < lsn) - { - buf_flush_sync_lsn= lsn; - pthread_cond_signal(&buf_pool.do_flush_list); - } + if (limit < lsn) + limit= lsn; + pthread_cond_signal(&buf_pool.do_flush_list); mysql_mutex_unlock(&buf_pool.flush_list_mutex); } } @@ -1997,6 +2002,8 @@ ATTRIBUTE_COLD static void buf_flush_sync_for_checkpoint(lsn_t lsn) if (measure >= target) buf_flush_sync_lsn= 0; + else if (measure >= buf_flush_async_lsn) + buf_flush_async_lsn= 0; /* wake up buf_flush_wait_flushed() */ pthread_cond_broadcast(&buf_pool.done_flush_list); @@ -2016,7 +2023,7 @@ static bool af_needed_for_redo(lsn_t oldest_lsn) { lsn_t age= (log_sys.get_lsn() - oldest_lsn); lsn_t af_lwm= static_cast(srv_adaptive_flushing_lwm * - static_cast(log_sys.log_capacity) / 100); + static_cast(log_sys.log_capacity) / 100); /* if age > af_lwm adaptive flushing is recommended */ return (age > af_lwm); @@ -2240,6 +2247,7 @@ furious_flush: set_timespec(abstime, 1); + lsn_t soft_lsn_limit= buf_flush_async_lsn; lsn_limit= buf_flush_sync_lsn; if (UNIV_UNLIKELY(lsn_limit != 0)) @@ -2261,6 +2269,7 @@ furious_flush: pthread_cond_broadcast(&buf_pool.done_flush_list); } unemployed: + buf_flush_async_lsn= 0; buf_pool.page_cleaner_set_idle(true); continue; } @@ -2275,7 +2284,7 @@ unemployed: bool idle_flush= false; - if (lsn_limit); + if (lsn_limit || soft_lsn_limit); else if (af_needed_for_redo(oldest_lsn)); else if (srv_max_dirty_pages_pct_lwm != 0.0) { @@ -2300,11 +2309,16 @@ unemployed: goto unemployed; if (UNIV_UNLIKELY(lsn_limit != 0) && oldest_lsn >= lsn_limit) - buf_flush_sync_lsn= 0; + lsn_limit= buf_flush_sync_lsn= 0; + if (UNIV_UNLIKELY(soft_lsn_limit != 0) && oldest_lsn >= soft_lsn_limit) + soft_lsn_limit= buf_flush_async_lsn= 0; buf_pool.page_cleaner_set_idle(false); mysql_mutex_unlock(&buf_pool.flush_list_mutex); + if (!lsn_limit) + lsn_limit= soft_lsn_limit; + ulint n_flushed; if (UNIV_UNLIKELY(lsn_limit != 0)) @@ -2355,7 +2369,7 @@ do_checkpoint: goto do_checkpoint; } } - else + else if (buf_flush_async_lsn <= oldest_lsn) { mysql_mutex_lock(&buf_pool.flush_list_mutex); goto unemployed; @@ -2410,6 +2424,7 @@ ATTRIBUTE_COLD void buf_flush_page_cleaner_init() ut_ad(srv_operation == SRV_OPERATION_NORMAL || srv_operation == SRV_OPERATION_RESTORE || srv_operation == SRV_OPERATION_RESTORE_EXPORT); + buf_flush_async_lsn= 0; buf_flush_sync_lsn= 0; buf_page_cleaner_is_active= true; os_thread_create(buf_flush_page_cleaner); diff --git a/storage/innobase/include/buf0flu.h b/storage/innobase/include/buf0flu.h index 76a4ecff950..8d45cf2be38 100644 --- a/storage/innobase/include/buf0flu.h +++ b/storage/innobase/include/buf0flu.h @@ -111,9 +111,10 @@ void buf_flush_wait_batch_end(bool lru); /** Wait until all persistent pages are flushed up to a limit. @param sync_lsn buf_pool.get_oldest_modification(LSN_MAX) to wait for */ ATTRIBUTE_COLD void buf_flush_wait_flushed(lsn_t sync_lsn); -/** If innodb_flush_sync=ON, initiate a furious flush. -@param lsn buf_pool.get_oldest_modification(LSN_MAX) target */ -void buf_flush_ahead(lsn_t lsn); +/** Initiate more eager page flushing if the log checkpoint age is too old. +@param lsn buf_pool.get_oldest_modification(LSN_MAX) target +@param furious true=furious flushing, false=limit to innodb_io_capacity */ +ATTRIBUTE_COLD void buf_flush_ahead(lsn_t lsn, bool furious); /********************************************************************//** This function should be called at a mini-transaction commit, if a page was diff --git a/storage/innobase/include/mtr0mtr.h b/storage/innobase/include/mtr0mtr.h index 97bfa2e53cb..a9539000602 100644 --- a/storage/innobase/include/mtr0mtr.h +++ b/storage/innobase/include/mtr0mtr.h @@ -588,6 +588,17 @@ public: @return number of buffer count added by this mtr */ uint32_t get_fix_count(const buf_block_t *block) const; + /** type of page flushing is needed during commit() */ + enum page_flush_ahead + { + /** no need to trigger page cleaner */ + PAGE_FLUSH_NO= 0, + /** asynchronous flushing is needed */ + PAGE_FLUSH_ASYNC, + /** furious flushing is needed */ + PAGE_FLUSH_SYNC + }; + private: /** Log a write of a byte string to a page. @param block buffer page @@ -621,7 +632,7 @@ private: /** Append the redo log records to the redo log buffer. @param len number of bytes to write @return {start_lsn,flush_ahead} */ - inline std::pair finish_write(ulint len); + inline std::pair finish_write(ulint len); /** Release the resources */ inline void release_resources(); diff --git a/storage/innobase/mtr/mtr0mtr.cc b/storage/innobase/mtr/mtr0mtr.cc index f7bde06544f..f6747686eb5 100644 --- a/storage/innobase/mtr/mtr0mtr.cc +++ b/storage/innobase/mtr/mtr0mtr.cc @@ -402,12 +402,12 @@ void mtr_t::commit() { ut_ad(!srv_read_only_mode || m_log_mode == MTR_LOG_NO_REDO); - std::pair lsns; + std::pair lsns; if (const ulint len= prepare_write()) lsns= finish_write(len); else - lsns= { m_commit_lsn, false }; + lsns= { m_commit_lsn, PAGE_FLUSH_NO }; if (m_made_dirty) mysql_mutex_lock(&log_sys.flush_order_mutex); @@ -447,8 +447,8 @@ void mtr_t::commit() m_memo.for_each_block_in_reverse(CIterate()); - if (lsns.second) - buf_flush_ahead(m_commit_lsn); + if (UNIV_UNLIKELY(lsns.second != PAGE_FLUSH_NO)) + buf_flush_ahead(m_commit_lsn, lsns.second == PAGE_FLUSH_SYNC); if (m_made_dirty) srv_stats.log_write_requests.inc(); @@ -754,7 +754,7 @@ static void log_write_low(const void *str, size_t size) /** Close the log at mini-transaction commit. @return whether buffer pool flushing is needed */ -static bool log_close(lsn_t lsn) +static mtr_t::page_flush_ahead log_close(lsn_t lsn) { mysql_mutex_assert_owner(&log_sys.mutex); ut_ad(lsn == log_sys.get_lsn()); @@ -777,7 +777,9 @@ static bool log_close(lsn_t lsn) const lsn_t checkpoint_age= lsn - log_sys.last_checkpoint_lsn; - if (UNIV_UNLIKELY(checkpoint_age >= log_sys.log_capacity)) + if (UNIV_UNLIKELY(checkpoint_age >= log_sys.log_capacity) && + /* silence message on create_log_file() after the log had been deleted */ + checkpoint_age != lsn) { time_t t= time(nullptr); if (!log_close_warned || difftime(t, log_close_warn_time) > 15) @@ -786,15 +788,17 @@ static bool log_close(lsn_t lsn) log_close_warn_time= t; ib::error() << "The age of the last checkpoint is " << checkpoint_age - << ", which exceeds the log capacity " - << log_sys.log_capacity << "."; + << ", which exceeds the log capacity " + << log_sys.log_capacity << "."; } } + else if (UNIV_LIKELY(checkpoint_age <= log_sys.max_modified_age_async)) + return mtr_t::PAGE_FLUSH_NO; else if (UNIV_LIKELY(checkpoint_age <= log_sys.max_checkpoint_age)) - return false; + return mtr_t::PAGE_FLUSH_ASYNC; log_sys.set_check_flush_or_checkpoint(); - return true; + return mtr_t::PAGE_FLUSH_SYNC; } /** Write the block contents to the REDO log */ @@ -858,8 +862,8 @@ inline ulint mtr_t::prepare_write() /** Append the redo log records to the redo log buffer. @param len number of bytes to write -@return {start_lsn,flush_ahead_lsn} */ -inline std::pair mtr_t::finish_write(ulint len) +@return {start_lsn,flush_ahead} */ +inline std::pair mtr_t::finish_write(ulint len) { ut_ad(m_log_mode == MTR_LOG_ALL); mysql_mutex_assert_owner(&log_sys.mutex); @@ -875,19 +879,19 @@ inline std::pair mtr_t::finish_write(ulint len) m_commit_lsn = log_reserve_and_write_fast(front->begin(), len, &start_lsn); - if (m_commit_lsn) { - return std::make_pair(start_lsn, false); + if (!m_commit_lsn) { + goto piecewise; } + } else { +piecewise: + /* Open the database log for log_write_low */ + start_lsn = log_reserve_and_open(len); + mtr_write_log write_log; + m_log.for_each_block(write_log); + m_commit_lsn = log_sys.get_lsn(); } - - /* Open the database log for log_write_low */ - start_lsn = log_reserve_and_open(len); - - mtr_write_log write_log; - m_log.for_each_block(write_log); - m_commit_lsn = log_sys.get_lsn(); - bool flush = log_close(m_commit_lsn); - DBUG_EXECUTE_IF("ib_log_flush_ahead", flush=true;); + page_flush_ahead flush= log_close(m_commit_lsn); + DBUG_EXECUTE_IF("ib_log_flush_ahead", flush = PAGE_FLUSH_SYNC;); return std::make_pair(start_lsn, flush); } From 60ed4797112533a88b11ed450290a0fd48f0ecb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 24 Jun 2021 11:01:18 +0300 Subject: [PATCH 174/251] MDEV-26004 Excessive wait times in buf_LRU_get_free_block() buf_LRU_get_free_block(): Initially wait for a single block to be freed, signaled by buf_pool.done_free. Only if that fails and no LRU eviction flushing batch is already running, we initiate a flushing batch that should serve all threads that are currently waiting in buf_LRU_get_free_block(). Note: In an extreme case, this may introduce a performance regression at larger numbers of connections. We observed this in sysbench oltp_update_index with 512MiB buffer pool, 4GiB of data on fast NVMe, and 1000 concurrent connections, on a 20-thread CPU. The contention point appears to be buf_pool.mutex, and the improvement would turn into a regression somewhere beyond 32 concurrent connections. On slower storage, such regression was not observed; instead, the throughput was improving and maximum latency was reduced. The excessive waits were pointed out by Vladislav Vaintroub. --- storage/innobase/buf/buf0buf.cc | 2 ++ storage/innobase/buf/buf0flu.cc | 14 +++++++++----- storage/innobase/buf/buf0lru.cc | 26 ++++++++++++++++++-------- storage/innobase/include/buf0buf.h | 2 ++ 4 files changed, 31 insertions(+), 13 deletions(-) diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index b0997c43847..72dd2cdc4ab 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -1467,6 +1467,7 @@ bool buf_pool_t::create() pthread_cond_init(&done_flush_LRU, nullptr); pthread_cond_init(&done_flush_list, nullptr); pthread_cond_init(&do_flush_list, nullptr); + pthread_cond_init(&done_free, nullptr); try_LRU_scan= true; @@ -1532,6 +1533,7 @@ void buf_pool_t::close() pthread_cond_destroy(&done_flush_LRU); pthread_cond_destroy(&done_flush_list); pthread_cond_destroy(&do_flush_list); + pthread_cond_destroy(&done_free); ut_free(chunks); chunks= nullptr; diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc index 2e5d1f2332d..410172499c9 100644 --- a/storage/innobase/buf/buf0flu.cc +++ b/storage/innobase/buf/buf0flu.cc @@ -391,19 +391,20 @@ void buf_page_write_complete(const IORequest &request) if (bpage->state() == BUF_BLOCK_FILE_PAGE) rw_lock_sx_unlock_gen(&((buf_block_t*) bpage)->lock, BUF_IO_WRITE); - if (request.is_LRU()) - buf_LRU_free_page(bpage, true); - else - ut_ad(!temp); - if (request.is_LRU()) { + buf_LRU_free_page(bpage, true); + ut_ad(buf_pool.n_flush_LRU_); if (!--buf_pool.n_flush_LRU_) + { pthread_cond_broadcast(&buf_pool.done_flush_LRU); + pthread_cond_signal(&buf_pool.done_free); + } } else { + ut_ad(!temp); ut_ad(buf_pool.n_flush_list_); if (!--buf_pool.n_flush_list_) pthread_cond_broadcast(&buf_pool.done_flush_list); @@ -1717,7 +1718,10 @@ ulint buf_flush_LRU(ulint max_n) mysql_mutex_unlock(&buf_pool.mutex); if (!n_flushing) + { pthread_cond_broadcast(&buf_pool.done_flush_LRU); + pthread_cond_signal(&buf_pool.done_free); + } buf_dblwr.flush_buffered_writes(); diff --git a/storage/innobase/buf/buf0lru.cc b/storage/innobase/buf/buf0lru.cc index a776ae75949..cc80df34056 100644 --- a/storage/innobase/buf/buf0lru.cc +++ b/storage/innobase/buf/buf0lru.cc @@ -401,7 +401,7 @@ we put it to free list to be used. @param have_mutex whether buf_pool.mutex is already being held @return the free control block, in state BUF_BLOCK_MEMORY */ -buf_block_t* buf_LRU_get_free_block(bool have_mutex) +buf_block_t *buf_LRU_get_free_block(bool have_mutex) { ulint n_iterations = 0; ulint flush_failures = 0; @@ -413,6 +413,7 @@ buf_block_t* buf_LRU_get_free_block(bool have_mutex) mysql_mutex_lock(&buf_pool.mutex); got_mutex: buf_LRU_check_size_of_non_data_objects(); + buf_block_t* block; DBUG_EXECUTE_IF("ib_lru_force_no_free_page", if (!buf_lru_free_blocks_error_printed) { @@ -421,7 +422,8 @@ got_mutex: retry: /* If there is a block in the free list, take it */ - if (buf_block_t* block = buf_LRU_get_free_only()) { + if ((block = buf_LRU_get_free_only()) != nullptr) { +got_block: if (!have_mutex) { mysql_mutex_unlock(&buf_pool.mutex); } @@ -446,10 +448,19 @@ retry: buf_pool.try_LRU_scan = false; } + for (;;) { + if ((block = buf_LRU_get_free_only()) != nullptr) { + goto got_block; + } + if (!buf_pool.n_flush_LRU_) { + break; + } + my_cond_wait(&buf_pool.done_free, &buf_pool.mutex.m_mutex); + } + #ifndef DBUG_OFF not_found: #endif - buf_flush_wait_batch_end(true); mysql_mutex_unlock(&buf_pool.mutex); if (n_iterations > 20 && !buf_lru_free_blocks_error_printed @@ -477,13 +488,11 @@ not_found: } /* No free block was found: try to flush the LRU list. - This call will flush one page from the LRU and put it on the - free list. That means that the free block is up for grabs for - all user threads. + The freed blocks will be up for grabs for all threads. - TODO: A more elegant way would have been to return the freed + TODO: A more elegant way would have been to return one freed up block to the caller here but the code that deals with - removing the block from page_hash and LRU_list is fairly + removing the block from buf_pool.page_hash and buf_pool.LRU is fairly involved (particularly in case of ROW_FORMAT=COMPRESSED pages). We can do that in a separate patch sometime in future. */ @@ -1027,6 +1036,7 @@ buf_LRU_block_free_non_file_page( } else { UT_LIST_ADD_FIRST(buf_pool.free, &block->page); ut_d(block->page.in_free_list = true); + pthread_cond_signal(&buf_pool.done_free); } MEM_NOACCESS(block->frame, srv_page_size); diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h index 404c46aa9f3..5d4059f849a 100644 --- a/storage/innobase/include/buf0buf.h +++ b/storage/innobase/include/buf0buf.h @@ -2020,6 +2020,8 @@ public: UT_LIST_BASE_NODE_T(buf_page_t) free; /*!< base node of the free block list */ + /** signaled each time when the free list grows; protected by mutex */ + pthread_cond_t done_free; UT_LIST_BASE_NODE_T(buf_page_t) withdraw; /*!< base node of the withdraw From 033e29b6a1a693a8b1f03c37f50918ecf1b25ac4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 24 Jun 2021 15:00:34 +0300 Subject: [PATCH 175/251] MDEV-26007 Rollback unnecessarily initiates redo log write trx_t::commit_in_memory(): Do not initiate a redo log write if the transaction has no visible effect. If anything for this transaction had been made durable, crash recovery will roll back the transaction just fine even if the end of ROLLBACK is not durably written. Rollbacks of transactions that are associated with XA identifiers (possibly internally via the binlog) will always be persisted. The test rpl.rpl_gtid_crash covers this. --- .../suite/innodb/r/read_only_recover_committed.result | 3 ++- mysql-test/suite/innodb/r/read_only_recovery.result | 4 ++-- mysql-test/suite/innodb/t/read_only_recover_committed.test | 3 ++- mysql-test/suite/innodb/t/read_only_recovery.test | 6 ++---- mysql-test/suite/innodb_fts/r/crash_recovery.result | 6 ++++-- mysql-test/suite/innodb_fts/t/crash_recovery.test | 6 ++++-- storage/innobase/trx/trx0trx.cc | 2 +- 7 files changed, 17 insertions(+), 13 deletions(-) diff --git a/mysql-test/suite/innodb/r/read_only_recover_committed.result b/mysql-test/suite/innodb/r/read_only_recover_committed.result index e7895ce6d46..2d41ab2157d 100644 --- a/mysql-test/suite/innodb/r/read_only_recover_committed.result +++ b/mysql-test/suite/innodb/r/read_only_recover_committed.result @@ -19,7 +19,8 @@ SET DEBUG_SYNC='now WAIT_FOR committed'; SET GLOBAL innodb_flush_log_at_trx_commit=1; BEGIN; INSERT INTO t VALUES(-10000); -ROLLBACK; +DELETE FROM t WHERE a=-10000; +COMMIT; # restart: --innodb-force-recovery=3 disconnect con1; disconnect con2; diff --git a/mysql-test/suite/innodb/r/read_only_recovery.result b/mysql-test/suite/innodb/r/read_only_recovery.result index e83bf66432e..2db12863246 100644 --- a/mysql-test/suite/innodb/r/read_only_recovery.result +++ b/mysql-test/suite/innodb/r/read_only_recovery.result @@ -13,7 +13,8 @@ FLUSH TABLES; SET GLOBAL innodb_flush_log_at_trx_commit=1; BEGIN; INSERT INTO t VALUES(0); -ROLLBACK; +DELETE FROM t WHERE a=0; +COMMIT; # restart: --innodb-force-recovery=3 disconnect con1; SELECT * FROM t; @@ -40,4 +41,3 @@ SELECT * FROM t; a 3 DROP TABLE t; -FOUND 1 /Rolled back recovered transaction [^0]/ in mysqld.1.err diff --git a/mysql-test/suite/innodb/t/read_only_recover_committed.test b/mysql-test/suite/innodb/t/read_only_recover_committed.test index 9ad09bb9b3a..236d37897e2 100644 --- a/mysql-test/suite/innodb/t/read_only_recover_committed.test +++ b/mysql-test/suite/innodb/t/read_only_recover_committed.test @@ -45,7 +45,8 @@ SET DEBUG_SYNC='now WAIT_FOR committed'; SET GLOBAL innodb_flush_log_at_trx_commit=1; BEGIN; INSERT INTO t VALUES(-10000); -ROLLBACK; +DELETE FROM t WHERE a=-10000; +COMMIT; --let $restart_parameters= --innodb-force-recovery=3 --let $shutdown_timeout= 0 --source include/restart_mysqld.inc diff --git a/mysql-test/suite/innodb/t/read_only_recovery.test b/mysql-test/suite/innodb/t/read_only_recovery.test index 7da012efb74..30876c2fbcf 100644 --- a/mysql-test/suite/innodb/t/read_only_recovery.test +++ b/mysql-test/suite/innodb/t/read_only_recovery.test @@ -19,7 +19,8 @@ FLUSH TABLES; SET GLOBAL innodb_flush_log_at_trx_commit=1; BEGIN; INSERT INTO t VALUES(0); -ROLLBACK; +DELETE FROM t WHERE a=0; +COMMIT; --let $restart_parameters= --innodb-force-recovery=3 --let $shutdown_timeout= 0 --source include/restart_mysqld.inc @@ -41,6 +42,3 @@ SELECT * FROM t; --source include/restart_mysqld.inc SELECT * FROM t; DROP TABLE t; -let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err; ---let SEARCH_PATTERN= Rolled back recovered transaction [^0] ---source include/search_pattern_in_file.inc diff --git a/mysql-test/suite/innodb_fts/r/crash_recovery.result b/mysql-test/suite/innodb_fts/r/crash_recovery.result index 74287f509b7..e8305cbb2f1 100644 --- a/mysql-test/suite/innodb_fts/r/crash_recovery.result +++ b/mysql-test/suite/innodb_fts/r/crash_recovery.result @@ -68,9 +68,11 @@ connection default; # Make durable the AUTO_INCREMENT in the above incomplete transaction. connect flush_redo_log,localhost,root,,; SET GLOBAL innodb_flush_log_at_trx_commit=1; +SET SQL_MODE = NO_AUTO_VALUE_ON_ZERO; BEGIN; -DELETE FROM articles LIMIT 1; -ROLLBACK; +UPDATE articles SET id=0 WHERE id=1; +UPDATE articles SET id=1 WHERE id=0; +COMMIT; disconnect flush_redo_log; connection default; # restart diff --git a/mysql-test/suite/innodb_fts/t/crash_recovery.test b/mysql-test/suite/innodb_fts/t/crash_recovery.test index 229f5affe87..702aaefad83 100644 --- a/mysql-test/suite/innodb_fts/t/crash_recovery.test +++ b/mysql-test/suite/innodb_fts/t/crash_recovery.test @@ -143,9 +143,11 @@ connection default; --echo # Make durable the AUTO_INCREMENT in the above incomplete transaction. --connect (flush_redo_log,localhost,root,,) SET GLOBAL innodb_flush_log_at_trx_commit=1; +SET SQL_MODE = NO_AUTO_VALUE_ON_ZERO; BEGIN; -DELETE FROM articles LIMIT 1; -ROLLBACK; +UPDATE articles SET id=0 WHERE id=1; +UPDATE articles SET id=1 WHERE id=0; +COMMIT; --disconnect flush_redo_log --connection default diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc index 0f735faacfa..dc7a719d5b0 100644 --- a/storage/innobase/trx/trx0trx.cc +++ b/storage/innobase/trx/trx0trx.cc @@ -1347,7 +1347,7 @@ inline void trx_t::commit_in_memory(const mtr_t *mtr) serialize all commits and prevent a group of transactions from gathering. */ - commit_lsn= mtr->commit_lsn(); + commit_lsn= undo_no || !xid->is_null() ? mtr->commit_lsn() : 0; if (!commit_lsn) /* Nothing to be done. */; else if (flush_log_later) From 82fe83a34c26b88338f7dae638566f6f3a6e84ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 24 Jun 2021 16:07:27 +0300 Subject: [PATCH 176/251] MDEV-26012 InnoDB purge and shutdown hangs after failed ALTER TABLE ha_innobase::commit_inplace_alter_table(): Invoke purge_sys.resume_FTS() on all error handling paths if purge_sys.stop_FTS() had been called. This fixes a regression that had been introduced in commit 1bd681c8b3c5213ce1f7976940a7dc38b48a0d39 (MDEV-25506). --- storage/innobase/handler/handler0alter.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index b074c86b9d2..62f9d103aa1 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -10885,6 +10885,9 @@ ha_innobase::commit_inplace_alter_table( lock_fail: my_error_innodb( error, table_share->table_name.str, 0); + if (fts_exist) { + purge_sys.resume_FTS(); + } DBUG_RETURN(true); } else if ((ctx->new_table->flags2 & (DICT_TF2_FTS_HAS_DOC_ID | DICT_TF2_FTS)) @@ -10916,6 +10919,9 @@ lock_fail: DBUG_ASSERT(ctx->need_rebuild()); if (alter_rebuild_apply_log(ctx, ha_alter_info, altered_table)) { + if (fts_exist) { + purge_sys.resume_FTS(); + } DBUG_RETURN(true); } } From e329dc8d86b91258df8173568684ac40079e3a8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 24 Jun 2021 18:51:05 +0300 Subject: [PATCH 177/251] MDEV-25948 fixup: Demote a warning to a note buf_dblwr_t::recover(): Issue a note, not a warning, about pages whose FIL_PAGE_LSN is in the future. This was supposed to be part of commit 762bcb81b5bf9bbde61fed59afb26417f4ce1e86 (MDEV-25948) but had been accidentally omitted. --- storage/innobase/buf/buf0dblwr.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/innobase/buf/buf0dblwr.cc b/storage/innobase/buf/buf0dblwr.cc index a6885059a86..845aa749856 100644 --- a/storage/innobase/buf/buf0dblwr.cc +++ b/storage/innobase/buf/buf0dblwr.cc @@ -363,7 +363,7 @@ void buf_dblwr_t::recover() if (recv_sys.scanned_lsn < lsn) { - ib::warn() << "Ignoring a doublewrite copy of page " << page_id + ib::info() << "Ignoring a doublewrite copy of page " << page_id << " with future log sequence number " << lsn; continue; } From 5f22511e35674ecc376f4c56217ee2d78f92c772 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 24 Jun 2021 21:55:10 +0300 Subject: [PATCH 178/251] MDEV-26010: Assertion lsn > 2 failed in buf_pool_t::get_oldest_modification In commit 22b62edaedddb1cabd5b855cdd39a5e90a5695a2 (MDEV-25113) we introduced a race condition. buf_LRU_free_page() would read buf_page_t::oldest_modification() as 0 and assume that buf_page_t::list can be used (for attaching the block to the buf_pool.free list). In the observed race condition, buf_pool_t::delete_from_flush_list() had cleared the field, and buf_pool_t::delete_from_flush_list_low() was executing concurrently with buf_LRU_block_free_non_file_page(), which resulted in buf_pool.flush_list.end becoming corrupted. buf_pool_t::delete_from_flush_list(), buf_flush_relocate_on_flush_list(): First remove the block from buf_pool.flush_list, and only then invoke buf_page_t::clear_oldest_modification(), to ensure that reading oldest_modification()==0 really implies that the block no longer is in buf_pool.flush_list. --- storage/innobase/buf/buf0flu.cc | 8 ++++---- storage/innobase/include/buf0buf.h | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc index 410172499c9..a418049a6af 100644 --- a/storage/innobase/buf/buf0flu.cc +++ b/storage/innobase/buf/buf0flu.cc @@ -208,10 +208,10 @@ void buf_pool_t::insert_into_flush_list(buf_block_t *block, lsn_t lsn) @param clear whether to invoke buf_page_t::clear_oldest_modification() */ void buf_pool_t::delete_from_flush_list(buf_page_t *bpage, bool clear) { - if (clear) - bpage->clear_oldest_modification(); delete_from_flush_list_low(bpage); stat.flush_list_bytes-= bpage->physical_size(); + if (clear) + bpage->clear_oldest_modification(); #ifdef UNIV_DEBUG buf_flush_validate_skip(); #endif /* UNIV_DEBUG */ @@ -309,10 +309,10 @@ buf_flush_relocate_on_flush_list( the bpage from the flush list. */ buf_pool.flush_hp.adjust(bpage); - bpage->clear_oldest_modification(); - prev = UT_LIST_GET_PREV(list, bpage); UT_LIST_REMOVE(buf_pool.flush_list, bpage); + + bpage->clear_oldest_modification(); } else { /* bpage was removed from buf_pool.flush_list since we last checked, and before we acquired diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h index 5d4059f849a..1a44999bf25 100644 --- a/storage/innobase/include/buf0buf.h +++ b/storage/innobase/include/buf0buf.h @@ -944,7 +944,7 @@ public: lsn_t oldest_modification() const { return oldest_modification_; } /** Set oldest_modification when adding to buf_pool.flush_list */ inline void set_oldest_modification(lsn_t lsn); - /** Clear oldest_modification when removing from buf_pool.flush_list */ + /** Clear oldest_modification after removing from buf_pool.flush_list */ inline void clear_oldest_modification(); /** Note that a block is no longer dirty, while not removing it from buf_pool.flush_list */ @@ -2246,10 +2246,11 @@ inline void buf_page_t::set_oldest_modification(lsn_t lsn) { mysql_mutex_assert_owner(&buf_pool.flush_list_mutex); ut_ad(oldest_modification() <= 1); + ut_ad(lsn > 2); oldest_modification_= lsn; } -/** Clear oldest_modification when removing from buf_pool.flush_list */ +/** Clear oldest_modification after removing from buf_pool.flush_list */ inline void buf_page_t::clear_oldest_modification() { mysql_mutex_assert_owner(&buf_pool.flush_list_mutex); From 4ad148b148cfbb6f78b33ad9a7662f47c24cb759 Mon Sep 17 00:00:00 2001 From: Julius Goryavsky Date: Fri, 25 Jun 2021 06:48:17 +0200 Subject: [PATCH 179/251] MDEV-26019: Upgrading MariaDB breaks TLS mariabackup SST Fixed typo in variable name that breaks SST in some scenatios. Also fixed one small inaccuracy after MDEV-25978 which leads to the use of an uninitialized variable when the --log-bin option is specified without an argument. --- scripts/wsrep_sst_common.sh | 11 +++++------ scripts/wsrep_sst_mariabackup.sh | 2 +- scripts/wsrep_sst_xtrabackup-v2.sh | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/scripts/wsrep_sst_common.sh b/scripts/wsrep_sst_common.sh index bb9a3b9f1b6..562f9dc3aac 100644 --- a/scripts/wsrep_sst_common.sh +++ b/scripts/wsrep_sst_common.sh @@ -456,7 +456,7 @@ if [ -n "${MYSQLD_OPT_LOG_BASENAME:-}" -a \ fi # If the --log-bin option is present without a value, then -# setting WSREP_SST_OPT_BINLOG by using other arguments: +# set WSREP_SST_OPT_BINLOG value using other arguments: if [ -z "$WSREP_SST_OPT_BINLOG" -a -n "${MYSQLD_OPT_LOG_BIN+x}" ]; then if [ -n "$WSREP_SST_OPT_LOG_BASENAME" ]; then # If the WSREP_SST_OPT_BINLOG variable is not set, but @@ -465,9 +465,8 @@ if [ -z "$WSREP_SST_OPT_BINLOG" -a -n "${MYSQLD_OPT_LOG_BIN+x}" ]; then # the "-bin" suffix: readonly WSREP_SST_OPT_BINLOG="$WSREP_SST_OPT_LOG_BASENAME-bin" else - # the default name, note that base of this name - # is already defined above - readonly WSREP_SST_OPT_BINLOG_INDEX="$WSREP_SST_OPT_BINLOG.index" + # Take the default name: + readonly WSREP_SST_OPT_BINLOG='mysql-bin' fi fi @@ -550,8 +549,8 @@ get_binlog() # the "-bin" suffix: readonly WSREP_SST_OPT_BINLOG_INDEX="$WSREP_SST_OPT_LOG_BASENAME-bin.index" else - # the default name, note that base of this name - # is already defined above + # the default name (note that base of this name + # is already defined above): readonly WSREP_SST_OPT_BINLOG_INDEX="$WSREP_SST_OPT_BINLOG.index" fi fi diff --git a/scripts/wsrep_sst_mariabackup.sh b/scripts/wsrep_sst_mariabackup.sh index 339a8fcf4a5..46804c9dce4 100644 --- a/scripts/wsrep_sst_mariabackup.sh +++ b/scripts/wsrep_sst_mariabackup.sh @@ -386,7 +386,7 @@ get_transfer() elif is_local_ip "$WSREP_SST_OPT_HOST_UNESCAPED"; then CN_option=',commonname=localhost' else - CN_option=",commonname='$WSREP_SST_OPT_HOST_UNSECAPED'" + CN_option=",commonname='$WSREP_SST_OPT_HOST_UNESCAPED'" fi tcmd="$tcmd,cert='$tpem',key='$tkey',cafile='$tcert'$CN_option$sockopt" wsrep_log_info "$action with cert=$tpem, key=$tkey, cafile=$tcert" diff --git a/scripts/wsrep_sst_xtrabackup-v2.sh b/scripts/wsrep_sst_xtrabackup-v2.sh index d76dc346a82..9600848dc77 100644 --- a/scripts/wsrep_sst_xtrabackup-v2.sh +++ b/scripts/wsrep_sst_xtrabackup-v2.sh @@ -388,7 +388,7 @@ get_transfer() elif is_local_ip "$WSREP_SST_OPT_HOST_UNESCAPED"; then CN_option=',commonname=localhost' else - CN_option=",commonname='$WSREP_SST_OPT_HOST_UNSECAPED'" + CN_option=",commonname='$WSREP_SST_OPT_HOST_UNESCAPED'" fi tcmd="$tcmd,cert='$tpem',key='$tkey',cafile='$tcert'$CN_option$sockopt" wsrep_log_info "$action with cert=$tpem, key=$tkey, cafile=$tcert" From 05a4996c5c04d7ec4fe2ed2a5533685a688eccc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Tue, 22 Jun 2021 15:44:44 +0300 Subject: [PATCH 180/251] MDEV-25978 : rsync SST does not work with custom binlog name wsrep_sst_common did not correctly set name for binlog index file if custom binlog name was used and this name was not added to script command line. Added test case for both log_basename and log_binlog. --- .../r/galera_sst_rsync_binlogname.result | 96 +++++++++++++++++++ .../r/galera_sst_rsync_logbasename.result | 96 +++++++++++++++++++ .../galera/t/galera_sst_rsync_binlogname.cnf | 12 +++ .../galera/t/galera_sst_rsync_binlogname.test | 9 ++ .../galera/t/galera_sst_rsync_logbasename.cnf | 15 +++ .../t/galera_sst_rsync_logbasename.test | 9 ++ scripts/wsrep_sst_common.sh | 11 ++- sql/wsrep_sst.cc | 17 +++- 8 files changed, 259 insertions(+), 6 deletions(-) create mode 100644 mysql-test/suite/galera/r/galera_sst_rsync_binlogname.result create mode 100644 mysql-test/suite/galera/r/galera_sst_rsync_logbasename.result create mode 100644 mysql-test/suite/galera/t/galera_sst_rsync_binlogname.cnf create mode 100644 mysql-test/suite/galera/t/galera_sst_rsync_binlogname.test create mode 100644 mysql-test/suite/galera/t/galera_sst_rsync_logbasename.cnf create mode 100644 mysql-test/suite/galera/t/galera_sst_rsync_logbasename.test diff --git a/mysql-test/suite/galera/r/galera_sst_rsync_binlogname.result b/mysql-test/suite/galera/r/galera_sst_rsync_binlogname.result new file mode 100644 index 00000000000..0f0a673947c --- /dev/null +++ b/mysql-test/suite/galera/r/galera_sst_rsync_binlogname.result @@ -0,0 +1,96 @@ +connection node_1; +connection node_2; +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; diff --git a/mysql-test/suite/galera/r/galera_sst_rsync_logbasename.result b/mysql-test/suite/galera/r/galera_sst_rsync_logbasename.result new file mode 100644 index 00000000000..0f0a673947c --- /dev/null +++ b/mysql-test/suite/galera/r/galera_sst_rsync_logbasename.result @@ -0,0 +1,96 @@ +connection node_1; +connection node_2; +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; diff --git a/mysql-test/suite/galera/t/galera_sst_rsync_binlogname.cnf b/mysql-test/suite/galera/t/galera_sst_rsync_binlogname.cnf new file mode 100644 index 00000000000..b1e4278dceb --- /dev/null +++ b/mysql-test/suite/galera/t/galera_sst_rsync_binlogname.cnf @@ -0,0 +1,12 @@ +!include ../galera_2nodes.cnf + +[mysqld] +wsrep_sst_method=rsync + +[mysqld.1] +wsrep_provider_options='base_port=@mysqld.1.#galera_port;gcache.size=1;pc.ignore_sb=true' +log_bin=server1_binlog + +[mysqld.2] +wsrep_provider_options='base_port=@mysqld.2.#galera_port;gcache.size=1;pc.ignore_sb=true' +log_bin=server2_binlog diff --git a/mysql-test/suite/galera/t/galera_sst_rsync_binlogname.test b/mysql-test/suite/galera/t/galera_sst_rsync_binlogname.test new file mode 100644 index 00000000000..b4ad6c43a0b --- /dev/null +++ b/mysql-test/suite/galera/t/galera_sst_rsync_binlogname.test @@ -0,0 +1,9 @@ +--source include/galera_cluster.inc + +--let $node_1=node_1 +--let $node_2=node_2 +--source include/auto_increment_offset_save.inc + +--source suite/galera/include/galera_st_shutdown_slave.inc + +--source include/auto_increment_offset_restore.inc diff --git a/mysql-test/suite/galera/t/galera_sst_rsync_logbasename.cnf b/mysql-test/suite/galera/t/galera_sst_rsync_logbasename.cnf new file mode 100644 index 00000000000..4f25af7cd8b --- /dev/null +++ b/mysql-test/suite/galera/t/galera_sst_rsync_logbasename.cnf @@ -0,0 +1,15 @@ +!include ../galera_2nodes.cnf + +[mysqld] +wsrep_sst_method=rsync + +[mysqld.1] +wsrep_provider_options='base_port=@mysqld.1.#galera_port;gcache.size=1;pc.ignore_sb=true' +log_basename=server1 +log_bin + +[mysqld.2] +wsrep_provider_options='base_port=@mysqld.2.#galera_port;gcache.size=1;pc.ignore_sb=true' +log_basename=server2 +log_bin + diff --git a/mysql-test/suite/galera/t/galera_sst_rsync_logbasename.test b/mysql-test/suite/galera/t/galera_sst_rsync_logbasename.test new file mode 100644 index 00000000000..b4ad6c43a0b --- /dev/null +++ b/mysql-test/suite/galera/t/galera_sst_rsync_logbasename.test @@ -0,0 +1,9 @@ +--source include/galera_cluster.inc + +--let $node_1=node_1 +--let $node_2=node_2 +--source include/auto_increment_offset_save.inc + +--source suite/galera/include/galera_st_shutdown_slave.inc + +--source include/auto_increment_offset_restore.inc diff --git a/scripts/wsrep_sst_common.sh b/scripts/wsrep_sst_common.sh index 4dedecb439f..bb9a3b9f1b6 100644 --- a/scripts/wsrep_sst_common.sh +++ b/scripts/wsrep_sst_common.sh @@ -465,8 +465,9 @@ if [ -z "$WSREP_SST_OPT_BINLOG" -a -n "${MYSQLD_OPT_LOG_BIN+x}" ]; then # the "-bin" suffix: readonly WSREP_SST_OPT_BINLOG="$WSREP_SST_OPT_LOG_BASENAME-bin" else - # Take the default name: - readonly WSREP_SST_OPT_BINLOG='mysql-bin' + # the default name, note that base of this name + # is already defined above + readonly WSREP_SST_OPT_BINLOG_INDEX="$WSREP_SST_OPT_BINLOG.index" fi fi @@ -549,9 +550,9 @@ get_binlog() # the "-bin" suffix: readonly WSREP_SST_OPT_BINLOG_INDEX="$WSREP_SST_OPT_LOG_BASENAME-bin.index" else - # If the base name not specified, then we take - # the default name: - readonly WSREP_SST_OPT_BINLOG_INDEX='mysql-bin.index' + # the default name, note that base of this name + # is already defined above + readonly WSREP_SST_OPT_BINLOG_INDEX="$WSREP_SST_OPT_BINLOG.index" fi fi fi diff --git a/sql/wsrep_sst.cc b/sql/wsrep_sst.cc index b18315dd160..dbebe91ec5b 100644 --- a/sql/wsrep_sst.cc +++ b/sql/wsrep_sst.cc @@ -984,6 +984,8 @@ static ssize_t sst_prepare_other (const char* method, { WSREP_ERROR("sst_prepare_other(): generate_binlog_index_opt_val() failed %d", ret); + if (binlog_opt_val) my_free(binlog_opt_val); + return ret; } make_wsrep_defaults_file(); @@ -1001,6 +1003,7 @@ static ssize_t sst_prepare_other (const char* method, wsrep_defaults_file, (int)getpid(), binlog_opt_val, binlog_index_opt_val); + my_free(binlog_opt_val); my_free(binlog_index_opt_val); @@ -1658,6 +1661,7 @@ static int sst_donate_other (const char* method, } char* binlog_opt_val= NULL; + char* binlog_index_opt_val= NULL; int ret; if ((ret= generate_binlog_opt_val(&binlog_opt_val))) @@ -1666,6 +1670,14 @@ static int sst_donate_other (const char* method, return ret; } + if ((ret= generate_binlog_index_opt_val(&binlog_index_opt_val))) + { + WSREP_ERROR("sst_prepare_other(): generate_binlog_index_opt_val() failed %d", + ret); + if (binlog_opt_val) my_free(binlog_opt_val); + return ret; + } + make_wsrep_defaults_file(); ret= snprintf (cmd_str(), cmd_len, @@ -1679,14 +1691,17 @@ static int sst_donate_other (const char* method, WSREP_SST_OPT_GTID " '%s:%lld' " WSREP_SST_OPT_GTID_DOMAIN_ID " '%d'" "%s" + "%s" "%s", method, addr, mysqld_port, mysqld_unix_port, mysql_real_data_home, wsrep_defaults_file, uuid, (long long) seqno, wsrep_gtid_domain_id, - binlog_opt_val, + binlog_opt_val, binlog_index_opt_val, bypass ? " " WSREP_SST_OPT_BYPASS : ""); + my_free(binlog_opt_val); + my_free(binlog_index_opt_val); if (ret < 0 || size_t(ret) >= cmd_len) { From 29098083f7ac3b445ee59c3e765eb634ec70b947 Mon Sep 17 00:00:00 2001 From: Julius Goryavsky Date: Fri, 25 Jun 2021 06:48:17 +0200 Subject: [PATCH 181/251] MDEV-26019: Upgrading MariaDB breaks TLS mariabackup SST Fixed typo in variable name that breaks SST in some scenatios. Also fixed one small inaccuracy after MDEV-25978 which leads to the use of an uninitialized variable when the --log-bin option is specified without an argument. --- scripts/wsrep_sst_common.sh | 11 +++++------ scripts/wsrep_sst_mariabackup.sh | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/scripts/wsrep_sst_common.sh b/scripts/wsrep_sst_common.sh index bb9a3b9f1b6..562f9dc3aac 100644 --- a/scripts/wsrep_sst_common.sh +++ b/scripts/wsrep_sst_common.sh @@ -456,7 +456,7 @@ if [ -n "${MYSQLD_OPT_LOG_BASENAME:-}" -a \ fi # If the --log-bin option is present without a value, then -# setting WSREP_SST_OPT_BINLOG by using other arguments: +# set WSREP_SST_OPT_BINLOG value using other arguments: if [ -z "$WSREP_SST_OPT_BINLOG" -a -n "${MYSQLD_OPT_LOG_BIN+x}" ]; then if [ -n "$WSREP_SST_OPT_LOG_BASENAME" ]; then # If the WSREP_SST_OPT_BINLOG variable is not set, but @@ -465,9 +465,8 @@ if [ -z "$WSREP_SST_OPT_BINLOG" -a -n "${MYSQLD_OPT_LOG_BIN+x}" ]; then # the "-bin" suffix: readonly WSREP_SST_OPT_BINLOG="$WSREP_SST_OPT_LOG_BASENAME-bin" else - # the default name, note that base of this name - # is already defined above - readonly WSREP_SST_OPT_BINLOG_INDEX="$WSREP_SST_OPT_BINLOG.index" + # Take the default name: + readonly WSREP_SST_OPT_BINLOG='mysql-bin' fi fi @@ -550,8 +549,8 @@ get_binlog() # the "-bin" suffix: readonly WSREP_SST_OPT_BINLOG_INDEX="$WSREP_SST_OPT_LOG_BASENAME-bin.index" else - # the default name, note that base of this name - # is already defined above + # the default name (note that base of this name + # is already defined above): readonly WSREP_SST_OPT_BINLOG_INDEX="$WSREP_SST_OPT_BINLOG.index" fi fi diff --git a/scripts/wsrep_sst_mariabackup.sh b/scripts/wsrep_sst_mariabackup.sh index 339a8fcf4a5..46804c9dce4 100644 --- a/scripts/wsrep_sst_mariabackup.sh +++ b/scripts/wsrep_sst_mariabackup.sh @@ -386,7 +386,7 @@ get_transfer() elif is_local_ip "$WSREP_SST_OPT_HOST_UNESCAPED"; then CN_option=',commonname=localhost' else - CN_option=",commonname='$WSREP_SST_OPT_HOST_UNSECAPED'" + CN_option=",commonname='$WSREP_SST_OPT_HOST_UNESCAPED'" fi tcmd="$tcmd,cert='$tpem',key='$tkey',cafile='$tcert'$CN_option$sockopt" wsrep_log_info "$action with cert=$tpem, key=$tkey, cafile=$tcert" From 1c03e7a66741a840ea39939853a774d93d3d4704 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Tue, 22 Jun 2021 15:44:44 +0300 Subject: [PATCH 182/251] MDEV-25978 : rsync SST does not work with custom binlog name wsrep_sst_common did not correctly set name for binlog index file if custom binlog name was used and this name was not added to script command line. Added test case for both log_basename and log_binlog. --- .../r/galera_sst_rsync_binlogname.result | 96 +++++++++++++++++++ .../r/galera_sst_rsync_logbasename.result | 96 +++++++++++++++++++ .../galera/t/galera_sst_rsync_binlogname.cnf | 12 +++ .../galera/t/galera_sst_rsync_binlogname.test | 9 ++ .../galera/t/galera_sst_rsync_logbasename.cnf | 15 +++ .../t/galera_sst_rsync_logbasename.test | 9 ++ scripts/wsrep_sst_common.sh | 11 ++- sql/wsrep_sst.cc | 5 + 8 files changed, 248 insertions(+), 5 deletions(-) create mode 100644 mysql-test/suite/galera/r/galera_sst_rsync_binlogname.result create mode 100644 mysql-test/suite/galera/r/galera_sst_rsync_logbasename.result create mode 100644 mysql-test/suite/galera/t/galera_sst_rsync_binlogname.cnf create mode 100644 mysql-test/suite/galera/t/galera_sst_rsync_binlogname.test create mode 100644 mysql-test/suite/galera/t/galera_sst_rsync_logbasename.cnf create mode 100644 mysql-test/suite/galera/t/galera_sst_rsync_logbasename.test diff --git a/mysql-test/suite/galera/r/galera_sst_rsync_binlogname.result b/mysql-test/suite/galera/r/galera_sst_rsync_binlogname.result new file mode 100644 index 00000000000..0f0a673947c --- /dev/null +++ b/mysql-test/suite/galera/r/galera_sst_rsync_binlogname.result @@ -0,0 +1,96 @@ +connection node_1; +connection node_2; +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; diff --git a/mysql-test/suite/galera/r/galera_sst_rsync_logbasename.result b/mysql-test/suite/galera/r/galera_sst_rsync_logbasename.result new file mode 100644 index 00000000000..0f0a673947c --- /dev/null +++ b/mysql-test/suite/galera/r/galera_sst_rsync_logbasename.result @@ -0,0 +1,96 @@ +connection node_1; +connection node_2; +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; diff --git a/mysql-test/suite/galera/t/galera_sst_rsync_binlogname.cnf b/mysql-test/suite/galera/t/galera_sst_rsync_binlogname.cnf new file mode 100644 index 00000000000..b1e4278dceb --- /dev/null +++ b/mysql-test/suite/galera/t/galera_sst_rsync_binlogname.cnf @@ -0,0 +1,12 @@ +!include ../galera_2nodes.cnf + +[mysqld] +wsrep_sst_method=rsync + +[mysqld.1] +wsrep_provider_options='base_port=@mysqld.1.#galera_port;gcache.size=1;pc.ignore_sb=true' +log_bin=server1_binlog + +[mysqld.2] +wsrep_provider_options='base_port=@mysqld.2.#galera_port;gcache.size=1;pc.ignore_sb=true' +log_bin=server2_binlog diff --git a/mysql-test/suite/galera/t/galera_sst_rsync_binlogname.test b/mysql-test/suite/galera/t/galera_sst_rsync_binlogname.test new file mode 100644 index 00000000000..b4ad6c43a0b --- /dev/null +++ b/mysql-test/suite/galera/t/galera_sst_rsync_binlogname.test @@ -0,0 +1,9 @@ +--source include/galera_cluster.inc + +--let $node_1=node_1 +--let $node_2=node_2 +--source include/auto_increment_offset_save.inc + +--source suite/galera/include/galera_st_shutdown_slave.inc + +--source include/auto_increment_offset_restore.inc diff --git a/mysql-test/suite/galera/t/galera_sst_rsync_logbasename.cnf b/mysql-test/suite/galera/t/galera_sst_rsync_logbasename.cnf new file mode 100644 index 00000000000..4f25af7cd8b --- /dev/null +++ b/mysql-test/suite/galera/t/galera_sst_rsync_logbasename.cnf @@ -0,0 +1,15 @@ +!include ../galera_2nodes.cnf + +[mysqld] +wsrep_sst_method=rsync + +[mysqld.1] +wsrep_provider_options='base_port=@mysqld.1.#galera_port;gcache.size=1;pc.ignore_sb=true' +log_basename=server1 +log_bin + +[mysqld.2] +wsrep_provider_options='base_port=@mysqld.2.#galera_port;gcache.size=1;pc.ignore_sb=true' +log_basename=server2 +log_bin + diff --git a/mysql-test/suite/galera/t/galera_sst_rsync_logbasename.test b/mysql-test/suite/galera/t/galera_sst_rsync_logbasename.test new file mode 100644 index 00000000000..b4ad6c43a0b --- /dev/null +++ b/mysql-test/suite/galera/t/galera_sst_rsync_logbasename.test @@ -0,0 +1,9 @@ +--source include/galera_cluster.inc + +--let $node_1=node_1 +--let $node_2=node_2 +--source include/auto_increment_offset_save.inc + +--source suite/galera/include/galera_st_shutdown_slave.inc + +--source include/auto_increment_offset_restore.inc diff --git a/scripts/wsrep_sst_common.sh b/scripts/wsrep_sst_common.sh index 4dedecb439f..bb9a3b9f1b6 100644 --- a/scripts/wsrep_sst_common.sh +++ b/scripts/wsrep_sst_common.sh @@ -465,8 +465,9 @@ if [ -z "$WSREP_SST_OPT_BINLOG" -a -n "${MYSQLD_OPT_LOG_BIN+x}" ]; then # the "-bin" suffix: readonly WSREP_SST_OPT_BINLOG="$WSREP_SST_OPT_LOG_BASENAME-bin" else - # Take the default name: - readonly WSREP_SST_OPT_BINLOG='mysql-bin' + # the default name, note that base of this name + # is already defined above + readonly WSREP_SST_OPT_BINLOG_INDEX="$WSREP_SST_OPT_BINLOG.index" fi fi @@ -549,9 +550,9 @@ get_binlog() # the "-bin" suffix: readonly WSREP_SST_OPT_BINLOG_INDEX="$WSREP_SST_OPT_LOG_BASENAME-bin.index" else - # If the base name not specified, then we take - # the default name: - readonly WSREP_SST_OPT_BINLOG_INDEX='mysql-bin.index' + # the default name, note that base of this name + # is already defined above + readonly WSREP_SST_OPT_BINLOG_INDEX="$WSREP_SST_OPT_BINLOG.index" fi fi fi diff --git a/sql/wsrep_sst.cc b/sql/wsrep_sst.cc index 4943db9a87f..88bee67a2fc 100644 --- a/sql/wsrep_sst.cc +++ b/sql/wsrep_sst.cc @@ -1053,6 +1053,8 @@ static ssize_t sst_prepare_other (const char* method, { WSREP_ERROR("sst_prepare_other(): generate_binlog_index_opt_val() failed %d", ret); + if (binlog_opt_val) my_free(binlog_opt_val); + return ret; } make_wsrep_defaults_file(); @@ -1070,6 +1072,7 @@ static ssize_t sst_prepare_other (const char* method, wsrep_defaults_file, (int)getpid(), binlog_opt_val, binlog_index_opt_val); + my_free(binlog_opt_val); my_free(binlog_index_opt_val); @@ -1794,6 +1797,8 @@ static int sst_donate_other (const char* method, { WSREP_ERROR("sst_prepare_other(): generate_binlog_index_opt_val() failed %d", ret); + if (binlog_opt_val) my_free(binlog_opt_val); + return ret; } make_wsrep_defaults_file(); From 12c80df4825955253a1a442098dbceb2a3e59971 Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Fri, 25 Jun 2021 18:03:29 -0700 Subject: [PATCH 183/251] MDEV-20411 Procedure containing CTE incorrectly stored in mysql.proc If the first token of the body of a stored procedure was 'WITH' then the beginning of the body was determined incorrectly and that token was missing in the string representing the body of the SP in mysql.proc. As a resultnany call of such procedure failed as the string representing the body could not be parsed. The patch corrects the code of the functions get_tok_start() and get_cpp_tok_start() of the class Lex_input_stream to make them take into account look ahead tokens. The patch is needed only for 10.2 as this problem has neen resolved in 10.3+. --- mysql-test/r/cte_nonrecursive.result | 55 ++++++++++++++++++++++++++++ mysql-test/r/fulltext.result | 2 +- mysql-test/t/cte_nonrecursive.test | 29 +++++++++++++++ sql/sql_lex.h | 4 +- 4 files changed, 87 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/cte_nonrecursive.result b/mysql-test/r/cte_nonrecursive.result index 7c6c6e8dedd..c1d7fd0a615 100644 --- a/mysql-test/r/cte_nonrecursive.result +++ b/mysql-test/r/cte_nonrecursive.result @@ -1964,4 +1964,59 @@ call p1(); ERROR 42S22: Unknown column 'a' in 'field list' drop procedure p1; drop table t1,t2; +# +# MDEV-20411: SP containing only one SELECT with WITH clause +# +create procedure sp1 () +with cte as (select 1 as a) select * from cte; +call sp1(); +a +1 +call sp1(); +a +1 +create table t1 (a int); +insert into t1 values (3), (7), (1), (7), (1), (1), (3), (1), (5); +create procedure sp2 () +with cte as (select * from t1) select * from cte; +call sp2(); +a +3 +7 +1 +7 +1 +1 +3 +1 +5 +call sp2(); +a +3 +7 +1 +7 +1 +1 +3 +1 +5 +create procedure sp3 () +with cte as (select * from t1 group by a) select * from cte; +call sp3(); +a +1 +3 +5 +7 +call sp3(); +a +1 +3 +5 +7 +drop procedure sp1; +drop procedure sp2; +drop procedure sp3; +drop table t1; # End of 10.2 tests diff --git a/mysql-test/r/fulltext.result b/mysql-test/r/fulltext.result index 5118cc38fdf..709e91cca4d 100644 --- a/mysql-test/r/fulltext.result +++ b/mysql-test/r/fulltext.result @@ -49,7 +49,7 @@ a b Full-text indexes are called collections Only MyISAM tables support collections select * from t1 where MATCH(a,b) AGAINST ("indexes" IN BOOLEAN MODE WITH QUERY EXPANSION); -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'QUERY EXPANSION)' at line 1 +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WITH QUERY EXPANSION)' at line 1 explain select * from t1 where MATCH(a,b) AGAINST ("collections"); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 fulltext a a 0 1 Using where diff --git a/mysql-test/t/cte_nonrecursive.test b/mysql-test/t/cte_nonrecursive.test index f994781548f..cbe4f8b855d 100644 --- a/mysql-test/t/cte_nonrecursive.test +++ b/mysql-test/t/cte_nonrecursive.test @@ -1463,4 +1463,33 @@ drop procedure p1; drop table t1,t2; + +--echo # +--echo # MDEV-20411: SP containing only one SELECT with WITH clause +--echo # + +create procedure sp1 () +with cte as (select 1 as a) select * from cte; +call sp1(); +call sp1(); + +create table t1 (a int); +insert into t1 values (3), (7), (1), (7), (1), (1), (3), (1), (5); + +create procedure sp2 () +with cte as (select * from t1) select * from cte; +call sp2(); +call sp2(); + +create procedure sp3 () +with cte as (select * from t1 group by a) select * from cte; +call sp3(); +call sp3(); + +drop procedure sp1; +drop procedure sp2; +drop procedure sp3; + +drop table t1; + --echo # End of 10.2 tests diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 03c06b9ae0f..bdf52e8ef7b 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -2176,7 +2176,7 @@ public: /** Get the token start position, in the raw buffer. */ const char *get_tok_start() { - return m_tok_start; + return lookahead_token >= 0 ? m_tok_start_prev : m_tok_start; } void set_cpp_tok_start(const char *pos) @@ -2222,7 +2222,7 @@ public: /** Get the token start position, in the pre-processed buffer. */ const char *get_cpp_tok_start() { - return m_cpp_tok_start; + return lookahead_token >= 0 ? m_cpp_tok_start_prev : m_cpp_tok_start; } /** Get the token end position, in the pre-processed buffer. */ From 759deaa0a22182353617c9fbff81f9f5fed25683 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Sat, 26 Jun 2021 11:16:40 +0300 Subject: [PATCH 184/251] MDEV-26010 fixup: Use acquire/release memory order In commit 5f22511e35674ecc376f4c56217ee2d78f92c772 we depend on Total Store Ordering. For correct operation on ISAs that implement weaker memory ordering, we must explicitly use release/acquire stores and loads on buf_page_t::oldest_modification_ to prevent a race condition when buf_page_t::list does not happen to be on the same cache line. buf_page_t::clear_oldest_modification(): Assert that the block is not in buf_pool.flush_list, and use std::memory_order_release. buf_page_t::oldest_modification_acquire(): Read oldest_modification_ with std::memory_order_acquire. In this way, if the return value is 0, the caller may safely assume that it will not observe the buf_page_t as being in buf_pool.flush_list, even if it is not holding buf_pool.flush_list_mutex. buf_flush_relocate_on_flush_list(), buf_LRU_free_page(): Invoke buf_page_t::oldest_modification_acquire(). --- include/my_atomic_wrapper.h | 5 ++-- storage/innobase/buf/buf0buf.cc | 8 +++--- storage/innobase/buf/buf0flu.cc | 21 ++++++++++------ storage/innobase/buf/buf0lru.cc | 2 +- storage/innobase/include/buf0buf.h | 39 ++++++++++++++++++++++++------ 5 files changed, 52 insertions(+), 23 deletions(-) diff --git a/include/my_atomic_wrapper.h b/include/my_atomic_wrapper.h index d57559d360d..c5820b4f5b6 100644 --- a/include/my_atomic_wrapper.h +++ b/include/my_atomic_wrapper.h @@ -43,9 +43,10 @@ public: Type load(std::memory_order o= std::memory_order_relaxed) const { return m.load(o); } + void store(Type i, std::memory_order o= std::memory_order_relaxed) + { m.store(i, o); } operator Type() const { return m.load(); } - Type operator=(const Type val) - { m.store(val, std::memory_order_relaxed); return val; } + Type operator=(const Type i) { store(i); return i; } Type operator=(const Atomic_relaxed &rhs) { return *this= Type{rhs}; } Type fetch_add(const Type i, std::memory_order o= std::memory_order_relaxed) { return m.fetch_add(i, o); } diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index 72dd2cdc4ab..bbbb67a69df 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -1333,21 +1333,19 @@ inline const buf_block_t *buf_pool_t::chunk_t::not_freed() const /* Skip blocks that are not being used for file pages. */ break; case BUF_BLOCK_FILE_PAGE: + const lsn_t lsn= block->page.oldest_modification(); + if (srv_read_only_mode) { /* The page cleaner is disabled in read-only mode. No pages can be dirtied, so all of them must be clean. */ - ut_d(lsn_t oldest_modification= block->page.oldest_modification()); - ut_ad(oldest_modification == 0 || - oldest_modification == recv_sys.recovered_lsn || + ut_ad(lsn == 0 || lsn == recv_sys.recovered_lsn || srv_force_recovery == SRV_FORCE_NO_LOG_REDO); ut_ad(!block->page.buf_fix_count()); ut_ad(block->page.io_fix() == BUF_IO_NONE); break; } - const lsn_t lsn= block->page.oldest_modification(); - if (fsp_is_system_temporary(block->page.id().space())) { ut_ad(lsn == 0 || lsn == 2); diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc index a418049a6af..c80398e9967 100644 --- a/storage/innobase/buf/buf0flu.cc +++ b/storage/innobase/buf/buf0flu.cc @@ -289,7 +289,7 @@ buf_flush_relocate_on_flush_list( mysql_mutex_assert_owner(&buf_pool.mutex); ut_ad(!fsp_is_system_temporary(bpage->id().space())); - const lsn_t lsn = bpage->oldest_modification(); + const lsn_t lsn = bpage->oldest_modification_acquire(); if (!lsn) { return; @@ -317,13 +317,13 @@ buf_flush_relocate_on_flush_list( /* bpage was removed from buf_pool.flush_list since we last checked, and before we acquired buf_pool.flush_list_mutex. */ - dpage->list.prev = nullptr; - dpage->list.next = nullptr; goto was_clean; } if (lsn == 1) { was_clean: + dpage->list.prev = nullptr; + dpage->list.next = nullptr; dpage->clear_oldest_modification(); } else if (prev) { ut_ad(prev->oldest_modification()); @@ -802,14 +802,15 @@ inline void buf_pool_t::release_freed_page(buf_page_t *bpage) bpage->set_io_fix(BUF_IO_NONE); bpage->status= buf_page_t::NORMAL; mysql_mutex_lock(&flush_list_mutex); + ut_d(const lsn_t oldest_modification= bpage->oldest_modification();) if (fsp_is_system_temporary(bpage->id().space())) { ut_ad(uncompressed); - ut_ad(bpage->oldest_modification() == 2); + ut_ad(oldest_modification == 2); } else { - ut_ad(bpage->oldest_modification() > 2); + ut_ad(oldest_modification > 2); delete_from_flush_list(bpage, false); } bpage->clear_oldest_modification(); @@ -838,6 +839,7 @@ static bool buf_flush_page(buf_page_t *bpage, bool lru, fil_space_t *space) ut_ad(space->purpose == FIL_TYPE_TABLESPACE || space->atomic_write_supported); ut_ad(space->referenced()); + ut_ad(lru || space != fil_system.temp_space); rw_lock_t *rw_lock; @@ -881,7 +883,10 @@ static bool buf_flush_page(buf_page_t *bpage, bool lru, fil_space_t *space) lru ? "LRU" : "flush_list", bpage->id().space(), bpage->id().page_no())); ut_ad(bpage->io_fix() == BUF_IO_WRITE); - ut_ad(bpage->oldest_modification()); + ut_d(const lsn_t oldest_modification= bpage->oldest_modification()); + ut_ad(space == fil_system.temp_space + ? oldest_modification == 2 + : oldest_modification > 2); ut_ad(bpage->state() == (rw_lock ? BUF_BLOCK_FILE_PAGE : BUF_BLOCK_ZIP_PAGE)); ut_ad(ULINT_UNDEFINED > @@ -946,6 +951,7 @@ static bool buf_flush_page(buf_page_t *bpage, bool lru, fil_space_t *space) } ut_ad(status == bpage->status); + ut_ad(oldest_modification == bpage->oldest_modification()); if (status != buf_page_t::NORMAL || !space->use_doublewrite()) { @@ -954,8 +960,7 @@ static bool buf_flush_page(buf_page_t *bpage, bool lru, fil_space_t *space) const lsn_t lsn= mach_read_from_8(my_assume_aligned<8> (FIL_PAGE_LSN + (frame ? frame : block->frame))); - ut_ad(lsn); - ut_ad(lsn >= bpage->oldest_modification()); + ut_ad(lsn >= oldest_modification); if (lsn > log_sys.get_flushed_lsn()) log_write_up_to(lsn, true); } diff --git a/storage/innobase/buf/buf0lru.cc b/storage/innobase/buf/buf0lru.cc index cc80df34056..cb42d4e2ae3 100644 --- a/storage/innobase/buf/buf0lru.cc +++ b/storage/innobase/buf/buf0lru.cc @@ -810,7 +810,7 @@ bool buf_LRU_free_page(buf_page_t *bpage, bool zip) const ulint fold = id.fold(); page_hash_latch* hash_lock = buf_pool.page_hash.lock_get(fold); hash_lock->write_lock(); - lsn_t oldest_modification = bpage->oldest_modification(); + lsn_t oldest_modification = bpage->oldest_modification_acquire(); if (UNIV_UNLIKELY(!bpage->can_relocate())) { /* Do not free buffer fixed and I/O-fixed blocks. */ diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h index 1a44999bf25..e0e6c581442 100644 --- a/storage/innobase/include/buf0buf.h +++ b/storage/innobase/include/buf0buf.h @@ -771,7 +771,7 @@ private: 1 if no modifications are pending, but the block is in buf_pool.flush_list; 2 if modifications are pending, but the block is not in buf_pool.flush_list (because id().space() is the temporary tablespace). */ - Atomic_counter oldest_modification_; + Atomic_relaxed oldest_modification_; /** type of pending I/O operation; protected by buf_pool.mutex if in_LRU_list */ @@ -937,11 +937,18 @@ public: inline void set_corrupt_id(); /** @return the log sequence number of the oldest pending modification - @retval 0 if the block is not in buf_pool.flush_list + @retval 0 if the block is being removed from (or not in) buf_pool.flush_list @retval 1 if the block is in buf_pool.flush_list but not modified @retval 2 if the block belongs to the temporary tablespace and has unwritten changes */ lsn_t oldest_modification() const { return oldest_modification_; } + /** @return the log sequence number of the oldest pending modification, + @retval 0 if the block is definitely not in buf_pool.flush_list + @retval 1 if the block is in buf_pool.flush_list but not modified + @retval 2 if the block belongs to the temporary tablespace and + has unwritten changes */ + lsn_t oldest_modification_acquire() const + { return oldest_modification_.load(std::memory_order_acquire); } /** Set oldest_modification when adding to buf_pool.flush_list */ inline void set_oldest_modification(lsn_t lsn); /** Clear oldest_modification after removing from buf_pool.flush_list */ @@ -963,7 +970,8 @@ public: void free_file_page() { ut_ad(state() == BUF_BLOCK_REMOVE_HASH); - ut_d(oldest_modification_= 0); /* for buf_LRU_block_free_non_file_page() */ + /* buf_LRU_block_free_non_file_page() asserts !oldest_modification() */ + ut_d(oldest_modification_= 0;) set_corrupt_id(); ut_d(set_state(BUF_BLOCK_MEMORY)); } @@ -2221,7 +2229,8 @@ inline void buf_page_t::set_corrupt_id() break; case 2: ut_ad(fsp_is_system_temporary(id().space())); - ut_d(oldest_modification_= 0); /* for buf_LRU_block_free_non_file_page() */ + /* buf_LRU_block_free_non_file_page() asserts !oldest_modification() */ + ut_d(oldest_modification_= 0;) break; default: ut_ad("block is dirty" == 0); @@ -2258,7 +2267,12 @@ inline void buf_page_t::clear_oldest_modification() ut_ad(state == BUF_BLOCK_FILE_PAGE || state == BUF_BLOCK_ZIP_PAGE || state == BUF_BLOCK_REMOVE_HASH); ut_ad(oldest_modification()); - oldest_modification_= 0; + ut_ad(!list.prev); + ut_ad(!list.next); + /* We must use release memory order to guarantee that callers of + oldest_modification_acquire() will observe the block as + being detached from buf_pool.flush_list, after reading the value 0. */ + oldest_modification_.store(0, std::memory_order_release); } /** Note that a block is no longer dirty, while not removing @@ -2268,8 +2282,19 @@ inline void buf_page_t::clear_oldest_modification(bool temporary) mysql_mutex_assert_not_owner(&buf_pool.flush_list_mutex); ut_ad(temporary == fsp_is_system_temporary(id().space())); ut_ad(io_fix_ == BUF_IO_WRITE); - ut_ad(temporary ? oldest_modification() == 2 : oldest_modification() > 2); - oldest_modification_= !temporary; + if (temporary) + { + ut_ad(oldest_modification() == 2); + oldest_modification_= 0; + } + else + { + /* We use release memory order to guarantee that callers of + oldest_modification_acquire() will observe the block as + being detached from buf_pool.flush_list, after reading the value 0. */ + ut_ad(oldest_modification() > 2); + oldest_modification_.store(1, std::memory_order_release); + } } /** @return whether the block is modified and ready for flushing */ From aa95c4236093afdf1e8fcb55bda5987e2db033e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Sat, 26 Jun 2021 11:17:05 +0300 Subject: [PATCH 185/251] Cleanup: Remove unused mtr_block_dirtied --- storage/innobase/include/mtr0mtr.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/storage/innobase/include/mtr0mtr.h b/storage/innobase/include/mtr0mtr.h index a9539000602..f3db0008c3e 100644 --- a/storage/innobase/include/mtr0mtr.h +++ b/storage/innobase/include/mtr0mtr.h @@ -81,11 +81,6 @@ savepoint. */ #define mtr_block_x_latch_at_savepoint(m, s, b) \ (m)->x_latch_at_savepoint((s), (b)) -/** Check if a mini-transaction is dirtying a clean page. -@param b block being x-fixed -@return true if the mtr is dirtying a clean page. */ -#define mtr_block_dirtied(b) mtr_t::is_block_dirtied((b)) - /** Mini-transaction memo stack slot. */ struct mtr_memo_slot_t { /** pointer to the object */ From fc2ff464696f6d1d23aa722df011781ba2ddb440 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Sat, 26 Jun 2021 11:52:25 +0300 Subject: [PATCH 186/251] MDEV-26017: Assertion stat.flush_list_bytes <= curr_pool_size buf_flush_relocate_on_flush_list(): If we are removing the block from buf_pool.flush_list, subtract its size from buf_pool.stat.flush_list_bytes. This fixes a regression that was introduced in commit 22b62edaedddb1cabd5b855cdd39a5e90a5695a2 (MDEV-25113). --- storage/innobase/buf/buf0flu.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc index c80398e9967..e6999222447 100644 --- a/storage/innobase/buf/buf0flu.cc +++ b/storage/innobase/buf/buf0flu.cc @@ -321,6 +321,7 @@ buf_flush_relocate_on_flush_list( } if (lsn == 1) { + buf_pool.stat.flush_list_bytes -= bpage->physical_size(); was_clean: dpage->list.prev = nullptr; dpage->list.next = nullptr; From 8b3f816cab30eadd574b975d11c9e525a0b1691e Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Sat, 26 Jun 2021 08:51:17 -0700 Subject: [PATCH 187/251] Adjusted test results after the fix for MDEV-20411 --- mysql-test/suite/funcs_1/r/innodb_views.result | 8 ++++---- mysql-test/suite/funcs_1/r/memory_views.result | 8 ++++---- mysql-test/suite/funcs_1/r/storedproc.result | 11 +++++------ mysql-test/suite/innodb_fts/r/fulltext.result | 2 +- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/mysql-test/suite/funcs_1/r/innodb_views.result b/mysql-test/suite/funcs_1/r/innodb_views.result index 1316988ffc3..5e4b008326d 100644 --- a/mysql-test/suite/funcs_1/r/innodb_views.result +++ b/mysql-test/suite/funcs_1/r/innodb_views.result @@ -3551,11 +3551,11 @@ CREATE VIEW v1 or REPLACE AS Select * from tb2 my_table; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'or REPLACE AS Select * from tb2 my_table' at line 1 CREATE VIEW v1 WITH CASCADED CHECK OPTION AS Select * from tb2 my_table limit 50; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CASCADED CHECK OPTION AS Select * +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WITH CASCADED CHECK OPTION AS Select * from tb2 my_table limit 50' at line 1 CREATE VIEW v1 WITH LOCAL CHECK OPTION AS Select * from tb2 my_table limit 50; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'LOCAL CHECK OPTION AS Select * +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WITH LOCAL CHECK OPTION AS Select * from tb2 my_table limit 50' at line 1 SELECT * FROM tb2 my_table CREATE VIEW As v1; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CREATE VIEW As v1' at line 1 @@ -3585,7 +3585,7 @@ FROM test.tb2 my_table CHECK OPTION WITH CASCADED; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CHECK OPTION WITH CASCADED' at line 2 CREATE OR REPLACE VIEW v1 WITH CASCADED CHECK OPTION AS SELECT F59, F60 FROM test.tb2 my_table; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CASCADED CHECK OPTION +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WITH CASCADED CHECK OPTION AS SELECT F59, F60 FROM test.tb2 my_table' at line 1 CREATE OR REPLACE AS SELECT F59, F60 FROM test.tb2 my_table VIEW v1 WITH CASCADED CHECK OPTION; @@ -3614,7 +3614,7 @@ FROM test.tb2 my_table CHECK OPTION WITH LOCAL; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CHECK OPTION WITH LOCAL' at line 2 CREATE OR REPLACE VIEW v1 WITH CASCADED CHECK OPTION AS SELECT F59, F60 FROM test.tb2 my_table; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CASCADED CHECK OPTION +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WITH CASCADED CHECK OPTION AS SELECT F59, F60 FROM test.tb2 my_table' at line 1 CREATE OR REPLACE AS SELECT F59, F60 FROM test.tb2 my_table VIEW v1 WITH LOCAL CHECK OPTION; diff --git a/mysql-test/suite/funcs_1/r/memory_views.result b/mysql-test/suite/funcs_1/r/memory_views.result index 9f3fbd7bb1a..acd042511a0 100644 --- a/mysql-test/suite/funcs_1/r/memory_views.result +++ b/mysql-test/suite/funcs_1/r/memory_views.result @@ -3552,11 +3552,11 @@ CREATE VIEW v1 or REPLACE AS Select * from tb2 my_table; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'or REPLACE AS Select * from tb2 my_table' at line 1 CREATE VIEW v1 WITH CASCADED CHECK OPTION AS Select * from tb2 my_table limit 50; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CASCADED CHECK OPTION AS Select * +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WITH CASCADED CHECK OPTION AS Select * from tb2 my_table limit 50' at line 1 CREATE VIEW v1 WITH LOCAL CHECK OPTION AS Select * from tb2 my_table limit 50; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'LOCAL CHECK OPTION AS Select * +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WITH LOCAL CHECK OPTION AS Select * from tb2 my_table limit 50' at line 1 SELECT * FROM tb2 my_table CREATE VIEW As v1; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CREATE VIEW As v1' at line 1 @@ -3586,7 +3586,7 @@ FROM test.tb2 my_table CHECK OPTION WITH CASCADED; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CHECK OPTION WITH CASCADED' at line 2 CREATE OR REPLACE VIEW v1 WITH CASCADED CHECK OPTION AS SELECT F59, F60 FROM test.tb2 my_table; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CASCADED CHECK OPTION +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WITH CASCADED CHECK OPTION AS SELECT F59, F60 FROM test.tb2 my_table' at line 1 CREATE OR REPLACE AS SELECT F59, F60 FROM test.tb2 my_table VIEW v1 WITH CASCADED CHECK OPTION; @@ -3615,7 +3615,7 @@ FROM test.tb2 my_table CHECK OPTION WITH LOCAL; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CHECK OPTION WITH LOCAL' at line 2 CREATE OR REPLACE VIEW v1 WITH CASCADED CHECK OPTION AS SELECT F59, F60 FROM test.tb2 my_table; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CASCADED CHECK OPTION +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WITH CASCADED CHECK OPTION AS SELECT F59, F60 FROM test.tb2 my_table' at line 1 CREATE OR REPLACE AS SELECT F59, F60 FROM test.tb2 my_table VIEW v1 WITH LOCAL CHECK OPTION; diff --git a/mysql-test/suite/funcs_1/r/storedproc.result b/mysql-test/suite/funcs_1/r/storedproc.result index 516ea983563..64573ed2bd1 100644 --- a/mysql-test/suite/funcs_1/r/storedproc.result +++ b/mysql-test/suite/funcs_1/r/storedproc.result @@ -2807,7 +2807,7 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp SELECT * from t1 where f2=f1' at line 1 CREATE PROCEDURE with() SELECT * from t1 where f2=f1; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '() +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'with() SELECT * from t1 where f2=f1' at line 1 CREATE PROCEDURE write() SELECT * from t1 where f2=f1; @@ -9219,7 +9219,7 @@ CREATE PROCEDURE sp1() BEGIN declare with char; END// -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'char; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'with char; END' at line 3 DROP PROCEDURE IF EXISTS sp1; Warnings: @@ -11547,9 +11547,8 @@ BEGIN declare with condition for sqlstate '02000'; declare exit handler for with set @var2 = 1; END// -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'condition for sqlstate '02000'; -declare exit handler for with set @var2 = 1; -END' at line 3 +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'with condition for sqlstate '02000'; +declare exit handler for with set @var2 ...' at line 3 DROP PROCEDURE IF EXISTS sp1; Warnings: Note 1305 PROCEDURE db_storedproc.sp1 does not exist @@ -13649,7 +13648,7 @@ CREATE PROCEDURE sp1( ) BEGIN declare with handler for sqlstate '02000' set @var2 = 1; END// -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'handler for sqlstate '02000' set @var2 = 1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'with handler for sqlstate '02000' set @var2 = 1; END' at line 3 DROP PROCEDURE IF EXISTS sp1; Warnings: diff --git a/mysql-test/suite/innodb_fts/r/fulltext.result b/mysql-test/suite/innodb_fts/r/fulltext.result index 90deb48a223..1e5a83fd44c 100644 --- a/mysql-test/suite/innodb_fts/r/fulltext.result +++ b/mysql-test/suite/innodb_fts/r/fulltext.result @@ -56,7 +56,7 @@ Only MyISAM tables support collections MySQL has now support for full-text search Full-text search in MySQL implements vector space model select * from t1 where MATCH(a,b) AGAINST ("indexes" IN BOOLEAN MODE WITH QUERY EXPANSION); -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'QUERY EXPANSION)' at line 1 +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WITH QUERY EXPANSION)' at line 1 explain select * from t1 where MATCH(a,b) AGAINST ("collections"); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 fulltext a a 0 1 Using where From 4e4f742ed7987ee52a34618d2ea3731e5e198ed8 Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Sat, 26 Jun 2021 23:11:10 -0700 Subject: [PATCH 188/251] Adjusted test results after the fix for MDEV-20411 (2) --- mysql-test/suite/funcs_1/r/myisam_views-big.result | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mysql-test/suite/funcs_1/r/myisam_views-big.result b/mysql-test/suite/funcs_1/r/myisam_views-big.result index a1d59e1c2f9..d3227d83b01 100644 --- a/mysql-test/suite/funcs_1/r/myisam_views-big.result +++ b/mysql-test/suite/funcs_1/r/myisam_views-big.result @@ -4054,11 +4054,11 @@ CREATE VIEW v1 or REPLACE AS Select * from tb2 my_table; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'or REPLACE AS Select * from tb2 my_table' at line 1 CREATE VIEW v1 WITH CASCADED CHECK OPTION AS Select * from tb2 my_table limit 50; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CASCADED CHECK OPTION AS Select * +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WITH CASCADED CHECK OPTION AS Select * from tb2 my_table limit 50' at line 1 CREATE VIEW v1 WITH LOCAL CHECK OPTION AS Select * from tb2 my_table limit 50; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'LOCAL CHECK OPTION AS Select * +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WITH LOCAL CHECK OPTION AS Select * from tb2 my_table limit 50' at line 1 SELECT * FROM tb2 my_table CREATE VIEW As v1; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CREATE VIEW As v1' at line 1 @@ -4088,7 +4088,7 @@ FROM test.tb2 my_table CHECK OPTION WITH CASCADED; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CHECK OPTION WITH CASCADED' at line 2 CREATE OR REPLACE VIEW v1 WITH CASCADED CHECK OPTION AS SELECT F59, F60 FROM test.tb2 my_table; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CASCADED CHECK OPTION +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WITH CASCADED CHECK OPTION AS SELECT F59, F60 FROM test.tb2 my_table' at line 1 CREATE OR REPLACE AS SELECT F59, F60 FROM test.tb2 my_table VIEW v1 WITH CASCADED CHECK OPTION; @@ -4117,7 +4117,7 @@ FROM test.tb2 my_table CHECK OPTION WITH LOCAL; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CHECK OPTION WITH LOCAL' at line 2 CREATE OR REPLACE VIEW v1 WITH CASCADED CHECK OPTION AS SELECT F59, F60 FROM test.tb2 my_table; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'CASCADED CHECK OPTION +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WITH CASCADED CHECK OPTION AS SELECT F59, F60 FROM test.tb2 my_table' at line 1 CREATE OR REPLACE AS SELECT F59, F60 FROM test.tb2 my_table VIEW v1 WITH LOCAL CHECK OPTION; From 98c7916f0f29fb20cf2b8c8fa498f6033a07a89c Mon Sep 17 00:00:00 2001 From: Alexey Botchkov Date: Thu, 24 Jun 2021 13:28:28 +0400 Subject: [PATCH 189/251] MDEV-23004 When using GROUP BY with JSON_ARRAYAGG with joint table, the square brackets are not included. Item_func_json_arrayagg::copy_or_same() should be implemented. --- mysql-test/main/func_json.result | 16 ++++++++++++++++ mysql-test/main/func_json.test | 17 +++++++++++++++++ sql/item_jsonfunc.cc | 6 ++++++ sql/item_jsonfunc.h | 8 +++++--- 4 files changed, 44 insertions(+), 3 deletions(-) diff --git a/mysql-test/main/func_json.result b/mysql-test/main/func_json.result index 14ab6f41bce..0c242a886b7 100644 --- a/mysql-test/main/func_json.result +++ b/mysql-test/main/func_json.result @@ -1366,5 +1366,21 @@ JSON_OBJECTAGG(a, e) DROP VIEW v; DROP TABLE t1; # +# MDEV-23004 When using GROUP BY with JSON_ARRAYAGG with joint table, the square brackets are not included. +# +CREATE TABLE t1(id int primary key, name varchar(50)); +CREATE TABLE t2(id int, owner_id int); +INSERT INTO t1 VALUES (1, "name1"), (2, "name2"), (3, "name3"); +INSERT INTO t2 VALUES (1, 1), (2, 1), (3, 2), (4, 3); +SELECT t1.id, JSON_ARRAYAGG(JSON_OBJECT('id',t2.id)) as materials +from t1 LEFT JOIN t2 on t1.id = t2.owner_id +GROUP BY t1.id ORDER BY id; +id materials +1 ["{\"id\": 1}","{\"id\": 2}"] +2 ["{\"id\": 3}"] +3 ["{\"id\": 4}"] +DROP TABLE t1; +DROP TABLE t2; +# # End of 10.5 tests # diff --git a/mysql-test/main/func_json.test b/mysql-test/main/func_json.test index a77f7d8bd5b..f08a72a5bce 100644 --- a/mysql-test/main/func_json.test +++ b/mysql-test/main/func_json.test @@ -856,6 +856,23 @@ SELECT * FROM v; DROP VIEW v; DROP TABLE t1; +--echo # +--echo # MDEV-23004 When using GROUP BY with JSON_ARRAYAGG with joint table, the square brackets are not included. +--echo # + +CREATE TABLE t1(id int primary key, name varchar(50)); +CREATE TABLE t2(id int, owner_id int); + +INSERT INTO t1 VALUES (1, "name1"), (2, "name2"), (3, "name3"); +INSERT INTO t2 VALUES (1, 1), (2, 1), (3, 2), (4, 3); + +SELECT t1.id, JSON_ARRAYAGG(JSON_OBJECT('id',t2.id)) as materials + from t1 LEFT JOIN t2 on t1.id = t2.owner_id + GROUP BY t1.id ORDER BY id; + +DROP TABLE t1; +DROP TABLE t2; + --echo # --echo # End of 10.5 tests --echo # diff --git a/sql/item_jsonfunc.cc b/sql/item_jsonfunc.cc index 220a3e8de92..cf00da79de9 100644 --- a/sql/item_jsonfunc.cc +++ b/sql/item_jsonfunc.cc @@ -3743,6 +3743,12 @@ void Item_func_json_arrayagg::cut_max_length(String *result, } +Item *Item_func_json_arrayagg::copy_or_same(THD* thd) +{ + return new (thd->mem_root) Item_func_json_arrayagg(thd, this); +} + + String* Item_func_json_arrayagg::val_str(String *str) { if ((str= Item_func_group_concat::val_str(str))) diff --git a/sql/item_jsonfunc.h b/sql/item_jsonfunc.h index ec6c6696001..64ee47f740a 100644 --- a/sql/item_jsonfunc.h +++ b/sql/item_jsonfunc.h @@ -560,15 +560,17 @@ public: is_separator, limit_clause, row_limit, offset_limit) { } - Item_func_json_arrayagg(THD *thd, Item_func_json_arrayagg *item); + Item_func_json_arrayagg(THD *thd, Item_func_json_arrayagg *item) : + Item_func_group_concat(thd, item) {} bool is_json_type() { return true; } const char *func_name() const { return "json_arrayagg("; } enum Sumfunctype sum_func() const {return JSON_ARRAYAGG_FUNC;} - String* val_str(String *str); + String* val_str(String *str) override; - Item *get_copy(THD *thd) + Item *copy_or_same(THD* thd) override; + Item *get_copy(THD *thd) override { return get_item_copy(thd, this); } }; From 8147d2e6183a1a4a4f3db2884966f5da2d17678c Mon Sep 17 00:00:00 2001 From: Alexey Botchkov Date: Mon, 28 Jun 2021 11:52:00 +0400 Subject: [PATCH 190/251] MDEV-25461 Assertion `je->state == JST_KEY' failed in Geometry::create_from_json. Handle invalid GEOJSON-s in Geometry::create_from_json(). --- mysql-test/r/gis-json.result | 10 ++++++++++ mysql-test/t/gis-json.test | 7 +++++++ sql/spatial.cc | 6 ++++++ 3 files changed, 23 insertions(+) diff --git a/mysql-test/r/gis-json.result b/mysql-test/r/gis-json.result index e52a7c809c6..ace9e9e9ae2 100644 --- a/mysql-test/r/gis-json.result +++ b/mysql-test/r/gis-json.result @@ -107,6 +107,16 @@ Warning 4076 Incorrect GeoJSON format - empty 'coordinates' array. SELECT ST_GEOMFROMGEOJSON("{ \"type\": \"Feature\", \"geometry\": [10, 20] }"); ST_GEOMFROMGEOJSON("{ \"type\": \"Feature\", \"geometry\": [10, 20] }") NULL +SELECT ST_ASTEXT (ST_GEOMFROMGEOJSON ('{ "type": "GEOMETRYCOLLECTION", "coordinates": [102.0, 0.0]}')); +ST_ASTEXT (ST_GEOMFROMGEOJSON ('{ "type": "GEOMETRYCOLLECTION", "coordinates": [102.0, 0.0]}')) +NULL +Warnings: +Warning 4048 Incorrect GeoJSON format specified for st_geomfromgeojson function. +SELECT ST_ASTEXT(ST_GEOMFROMGEOJSON('{"type": ["POINT"], "coINates": [0,0] }')); +ST_ASTEXT(ST_GEOMFROMGEOJSON('{"type": ["POINT"], "coINates": [0,0] }')) +NULL +Warnings: +Warning 4048 Incorrect GeoJSON format specified for st_geomfromgeojson function. # # End of 10.2 tests # diff --git a/mysql-test/t/gis-json.test b/mysql-test/t/gis-json.test index a97e9411e5c..ff6298c50a6 100644 --- a/mysql-test/t/gis-json.test +++ b/mysql-test/t/gis-json.test @@ -46,6 +46,13 @@ SELECT st_astext(st_geomfromgeojson('{"type": "MultiPolygon","coordinates": []}' SELECT ST_GEOMFROMGEOJSON("{ \"type\": \"Feature\", \"geometry\": [10, 20] }"); +# +# MDEV-25461 Assertion `je->state == JST_KEY' failed in Geometry::create_from_json. +# + +SELECT ST_ASTEXT (ST_GEOMFROMGEOJSON ('{ "type": "GEOMETRYCOLLECTION", "coordinates": [102.0, 0.0]}')); + +SELECT ST_ASTEXT(ST_GEOMFROMGEOJSON('{"type": ["POINT"], "coINates": [0,0] }')); --echo # --echo # End of 10.2 tests --echo # diff --git a/sql/spatial.cc b/sql/spatial.cc index 7bb3ecff948..8bd9acef18f 100644 --- a/sql/spatial.cc +++ b/sql/spatial.cc @@ -539,7 +539,11 @@ Geometry *Geometry::create_from_json(Geometry_buffer *buffer, goto handle_geometry_key; feature_type_found= 1; } + else /* can't understand the type. */ + break; } + else /* The "type" value can only be string. */ + break; } else if (key_len == coord_keyname_len && memcmp(key_buf, coord_keyname, coord_keyname_len) == 0) @@ -556,6 +560,8 @@ Geometry *Geometry::create_from_json(Geometry_buffer *buffer, coord_start= je->value_begin; if (ci && ci != &geometrycollection_class) goto create_geom; + if (json_skip_level(je)) + goto err_return; } } else if (key_len == geometries_keyname_len && From 63e9a05440953bf451ebe1cd808ca445e4c7634e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 28 Jun 2021 15:37:29 +0300 Subject: [PATCH 191/251] MDEV-25942: Assertion !table.n_waiting_or_granted_auto_inc_locks trx_t::drop_table(): Remove a bogus debug assertion. The current transaction may hold an AUTO_INCREMENT lock on the table while CREATE TABLE t2 (pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=InnoDB SELECT... is being rolled back due to lock wait timeout. Remaining debug assertions will check that only this transaction is holding locks on the table, and that one of them is an exclusive lock. --- storage/innobase/dict/drop.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/storage/innobase/dict/drop.cc b/storage/innobase/dict/drop.cc index 7f936aaf051..ff8e108b26d 100644 --- a/storage/innobase/dict/drop.cc +++ b/storage/innobase/dict/drop.cc @@ -151,7 +151,6 @@ dberr_t trx_t::drop_table(const dict_table_t &table) ut_ad(!(table.stats_bg_flag & BG_STAT_IN_PROGRESS)); /* The table must be exclusively locked by this transaction. */ ut_ad(table.get_ref_count() <= 1); - ut_ad(!table.n_waiting_or_granted_auto_inc_locks); ut_ad(table.n_lock_x_or_s == 1); ut_ad(UT_LIST_GET_LEN(table.locks) >= 1); #ifdef UNIV_DEBUG From c29f45ce77c0eb89e5169c5c2b0f05e2a6198132 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicen=C8=9Biu=20Ciorbaru?= Date: Tue, 29 Jun 2021 00:12:03 +0300 Subject: [PATCH 192/251] MDEV-25481 Memory leak in Cached_item_str::Cached_item_str WITH TIES involving a blob Make sure to call cached item's destructors. --- mysql-test/main/fetch_first.result | 10 ++++++++++ mysql-test/main/fetch_first.test | 10 ++++++++++ sql/sql_select.cc | 1 + 3 files changed, 21 insertions(+) diff --git a/mysql-test/main/fetch_first.result b/mysql-test/main/fetch_first.result index 7bb89633081..69a0336d722 100644 --- a/mysql-test/main/fetch_first.result +++ b/mysql-test/main/fetch_first.result @@ -1368,3 +1368,13 @@ f 1 1 drop table t1; +# +# MDEV-25481: Memory leak upon query WITH TIES involving a blob +# +CREATE TABLE t (a TEXT); +INSERT INTO t VALUES ('foo'),('bar'); +SELECT a FROM t ORDER BY a FETCH FIRST 2 ROWS WITH TIES; +a +bar +foo +DROP TABLE t; diff --git a/mysql-test/main/fetch_first.test b/mysql-test/main/fetch_first.test index 3fdd6c56968..8a5cb2c8e73 100644 --- a/mysql-test/main/fetch_first.test +++ b/mysql-test/main/fetch_first.test @@ -1046,3 +1046,13 @@ SELECT SQL_BUFFER_RESULT 1 AS f FROM t1 ORDER BY f FETCH NEXT 2 ROW WITH TIES; SELECT 1 AS f FROM t1 ORDER BY f FETCH NEXT 2 ROW WITH TIES; drop table t1; + +--echo # +--echo # MDEV-25481: Memory leak upon query WITH TIES involving a blob +--echo # +CREATE TABLE t (a TEXT); +INSERT INTO t VALUES ('foo'),('bar'); +SELECT a FROM t ORDER BY a FETCH FIRST 2 ROWS WITH TIES; + +# Cleanup +DROP TABLE t; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 7baa4b49890..50a42ff8410 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -14231,6 +14231,7 @@ void JOIN::cleanup(bool full) // Run Cached_item DTORs! group_fields.delete_elements(); + order_fields.delete_elements(); /* We can't call delete_elements() on copy_funcs as this will cause From 58700a426ae8719db253d3ee9ec987381ef22a1b Mon Sep 17 00:00:00 2001 From: Julius Goryavsky Date: Tue, 29 Jun 2021 12:42:14 +0200 Subject: [PATCH 193/251] MDEV-26019: Upgrading MariaDB breaks TLS mariabackup SST Fixed typo in variable name that breaks SST in some scenatios. Also fixed one small inaccuracy after MDEV-25978 which leads to the use of an uninitialized variable when the --log-bin option is specified without an argument. --- scripts/wsrep_sst_common.sh | 11 +++++------ scripts/wsrep_sst_mariabackup.sh | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/scripts/wsrep_sst_common.sh b/scripts/wsrep_sst_common.sh index bb9a3b9f1b6..562f9dc3aac 100644 --- a/scripts/wsrep_sst_common.sh +++ b/scripts/wsrep_sst_common.sh @@ -456,7 +456,7 @@ if [ -n "${MYSQLD_OPT_LOG_BASENAME:-}" -a \ fi # If the --log-bin option is present without a value, then -# setting WSREP_SST_OPT_BINLOG by using other arguments: +# set WSREP_SST_OPT_BINLOG value using other arguments: if [ -z "$WSREP_SST_OPT_BINLOG" -a -n "${MYSQLD_OPT_LOG_BIN+x}" ]; then if [ -n "$WSREP_SST_OPT_LOG_BASENAME" ]; then # If the WSREP_SST_OPT_BINLOG variable is not set, but @@ -465,9 +465,8 @@ if [ -z "$WSREP_SST_OPT_BINLOG" -a -n "${MYSQLD_OPT_LOG_BIN+x}" ]; then # the "-bin" suffix: readonly WSREP_SST_OPT_BINLOG="$WSREP_SST_OPT_LOG_BASENAME-bin" else - # the default name, note that base of this name - # is already defined above - readonly WSREP_SST_OPT_BINLOG_INDEX="$WSREP_SST_OPT_BINLOG.index" + # Take the default name: + readonly WSREP_SST_OPT_BINLOG='mysql-bin' fi fi @@ -550,8 +549,8 @@ get_binlog() # the "-bin" suffix: readonly WSREP_SST_OPT_BINLOG_INDEX="$WSREP_SST_OPT_LOG_BASENAME-bin.index" else - # the default name, note that base of this name - # is already defined above + # the default name (note that base of this name + # is already defined above): readonly WSREP_SST_OPT_BINLOG_INDEX="$WSREP_SST_OPT_BINLOG.index" fi fi diff --git a/scripts/wsrep_sst_mariabackup.sh b/scripts/wsrep_sst_mariabackup.sh index 339a8fcf4a5..46804c9dce4 100644 --- a/scripts/wsrep_sst_mariabackup.sh +++ b/scripts/wsrep_sst_mariabackup.sh @@ -386,7 +386,7 @@ get_transfer() elif is_local_ip "$WSREP_SST_OPT_HOST_UNESCAPED"; then CN_option=',commonname=localhost' else - CN_option=",commonname='$WSREP_SST_OPT_HOST_UNSECAPED'" + CN_option=",commonname='$WSREP_SST_OPT_HOST_UNESCAPED'" fi tcmd="$tcmd,cert='$tpem',key='$tkey',cafile='$tcert'$CN_option$sockopt" wsrep_log_info "$action with cert=$tpem, key=$tkey, cafile=$tcert" From 64318620226a719e66ca01a255c4a9f11e321fd2 Mon Sep 17 00:00:00 2001 From: Julius Goryavsky Date: Tue, 29 Jun 2021 12:44:42 +0200 Subject: [PATCH 194/251] MDEV-25978 post-merge: updated mtr result files --- .../r/galera_sst_rsync_binlogname.result | 186 +++++++++++++----- .../r/galera_sst_rsync_logbasename.result | 186 +++++++++++++----- 2 files changed, 264 insertions(+), 108 deletions(-) diff --git a/mysql-test/suite/galera/r/galera_sst_rsync_binlogname.result b/mysql-test/suite/galera/r/galera_sst_rsync_binlogname.result index 0f0a673947c..9b56a09d369 100644 --- a/mysql-test/suite/galera/r/galera_sst_rsync_binlogname.result +++ b/mysql-test/suite/galera/r/galera_sst_rsync_binlogname.result @@ -1,96 +1,174 @@ +connection node_2; +connection node_1; connection node_1; connection node_2; 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; +CREATE TABLE t1 (id int not null primary key,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'); +INSERT INTO t1 VALUES (1,'node1_committed_before'); +INSERT INTO t1 VALUES (2,'node1_committed_before'); +INSERT INTO t1 VALUES (3,'node1_committed_before'); +INSERT INTO t1 VALUES (4,'node1_committed_before'); +INSERT INTO t1 VALUES (5,'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'); +INSERT INTO t1 VALUES (6,'node2_committed_before'); +INSERT INTO t1 VALUES (7,'node2_committed_before'); +INSERT INTO t1 VALUES (8,'node2_committed_before'); +INSERT INTO t1 VALUES (9,'node2_committed_before'); +INSERT INTO t1 VALUES (10,'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'); +INSERT INTO t1 VALUES (11,'node1_committed_during'); +INSERT INTO t1 VALUES (12,'node1_committed_during'); +INSERT INTO t1 VALUES (13,'node1_committed_during'); +INSERT INTO t1 VALUES (14,'node1_committed_during'); +INSERT INTO t1 VALUES (15,'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'); +INSERT INTO t1 VALUES (16,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (17,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (18,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (19,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (20,'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'); +INSERT INTO t1 VALUES (21,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (22,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (23,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (24,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (25,'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'); +INSERT INTO t1 VALUES (26,'node2_committed_after'); +INSERT INTO t1 VALUES (27,'node2_committed_after'); +INSERT INTO t1 VALUES (28,'node2_committed_after'); +INSERT INTO t1 VALUES (29,'node2_committed_after'); +INSERT INTO t1 VALUES (30,'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'); +INSERT INTO t1 VALUES (31,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (32,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (33,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (34,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (35,'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'); +INSERT INTO t1 VALUES (36,'node1_committed_after'); +INSERT INTO t1 VALUES (37,'node1_committed_after'); +INSERT INTO t1 VALUES (38,'node1_committed_after'); +INSERT INTO t1 VALUES (39,'node1_committed_after'); +INSERT INTO t1 VALUES (40,'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'); +INSERT INTO t1 VALUES (41,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (42,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (43,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (44,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (45,'node1_to_be_rollbacked_after'); ROLLBACK; -SELECT COUNT(*) = 35 FROM t1; -COUNT(*) = 35 -1 +SET AUTOCOMMIT=ON; +SET SESSION wsrep_sync_wait=15; +SELECT COUNT(*) AS EXPECT_15 FROM t1; +EXPECT_15 +35 +SELECT * from t1; +id f1 +1 node1_committed_before +2 node1_committed_before +3 node1_committed_before +4 node1_committed_before +5 node1_committed_before +6 node2_committed_before +7 node2_committed_before +8 node2_committed_before +9 node2_committed_before +10 node2_committed_before +11 node1_committed_during +12 node1_committed_during +13 node1_committed_during +14 node1_committed_during +15 node1_committed_during +16 node1_to_be_committed_after +17 node1_to_be_committed_after +18 node1_to_be_committed_after +19 node1_to_be_committed_after +20 node1_to_be_committed_after +26 node2_committed_after +27 node2_committed_after +28 node2_committed_after +29 node2_committed_after +30 node2_committed_after +31 node1_to_be_committed_after +32 node1_to_be_committed_after +33 node1_to_be_committed_after +34 node1_to_be_committed_after +35 node1_to_be_committed_after +36 node1_committed_after +37 node1_committed_after +38 node1_committed_after +39 node1_committed_after +40 node1_committed_after 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 +SET AUTOCOMMIT=ON; +SET SESSION wsrep_sync_wait=15; +SELECT COUNT(*) AS EXPECT_15 FROM t1; +EXPECT_15 +35 +SELECT * from t1; +id f1 +1 node1_committed_before +2 node1_committed_before +3 node1_committed_before +4 node1_committed_before +5 node1_committed_before +6 node2_committed_before +7 node2_committed_before +8 node2_committed_before +9 node2_committed_before +10 node2_committed_before +11 node1_committed_during +12 node1_committed_during +13 node1_committed_during +14 node1_committed_during +15 node1_committed_during +16 node1_to_be_committed_after +17 node1_to_be_committed_after +18 node1_to_be_committed_after +19 node1_to_be_committed_after +20 node1_to_be_committed_after +26 node2_committed_after +27 node2_committed_after +28 node2_committed_after +29 node2_committed_after +30 node2_committed_after +31 node1_to_be_committed_after +32 node1_to_be_committed_after +33 node1_to_be_committed_after +34 node1_to_be_committed_after +35 node1_to_be_committed_after +36 node1_committed_after +37 node1_committed_after +38 node1_committed_after +39 node1_committed_after +40 node1_committed_after 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; diff --git a/mysql-test/suite/galera/r/galera_sst_rsync_logbasename.result b/mysql-test/suite/galera/r/galera_sst_rsync_logbasename.result index 0f0a673947c..9b56a09d369 100644 --- a/mysql-test/suite/galera/r/galera_sst_rsync_logbasename.result +++ b/mysql-test/suite/galera/r/galera_sst_rsync_logbasename.result @@ -1,96 +1,174 @@ +connection node_2; +connection node_1; connection node_1; connection node_2; 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; +CREATE TABLE t1 (id int not null primary key,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'); +INSERT INTO t1 VALUES (1,'node1_committed_before'); +INSERT INTO t1 VALUES (2,'node1_committed_before'); +INSERT INTO t1 VALUES (3,'node1_committed_before'); +INSERT INTO t1 VALUES (4,'node1_committed_before'); +INSERT INTO t1 VALUES (5,'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'); +INSERT INTO t1 VALUES (6,'node2_committed_before'); +INSERT INTO t1 VALUES (7,'node2_committed_before'); +INSERT INTO t1 VALUES (8,'node2_committed_before'); +INSERT INTO t1 VALUES (9,'node2_committed_before'); +INSERT INTO t1 VALUES (10,'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'); +INSERT INTO t1 VALUES (11,'node1_committed_during'); +INSERT INTO t1 VALUES (12,'node1_committed_during'); +INSERT INTO t1 VALUES (13,'node1_committed_during'); +INSERT INTO t1 VALUES (14,'node1_committed_during'); +INSERT INTO t1 VALUES (15,'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'); +INSERT INTO t1 VALUES (16,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (17,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (18,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (19,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (20,'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'); +INSERT INTO t1 VALUES (21,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (22,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (23,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (24,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (25,'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'); +INSERT INTO t1 VALUES (26,'node2_committed_after'); +INSERT INTO t1 VALUES (27,'node2_committed_after'); +INSERT INTO t1 VALUES (28,'node2_committed_after'); +INSERT INTO t1 VALUES (29,'node2_committed_after'); +INSERT INTO t1 VALUES (30,'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'); +INSERT INTO t1 VALUES (31,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (32,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (33,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (34,'node1_to_be_committed_after'); +INSERT INTO t1 VALUES (35,'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'); +INSERT INTO t1 VALUES (36,'node1_committed_after'); +INSERT INTO t1 VALUES (37,'node1_committed_after'); +INSERT INTO t1 VALUES (38,'node1_committed_after'); +INSERT INTO t1 VALUES (39,'node1_committed_after'); +INSERT INTO t1 VALUES (40,'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'); +INSERT INTO t1 VALUES (41,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (42,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (43,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (44,'node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES (45,'node1_to_be_rollbacked_after'); ROLLBACK; -SELECT COUNT(*) = 35 FROM t1; -COUNT(*) = 35 -1 +SET AUTOCOMMIT=ON; +SET SESSION wsrep_sync_wait=15; +SELECT COUNT(*) AS EXPECT_15 FROM t1; +EXPECT_15 +35 +SELECT * from t1; +id f1 +1 node1_committed_before +2 node1_committed_before +3 node1_committed_before +4 node1_committed_before +5 node1_committed_before +6 node2_committed_before +7 node2_committed_before +8 node2_committed_before +9 node2_committed_before +10 node2_committed_before +11 node1_committed_during +12 node1_committed_during +13 node1_committed_during +14 node1_committed_during +15 node1_committed_during +16 node1_to_be_committed_after +17 node1_to_be_committed_after +18 node1_to_be_committed_after +19 node1_to_be_committed_after +20 node1_to_be_committed_after +26 node2_committed_after +27 node2_committed_after +28 node2_committed_after +29 node2_committed_after +30 node2_committed_after +31 node1_to_be_committed_after +32 node1_to_be_committed_after +33 node1_to_be_committed_after +34 node1_to_be_committed_after +35 node1_to_be_committed_after +36 node1_committed_after +37 node1_committed_after +38 node1_committed_after +39 node1_committed_after +40 node1_committed_after 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 +SET AUTOCOMMIT=ON; +SET SESSION wsrep_sync_wait=15; +SELECT COUNT(*) AS EXPECT_15 FROM t1; +EXPECT_15 +35 +SELECT * from t1; +id f1 +1 node1_committed_before +2 node1_committed_before +3 node1_committed_before +4 node1_committed_before +5 node1_committed_before +6 node2_committed_before +7 node2_committed_before +8 node2_committed_before +9 node2_committed_before +10 node2_committed_before +11 node1_committed_during +12 node1_committed_during +13 node1_committed_during +14 node1_committed_during +15 node1_committed_during +16 node1_to_be_committed_after +17 node1_to_be_committed_after +18 node1_to_be_committed_after +19 node1_to_be_committed_after +20 node1_to_be_committed_after +26 node2_committed_after +27 node2_committed_after +28 node2_committed_after +29 node2_committed_after +30 node2_committed_after +31 node1_to_be_committed_after +32 node1_to_be_committed_after +33 node1_to_be_committed_after +34 node1_to_be_committed_after +35 node1_to_be_committed_after +36 node1_committed_after +37 node1_committed_after +38 node1_committed_after +39 node1_committed_after +40 node1_committed_after 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; From 390014781b6832597e83ceffe06a214fb395f74f Mon Sep 17 00:00:00 2001 From: Andrei Elkin Date: Sat, 26 Jun 2021 20:36:53 +0300 Subject: [PATCH 195/251] MDEV-26031 unnessary xid logging in one phase commit case The bug was originally observed as hanging binlog background thread at shutdown similar to one of MDEV-21120. It occurred through unnessary xid logging in 1pc execution. Two parts of the issue are fixed. Per engine loop by involved engine with attempt to mark a group requiring xid unlogging gets corrected in two ways. Do not execute it when the termination event is irrelevant for recovery, does not have xid in particular. Do not break the loop anymore unconditionally at the end of the 1st iteration. --- mysql-test/suite/binlog/r/binlog_1pc.result | 34 ++++++++++++++++++ mysql-test/suite/binlog/t/binlog_1pc.test | 39 +++++++++++++++++++++ sql/log.cc | 19 +++++++--- 3 files changed, 87 insertions(+), 5 deletions(-) create mode 100644 mysql-test/suite/binlog/r/binlog_1pc.result create mode 100644 mysql-test/suite/binlog/t/binlog_1pc.test diff --git a/mysql-test/suite/binlog/r/binlog_1pc.result b/mysql-test/suite/binlog/r/binlog_1pc.result new file mode 100644 index 00000000000..4a1615d5f1c --- /dev/null +++ b/mysql-test/suite/binlog/r/binlog_1pc.result @@ -0,0 +1,34 @@ +RESET MASTER; +CREATE TABLE t (f INT) ENGINE=INNODB; +CREATE TABLE ta (f INT) ENGINE=Aria; +BEGIN; +INSERT INTO t SET f = 1; +INSERT INTO ta SET f = 1; +COMMIT; +include/show_binlog_events.inc +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Gtid # # BEGIN GTID #-#-# +master-bin.000001 # Query # # use `test`; INSERT INTO ta SET f = 1 +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Gtid # # BEGIN GTID #-#-# +master-bin.000001 # Query # # use `test`; INSERT INTO t SET f = 1 +master-bin.000001 # Query # # COMMIT +# Prove that binlog is resettable. Under the bug condition it was not. +RESET MASTER; +SET @@binlog_format = ROW; +CREATE TABLE ta2 ENGINE = Aria SELECT * from t; +include/show_binlog_events.inc +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Gtid # # BEGIN GTID #-#-# +master-bin.000001 # Query # # use `test`; CREATE TABLE `ta2` ( + `f` int(11) DEFAULT NULL +) ENGINE=Aria PAGE_CHECKSUM=1 +master-bin.000001 # Annotate_rows # # CREATE TABLE ta2 ENGINE = Aria SELECT * from t +master-bin.000001 # Table_map # # table_id: # (test.ta2) +master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +# Prove that binlog is resettable. Under the bug condition it was not. +RESET MASTER; +# Cleanup +DROP TABLE ta2, ta, t; +# End of the tests diff --git a/mysql-test/suite/binlog/t/binlog_1pc.test b/mysql-test/suite/binlog/t/binlog_1pc.test new file mode 100644 index 00000000000..8465ff171b3 --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_1pc.test @@ -0,0 +1,39 @@ +# The test file contains tests specific to one phase commit +# execution and binlogging. +# +# MDEV-26031 unnessary xid logging in one phase commit case +# +--source include/have_innodb.inc +--source include/have_aria.inc +--source include/have_binlog_format_mixed.inc + +RESET MASTER; + +CREATE TABLE t (f INT) ENGINE=INNODB; +CREATE TABLE ta (f INT) ENGINE=Aria; + +--let $binlog_start = query_get_value(SHOW MASTER STATUS, Position, 1) +BEGIN; + INSERT INTO t SET f = 1; + INSERT INTO ta SET f = 1; +COMMIT; +--let $binlog_file = query_get_value(SHOW MASTER STATUS, File, 1) +--source include/show_binlog_events.inc + +--echo # Prove that binlog is resettable. Under the bug condition it was not. +RESET MASTER; + +--let $binlog_start = query_get_value(SHOW MASTER STATUS, Position, 1) +--let $binlog_file = query_get_value(SHOW MASTER STATUS, File, 1) +SET @@binlog_format = ROW; +CREATE TABLE ta2 ENGINE = Aria SELECT * from t; +--source include/show_binlog_events.inc + +--echo # Prove that binlog is resettable. Under the bug condition it was not. +RESET MASTER; + + +--echo # Cleanup +DROP TABLE ta2, ta, t; + +--echo # End of the tests diff --git a/sql/log.cc b/sql/log.cc index a6e83d1b4f5..538f6ea86ac 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -2186,11 +2186,20 @@ int binlog_commit(THD *thd, bool all, bool ro_1pc) */ if (likely(!error) && ending_trans(thd, all)) { - error= is_preparing_xa(thd) ? + bool is_xa_prepare= is_preparing_xa(thd); + + error= is_xa_prepare ? binlog_commit_flush_xa_prepare(thd, all, cache_mngr) : binlog_commit_flush_trx_cache (thd, all, cache_mngr, ro_1pc); + // the user xa is unlogged on common exec path with the "empty" xa case + if (cache_mngr->need_unlog && !is_xa_prepare) + { + error= + mysql_bin_log.unlog(BINLOG_COOKIE_MAKE(cache_mngr->binlog_id, + cache_mngr->delayed_error), 1); + cache_mngr->need_unlog= false; + } } - /* This is part of the stmt rollback. */ @@ -7634,16 +7643,16 @@ MYSQL_BIN_LOG::write_transaction_to_binlog(THD *thd, entry.need_unlog= is_preparing_xa(thd); ha_info= all ? thd->transaction->all.ha_list : thd->transaction->stmt.ha_list; entry.ro_1pc= is_ro_1pc; + entry.end_event= end_ev; + auto has_xid= entry.end_event->get_type_code() == XID_EVENT; - for (; !entry.need_unlog && ha_info; ha_info= ha_info->next()) + for (; has_xid && !entry.need_unlog && ha_info; ha_info= ha_info->next()) { if (ha_info->is_started() && ha_info->ht() != binlog_hton && !ha_info->ht()->commit_checkpoint_request) entry.need_unlog= true; - break; } - entry.end_event= end_ev; if (cache_mngr->stmt_cache.has_incident() || cache_mngr->trx_cache.has_incident()) { From 58252fff15acfe7c7b0452a87e202e3f8e454e19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 29 Jun 2021 14:28:23 +0300 Subject: [PATCH 196/251] MDEV-26040 os_file_set_size() may not work on O_DIRECT files os_file_set_size(): Trim the current size down to the file system block size, to obey the constraints for unbuffered I/O. --- storage/innobase/os/os0file.cc | 38 +++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc index d2d5769d85e..884cadaf9f6 100644 --- a/storage/innobase/os/os0file.cc +++ b/storage/innobase/os/os0file.cc @@ -5420,6 +5420,8 @@ os_file_set_size( fallback: #else + struct stat statbuf; + if (is_sparse) { bool success = !ftruncate(file, size); if (!success) { @@ -5433,10 +5435,17 @@ fallback: # ifdef HAVE_POSIX_FALLOCATE int err; do { - os_offset_t current_size = os_file_get_size(file); - err = current_size >= size - ? 0 : posix_fallocate(file, current_size, + if (fstat(file, &statbuf)) { + err = errno; + } else { + os_offset_t current_size = statbuf.st_size; + if (current_size >= size) { + return true; + } + current_size &= ~os_offset_t(statbuf.st_blksize - 1); + err = posix_fallocate(file, current_size, size - current_size); + } } while (err == EINTR && srv_shutdown_state <= SRV_SHUTDOWN_INITIATED); @@ -5459,6 +5468,27 @@ fallback: # endif /* HAVE_POSIX_ALLOCATE */ #endif /* _WIN32*/ +#ifdef _WIN32 + os_offset_t current_size = os_file_get_size(file); + FILE_STORAGE_INFO info; + if (GetFileInformationByHandleEx(file, FileStorageInfo, &info, + sizeof info)) { + if (info.LogicalBytesPerSector) { + current_size &= ~os_offset_t(info.LogicalBytesPerSector + - 1); + } + } +#else + if (fstat(file, &statbuf)) { + return false; + } + os_offset_t current_size = statbuf.st_size + & ~os_offset_t(statbuf.st_blksize - 1); +#endif + if (current_size >= size) { + return true; + } + /* Write up to 1 megabyte at a time. */ ulint buf_size = ut_min( static_cast(64), @@ -5476,8 +5506,6 @@ fallback: /* Write buffer full of zeros */ memset(buf, 0, buf_size); - os_offset_t current_size = os_file_get_size(file); - while (current_size < size && srv_shutdown_state <= SRV_SHUTDOWN_INITIATED) { ulint n_bytes; From 3d15e3c0859a3ac73b968c3376e09f991ecb1adf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 29 Jun 2021 15:02:10 +0300 Subject: [PATCH 197/251] MDEV-22640 fixup: clang -Winconsistent-missing-override --- sql/item_jsonfunc.h | 58 ++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 30 deletions(-) diff --git a/sql/item_jsonfunc.h b/sql/item_jsonfunc.h index 64ee47f740a..0026fce21b2 100644 --- a/sql/item_jsonfunc.h +++ b/sql/item_jsonfunc.h @@ -1,7 +1,7 @@ #ifndef ITEM_JSONFUNC_INCLUDED #define ITEM_JSONFUNC_INCLUDED -/* Copyright (c) 2016, MariaDB +/* Copyright (c) 2016, 2021, 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 @@ -123,8 +123,8 @@ public: :Item_str_func(thd, a, b) { } Item_json_func(THD *thd, List &list) :Item_str_func(thd, list) { } - bool is_json_type() { return true; } - void make_send_field(THD *thd, Send_field *tmp_field) + bool is_json_type() override { return true; } + void make_send_field(THD *thd, Send_field *tmp_field) override { Item_str_func::make_send_field(thd, tmp_field); static const Lex_cstring fmt(STRING_WITH_LEN("json")); @@ -544,12 +544,12 @@ protected: Overrides Item_func_group_concat::skip_nulls() NULL-s should be added to the result as JSON null value. */ - bool skip_nulls() const { return false; } - String *get_str_from_item(Item *i, String *tmp); + bool skip_nulls() const override { return false; } + String *get_str_from_item(Item *i, String *tmp) override; String *get_str_from_field(Item *i, Field *f, String *tmp, - const uchar *key, size_t offset); + const uchar *key, size_t offset) override; void cut_max_length(String *result, - uint old_length, uint max_length) const; + uint old_length, uint max_length) const override; public: String m_tmp_json; /* Used in get_str_from_*.. */ Item_func_json_arrayagg(THD *thd, Name_resolution_context *context_arg, @@ -562,10 +562,10 @@ public: } Item_func_json_arrayagg(THD *thd, Item_func_json_arrayagg *item) : Item_func_group_concat(thd, item) {} - bool is_json_type() { return true; } + bool is_json_type() override { return true; } - const char *func_name() const { return "json_arrayagg("; } - enum Sumfunctype sum_func() const {return JSON_ARRAYAGG_FUNC;} + const char *func_name() const override { return "json_arrayagg("; } + enum Sumfunctype sum_func() const override { return JSON_ARRAYAGG_FUNC; } String* val_str(String *str) override; @@ -587,40 +587,38 @@ public: } Item_func_json_objectagg(THD *thd, Item_func_json_objectagg *item); - bool is_json_type() { return true; } - void cleanup(); + bool is_json_type() override { return true; } + void cleanup() override; - enum Sumfunctype sum_func () const {return JSON_OBJECTAGG_FUNC;} - const char *func_name() const { return "json_objectagg"; } - const Type_handler *type_handler() const + enum Sumfunctype sum_func() const override {return JSON_OBJECTAGG_FUNC;} + const char *func_name() const override { return "json_objectagg"; } + const Type_handler *type_handler() const override { if (too_big_for_varchar()) return &type_handler_blob; return &type_handler_varchar; } - void clear(); - bool add(); - void reset_field() { DBUG_ASSERT(0); } // not used - void update_field() { DBUG_ASSERT(0); } // not used - bool fix_fields(THD *,Item **); + void clear() override; + bool add() override; + void reset_field() override { DBUG_ASSERT(0); } // not used + void update_field() override { DBUG_ASSERT(0); } // not used + bool fix_fields(THD *,Item **) override; - double val_real() - { return 0.0; } - longlong val_int() - { return 0; } - my_decimal *val_decimal(my_decimal *decimal_value) + double val_real() override { return 0.0; } + longlong val_int() override { return 0; } + my_decimal *val_decimal(my_decimal *decimal_value) override { my_decimal_set_zero(decimal_value); return decimal_value; } - bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) + bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) override { return get_date_from_string(thd, ltime, fuzzydate); } - String* val_str(String* str); - Item *copy_or_same(THD* thd); - void no_rows_in_result() {} - Item *get_copy(THD *thd) + String* val_str(String* str) override; + Item *copy_or_same(THD* thd) override; + void no_rows_in_result() override {} + Item *get_copy(THD *thd) override { return get_item_copy(thd, this); } }; From 30edd5549dd764dbc8171ee764380dba4eb94cc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 28 Jun 2021 13:42:43 +0300 Subject: [PATCH 198/251] MDEV-26029: Sparse files are inefficient on thinly provisioned storage The MariaDB implementation of page_compressed tables for InnoDB used sparse files. In the worst case, in the data file, every data page will consist of some data followed by a hole. This may be extremely inefficient in some file systems. If the underlying storage device is thinly provisioned (can compress data on the fly), it would be good to write regular files (with sequences of NUL bytes at the end of each page_compressed block) and let the storage device take care of compressing the data. For reads, sparse file regions and regions containing NUL bytes will be indistinguishable. my_test_if_disable_punch_hole(): A new predicate for detecting thinly provisioned storage. (Not implemented yet.) innodb_atomic_writes: Correct the comment. buf_flush_page(): Support all values of fil_node_t::punch_hole. On a thinly provisioned storage device, we will always write NUL-padded innodb_page_size bytes also for page_compressed tables. buf_flush_freed_pages(): Remove a redundant condition. fil_space_t::atomic_write_supported: Remove. (This was duplicating fil_node_t::atomic_write.) fil_space_t::punch_hole: Remove. (Duplicated fil_node_t::punch_hole.) fil_node_t: Remove magic_n, and consolidate flags into bitfields. For punch_hole we introduce a third value that indicates a thinly provisioned storage device. fil_node_t::find_metadata(): Detect all attributes of the file. --- include/my_sys.h | 5 +- .../suite/sys_vars/r/sysvars_innodb.result | 2 +- storage/innobase/buf/buf0dblwr.cc | 1 + storage/innobase/buf/buf0flu.cc | 20 ++- storage/innobase/fil/fil0fil.cc | 25 +--- storage/innobase/handler/ha_innodb.cc | 4 +- storage/innobase/include/fil0fil.h | 112 +++++++-------- storage/innobase/os/os0file.cc | 136 +++++++----------- storage/innobase/row/row0import.cc | 2 +- 9 files changed, 126 insertions(+), 181 deletions(-) diff --git a/include/my_sys.h b/include/my_sys.h index f3515b7726c..fccff539fa9 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2013, Oracle and/or its affiliates. - Copyright (c) 2010, 2020, MariaDB Corporation. + Copyright (c) 2010, 2021, 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 @@ -183,10 +183,11 @@ extern BOOL my_obtain_privilege(LPCSTR lpPrivilege); #endif void my_init_atomic_write(void); +#define my_test_if_thinly_provisioned(A) 0 #ifdef __linux__ my_bool my_test_if_atomic_write(File handle, int pagesize); #else -#define my_test_if_atomic_write(A, B) 0 +# define my_test_if_atomic_write(A, B) 0 #endif /* __linux__ */ extern my_bool my_may_have_atomic_write; diff --git a/mysql-test/suite/sys_vars/r/sysvars_innodb.result b/mysql-test/suite/sys_vars/r/sysvars_innodb.result index 1a88710de94..bba60290863 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_innodb.result +++ b/mysql-test/suite/sys_vars/r/sysvars_innodb.result @@ -1754,7 +1754,7 @@ SESSION_VALUE NULL DEFAULT_VALUE ON VARIABLE_SCOPE GLOBAL VARIABLE_TYPE BOOLEAN -VARIABLE_COMMENT Enable atomic writes, instead of using the doublewrite buffer, for files on devices that supports atomic writes. This option only works on Linux with either FusionIO cards using the directFS filesystem or with Shannon cards using any file system. +VARIABLE_COMMENT Enable atomic writes, instead of using the doublewrite buffer, for files on devices that supports atomic writes. NUMERIC_MIN_VALUE NULL NUMERIC_MAX_VALUE NULL NUMERIC_BLOCK_SIZE NULL diff --git a/storage/innobase/buf/buf0dblwr.cc b/storage/innobase/buf/buf0dblwr.cc index 1b7a2d9608a..44db9986df6 100644 --- a/storage/innobase/buf/buf0dblwr.cc +++ b/storage/innobase/buf/buf0dblwr.cc @@ -712,6 +712,7 @@ void buf_dblwr_t::add_to_batch(const IORequest &request, size_t size) ut_ad(request.bpage); ut_ad(request.bpage->in_file()); ut_ad(request.node); + ut_ad(request.node->space->purpose == FIL_TYPE_TABLESPACE); ut_ad(request.node->space->id == request.bpage->id().space()); ut_ad(request.node->space->referenced()); ut_ad(!srv_read_only_mode); diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc index 4adf5931281..0717558eba6 100644 --- a/storage/innobase/buf/buf0flu.cc +++ b/storage/innobase/buf/buf0flu.cc @@ -804,8 +804,6 @@ static bool buf_flush_page(buf_page_t *bpage, bool lru, fil_space_t *space) ut_ad(bpage->ready_for_flush()); ut_ad((space->purpose == FIL_TYPE_TEMPORARY) == (space == fil_system.temp_space)); - ut_ad(space->purpose == FIL_TYPE_TABLESPACE || - space->atomic_write_supported); ut_ad(space->referenced()); ut_ad(lru || space != fil_system.temp_space); @@ -912,8 +910,16 @@ static bool buf_flush_page(buf_page_t *bpage, bool lru, fil_space_t *space) } #if defined HAVE_FALLOC_PUNCH_HOLE_AND_KEEP_SIZE || defined _WIN32 - if (size != orig_size && space->punch_hole) - type= lru ? IORequest::PUNCH_LRU : IORequest::PUNCH; + if (size != orig_size) + { + switch (space->chain.start->punch_hole) { + case 1: + type= lru ? IORequest::PUNCH_LRU : IORequest::PUNCH; + break; + case 2: + size= orig_size; + } + } #endif frame=page; } @@ -1036,8 +1042,8 @@ innodb_immediate_scrub_data_uncompressed from the freed ranges. @param space tablespace which may contain ranges of freed pages */ static void buf_flush_freed_pages(fil_space_t *space) { - const bool punch_hole= space->punch_hole; - if (!srv_immediate_scrub_data_uncompressed && !punch_hole) + const bool punch_hole= space->chain.start->punch_hole == 1; + if (!punch_hole && !srv_immediate_scrub_data_uncompressed) return; lsn_t flush_to_disk_lsn= log_sys.get_flushed_lsn(); @@ -1064,7 +1070,7 @@ static void buf_flush_freed_pages(fil_space_t *space) (range.last - range.first + 1) * physical_size, nullptr); } - else if (srv_immediate_scrub_data_uncompressed) + else { for (os_offset_t i= range.first; i <= range.last; i++) { diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index 6997978ea0a..c841eb79497 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -317,8 +317,6 @@ fil_node_t* fil_space_t::add(const char* name, pfs_os_file_t handle, node->size = size; - node->magic_n = FIL_NODE_MAGIC_N; - node->init_size = size; node->max_size = max_pages; @@ -718,7 +716,6 @@ bool fil_space_extend(fil_space_t *space, uint32_t size) inline pfs_os_file_t fil_node_t::close_to_free(bool detach_handle) { mysql_mutex_assert_owner(&fil_system.mutex); - ut_a(magic_n == FIL_NODE_MAGIC_N); ut_a(!being_extended); if (is_open() && @@ -941,16 +938,6 @@ fil_space_t *fil_space_t::create(ulint id, ulint flags, space->latch.SRW_LOCK_INIT(fil_space_latch_key); - if (space->purpose == FIL_TYPE_TEMPORARY) { - /* SysTablespace::open_or_create() would pass - size!=0 to fil_space_t::add(), so first_time_open - would not hold in fil_node_open_file(), and we - must assign this manually. We do not care about - the durability or atomicity of writes to the - temporary tablespace files. */ - space->atomic_write_supported = true; - } - mysql_mutex_lock(&fil_system.mutex); if (const fil_space_t *old_space = fil_space_get_by_id(id)) { @@ -1951,9 +1938,6 @@ skip_second_rename: return(success); } -/* FIXME: remove this! */ -IF_WIN(, bool os_is_sparse_file_supported(os_file_t fh)); - /** Create a tablespace file. @param[in] space_id Tablespace ID @param[in] name Tablespace name in dbname/tablename format. @@ -2041,7 +2025,6 @@ fil_ibd_create( } const bool is_compressed = fil_space_t::is_compressed(flags); - bool punch_hole = is_compressed; fil_space_crypt_t* crypt_data = nullptr; #ifdef _WIN32 if (is_compressed) { @@ -2060,9 +2043,6 @@ err_exit: return NULL; } - /* FIXME: remove this */ - IF_WIN(, punch_hole = punch_hole && os_is_sparse_file_supported(file)); - /* We have to write the space id to the file immediately and flush the file to disk. This is because in crash recovery we must be aware what tablespaces exist and what are their space id's, so that we can apply @@ -2115,9 +2095,8 @@ err_exit: if (fil_space_t* space = fil_space_t::create(space_id, flags, FIL_TYPE_TABLESPACE, crypt_data, mode)) { - space->punch_hole = punch_hole; fil_node_t* node = space->add(path, file, size, false, true); - node->find_metadata(file); + IF_WIN(node->find_metadata(), node->find_metadata(file, true)); mtr.start(); mtr.set_named_space(space); fsp_header_init(space, size, &mtr); @@ -2878,7 +2857,7 @@ fil_io_t fil_space_t::io(const IORequest &type, os_offset_t offset, size_t len, /* Punch hole is not supported, make space not to support punch hole */ if (UNIV_UNLIKELY(err == DB_IO_NO_PUNCH_HOLE)) { - punch_hole = false; + node->punch_hole = false; err = DB_SUCCESS; } goto release_sync_write; diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index ab94684e982..8b97bf07c33 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -18510,9 +18510,7 @@ static MYSQL_SYSVAR_BOOL(doublewrite, srv_use_doublewrite_buf, static MYSQL_SYSVAR_BOOL(use_atomic_writes, srv_use_atomic_writes, PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY, "Enable atomic writes, instead of using the doublewrite buffer, for files " - "on devices that supports atomic writes. " - "This option only works on Linux with either FusionIO cards using " - "the directFS filesystem or with Shannon cards using any file system.", + "on devices that supports atomic writes.", NULL, NULL, TRUE); static MYSQL_SYSVAR_BOOL(stats_include_delete_marked, diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h index 58d83770daa..9fd0b076520 100644 --- a/storage/innobase/include/fil0fil.h +++ b/storage/innobase/include/fil0fil.h @@ -424,13 +424,6 @@ public: /** Checks that this tablespace needs key rotation. */ bool is_in_default_encrypt; - /** True if the device this filespace is on supports atomic writes */ - bool atomic_write_supported; - - /** True if file system storing this tablespace supports - punch hole */ - bool punch_hole; - /** mutex to protect freed ranges */ std::mutex freed_range_mutex; @@ -444,11 +437,7 @@ public: ulint magic_n;/*!< FIL_SPACE_MAGIC_N */ /** @return whether doublewrite buffering is needed */ - bool use_doublewrite() const - { - return !atomic_write_supported && srv_use_doublewrite_buf && - buf_dblwr.is_initialised(); - } + inline bool use_doublewrite() const; /** Append a file to the chain of files of a space. @param[in] name file name of a file that is not open @@ -509,6 +498,8 @@ public: /** @return whether the storage device is rotational (HDD, not SSD) */ inline bool is_rotational() const; + /** whether the tablespace discovery is being deferred during crash + recovery due to incompletely written page 0 */ inline bool is_deferred() const; /** Open each file. Never invoked on .ibd files. @@ -1066,60 +1057,56 @@ private: /** File node of a tablespace or the log data space */ struct fil_node_t final { - /** tablespace containing this file */ - fil_space_t* space; - /** file name; protected by fil_system.mutex and log_sys.mutex. */ - char* name; - /** file handle (valid if is_open) */ - pfs_os_file_t handle; - /** whether the file actually is a raw device or disk partition */ - bool is_raw_disk; - /** whether the file is on non-rotational media (SSD) */ - bool on_ssd; - /** size of the file in database pages (0 if not known yet); - the possible last incomplete megabyte may be ignored - if space->id == 0 */ - uint32_t size; - /** initial size of the file in database pages; - FIL_IBD_FILE_INITIAL_SIZE by default */ - uint32_t init_size; - /** maximum size of the file in database pages (0 if unlimited) */ - uint32_t max_size; - /** whether the file is currently being extended */ - Atomic_relaxed being_extended; - /** link to other files in this tablespace */ - UT_LIST_NODE_T(fil_node_t) chain; + /** tablespace containing this file */ + fil_space_t *space; + /** file name; protected by fil_system.mutex and log_sys.mutex */ + char *name; + /** file handle */ + pfs_os_file_t handle; + /** whether the file is on non-rotational media (SSD) */ + unsigned on_ssd:1; + /** how to write page_compressed tables + (0=do not punch holes but write minimal amount of data, 1=punch holes, + 2=always write the same amount; thinly provisioned storage will compress) */ + unsigned punch_hole:2; + /** whether this file could use atomic write */ + unsigned atomic_write:1; + /** whether the file actually is a raw device or disk partition */ + unsigned is_raw_disk:1; + /** whether the tablespace discovery is being deferred during crash + recovery due to incompletely written page 0 */ + unsigned deferred:1; - /** whether this file could use atomic write (data file) */ - bool atomic_write; + /** size of the file in database pages (0 if not known yet); + the possible last incomplete megabyte may be ignored if space->id == 0 */ + uint32_t size; + /** initial size of the file in database pages; + FIL_IBD_FILE_INITIAL_SIZE by default */ + uint32_t init_size; + /** maximum size of the file in database pages (0 if unlimited) */ + uint32_t max_size; + /** whether the file is currently being extended */ + Atomic_relaxed being_extended; + /** link to other files in this tablespace */ + UT_LIST_NODE_T(fil_node_t) chain; - /** Filesystem block size */ - ulint block_size; + /** Filesystem block size */ + ulint block_size; - /** Deferring the tablespace during recovery and it - can be used to skip the validation of page0 */ - bool deferred=false; + /** @return whether this file is open */ + bool is_open() const { return handle != OS_FILE_CLOSED; } - /** FIL_NODE_MAGIC_N */ - ulint magic_n; + /** Read the first page of a data file. + @return whether the page was found valid */ + bool read_page0(); - /** @return whether this file is open */ - bool is_open() const - { - return(handle != OS_FILE_CLOSED); - } - - /** Read the first page of a data file. - @return whether the page was found valid */ - bool read_page0(); - - /** Determine some file metadata when creating or reading the file. - @param file the file that is being created, or OS_FILE_CLOSED */ - void find_metadata(os_file_t file = OS_FILE_CLOSED + /** Determine some file metadata when creating or reading the file. + @param file the file that is being created, or OS_FILE_CLOSED */ + void find_metadata(os_file_t file= OS_FILE_CLOSED #ifndef _WIN32 - , struct stat* statbuf = NULL + , bool create= false, struct stat *statbuf= nullptr #endif - ); + ); /** Close the file handle. */ void close(); @@ -1138,8 +1125,11 @@ private: void prepare_to_close_or_detach(); }; -/** Value of fil_node_t::magic_n */ -#define FIL_NODE_MAGIC_N 89389 +inline bool fil_space_t::use_doublewrite() const +{ + return !UT_LIST_GET_FIRST(chain)->atomic_write && srv_use_doublewrite_buf && + buf_dblwr.is_initialised(); +} inline void fil_space_t::set_imported() { diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc index 53c0c07eda4..efc92a384c5 100644 --- a/storage/innobase/os/os0file.cc +++ b/storage/innobase/os/os0file.cc @@ -3233,7 +3233,7 @@ os_file_set_nocache( /** Check if the file system supports sparse files. @param fh file handle @return true if the file system supports sparse files */ -IF_WIN(static,) bool os_is_sparse_file_supported(os_file_t fh) +static bool os_is_sparse_file_supported(os_file_t fh) { #ifdef _WIN32 FILE_ATTRIBUTE_TAG_INFO info; @@ -3495,24 +3495,23 @@ dberr_t IORequest::punch_hole(os_offset_t off, ulint len) const /* Check does file system support punching holes for this tablespace. */ - if (!node->space->punch_hole) { + if (!node->punch_hole) { return DB_IO_NO_PUNCH_HOLE; } dberr_t err = os_file_punch_hole(node->handle, off, trim_len); - if (err == DB_SUCCESS) { + switch (err) { + case DB_SUCCESS: srv_stats.page_compressed_trim_op.inc(); - } else { - /* If punch hole is not supported, - set space so that it is not used. */ - if (err == DB_IO_NO_PUNCH_HOLE) { - node->space->punch_hole = false; - err = DB_SUCCESS; - } + return err; + case DB_IO_NO_PUNCH_HOLE: + node->punch_hole = false; + err = DB_SUCCESS; + /* fall through */ + default: + return err; } - - return (err); } /** This function returns information about the specified file @@ -4101,81 +4100,56 @@ static bool is_file_on_ssd(char *file_path) #endif -/** Determine some file metadata when creating or reading the file. -@param file the file that is being created, or OS_FILE_CLOSED */ void fil_node_t::find_metadata(os_file_t file #ifndef _WIN32 - , struct stat* statbuf + , bool create, struct stat *statbuf #endif - ) + ) { - if (file == OS_FILE_CLOSED) { - file = handle; - ut_ad(is_open()); - } + if (!is_open()) + { + handle= file; + ut_ad(is_open()); + } -#ifdef _WIN32 /* FIXME: make this unconditional */ - if (space->punch_hole) { - space->punch_hole = os_is_sparse_file_supported(file); - } -#endif + if (!space->is_compressed()) + punch_hole= 0; + else if (my_test_if_thinly_provisioned(file)) + punch_hole= 2; + else + punch_hole= IF_WIN(, !create ||) os_is_sparse_file_supported(file); - /* - For the temporary tablespace and during the - non-redo-logged adjustments in - IMPORT TABLESPACE, we do not care about - the atomicity of writes. - - Atomic writes is supported if the file can be used - with atomic_writes (not log file), O_DIRECT is - used (tested in ha_innodb.cc) and the file is - device and file system that supports atomic writes - for the given block size. - */ - space->atomic_write_supported = space->purpose == FIL_TYPE_TEMPORARY - || space->purpose == FIL_TYPE_IMPORT; #ifdef _WIN32 - on_ssd = is_file_on_ssd(name); - FILE_STORAGE_INFO info; - if (GetFileInformationByHandleEx( - file, FileStorageInfo, &info, sizeof(info))) { - block_size = info.PhysicalBytesPerSectorForAtomicity; - } else { - block_size = 512; - } + on_ssd= is_file_on_ssd(name); + FILE_STORAGE_INFO info; + if (GetFileInformationByHandleEx(file, FileStorageInfo, &info, sizeof info)) + block_size= info.PhysicalBytesPerSectorForAtomicity; + else + block_size= 512; #else - struct stat sbuf; - if (!statbuf && !fstat(file, &sbuf)) { - statbuf = &sbuf; - } - if (statbuf) { - block_size = statbuf->st_blksize; - } - on_ssd = space->atomic_write_supported + struct stat sbuf; + if (!statbuf && !fstat(file, &sbuf)) + statbuf= &sbuf; + if (statbuf) + block_size= statbuf->st_blksize; # ifdef UNIV_LINUX - || (statbuf && fil_system.is_ssd(statbuf->st_dev)) + on_ssd= statbuf && fil_system.is_ssd(statbuf->st_dev); # endif - ; #endif - if (!space->atomic_write_supported) { - space->atomic_write_supported = atomic_write - && srv_use_atomic_writes -#ifndef _WIN32 - && my_test_if_atomic_write(file, - space->physical_size()) -#else - /* On Windows, all single sector writes are atomic, - as per WriteFile() documentation on MSDN. - We also require SSD for atomic writes, eventhough - technically it is not necessary- the reason is that - on hard disks, we still want the benefit from - (non-atomic) neighbor page flushing in the buffer - pool code. */ - && srv_page_size == block_size - && on_ssd -#endif - ; - } + + if (space->purpose != FIL_TYPE_TABLESPACE) + { + /* For temporary tablespace or during IMPORT TABLESPACE, we + disable neighbour flushing and do not care about atomicity. */ + on_ssd= true; + atomic_write= true; + } + else + /* On Windows, all single sector writes are atomic, as per + WriteFile() documentation on MSDN. */ + atomic_write= srv_use_atomic_writes && + IF_WIN(srv_page_size == block_size, + my_test_if_atomic_write(file, space->physical_size())); } /** Read the first page of a data file. @@ -4270,20 +4244,16 @@ invalid: space->free_len= free_len; } -#ifdef UNIV_LINUX - find_metadata(handle, &statbuf); -#else - find_metadata(); -#endif + IF_WIN(find_metadata(), find_metadata(handle, false, &statbuf)); /* Truncate the size to a multiple of extent size. */ ulint mask= psize * FSP_EXTENT_SIZE - 1; if (size_bytes <= mask); /* .ibd files start smaller than an extent size. Do not truncate valid data. */ - else size_bytes &= ~os_offset_t(mask); + else + size_bytes&= ~os_offset_t(mask); - space->punch_hole= space->is_compressed(); this->size= uint32_t(size_bytes / psize); space->set_sizes(this->size); return true; diff --git a/storage/innobase/row/row0import.cc b/storage/innobase/row/row0import.cc index 00016761c91..b2638c6fea2 100644 --- a/storage/innobase/row/row0import.cc +++ b/storage/innobase/row/row0import.cc @@ -3436,7 +3436,7 @@ fil_iterate( required by buf_zip_decompress() */ dberr_t err = DB_SUCCESS; bool page_compressed = false; - bool punch_hole = true; + bool punch_hole = !my_test_if_thinly_provisioned(iter.file); for (offset = iter.start; offset < iter.end; offset += n_bytes) { if (callback.is_interrupted()) { From 4b0070f642eb20472991de3a201378534f6f1bd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 29 Jun 2021 15:20:16 +0300 Subject: [PATCH 199/251] MDEV-26029: Implement my_test_if_thinly_provisioned() for ScaleFlux This is based on code that was contributed by Ning Zheng and Ray Kuan from ScaleFlux. --- include/my_sys.h | 3 +- mysys/my_atomic_writes.c | 121 +++++++++++++++++++++++++++++++++------ 2 files changed, 104 insertions(+), 20 deletions(-) diff --git a/include/my_sys.h b/include/my_sys.h index fccff539fa9..63703c4cb16 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -183,11 +183,12 @@ extern BOOL my_obtain_privilege(LPCSTR lpPrivilege); #endif void my_init_atomic_write(void); -#define my_test_if_thinly_provisioned(A) 0 #ifdef __linux__ my_bool my_test_if_atomic_write(File handle, int pagesize); +my_bool my_test_if_thinly_provisioned(File handle); #else # define my_test_if_atomic_write(A, B) 0 +# define my_test_if_thinly_provisioned(A) 0 #endif /* __linux__ */ extern my_bool my_may_have_atomic_write; diff --git a/mysys/my_atomic_writes.c b/mysys/my_atomic_writes.c index cfd7dbb3cbf..42ee4e690cd 100644 --- a/mysys/my_atomic_writes.c +++ b/mysys/my_atomic_writes.c @@ -19,8 +19,9 @@ my_bool my_may_have_atomic_write= IF_WIN(1,0); #ifdef __linux__ -my_bool has_shannon_atomic_write= 0, has_fusion_io_atomic_write= 0, - has_sfx_atomic_write= 0; +my_bool has_shannon_atomic_write, has_fusion_io_atomic_write, + has_sfx_atomic_write; +my_bool has_sfx_card; #include @@ -225,7 +226,7 @@ static my_bool shannon_dev_has_atomic_write(struct shannon_dev *dev, @return TRUE Atomic write supported @notes - This is called only at first open of a file. In this case it's doesn't + This is called only at first open of a file. In this case it doesn't matter so much that we loop over all cards. We update the atomic size on first access. */ @@ -264,15 +265,26 @@ static my_bool shannon_has_atomic_write(File file, int page_size) ScaleFlux ************************************************************************/ -#define SFX_GET_ATOMIC_SIZE _IO('N', 0x244) -#define SFX_MAX_DEVICES 32 -#define SFX_NO_ATOMIC_SIZE_YET -2 +#define SFX_GET_ATOMIC_SIZE _IOR('N', 0x243, int) +#define SFX_MAX_DEVICES (32) +#define SFX_UNKNOWN_ATOMIC_WRITE_YET (-2) +#define SFX_MAX_ATOMIC_SIZE (256 * 1024) + +#define SFX_GET_SPACE_RATIO _IO('N', 0x244) +#define SFX_UNKNOWN_PUNCH_HOLE_YET (-3) + +/** + Threshold for logical_space / physical_space + No less than the threshold means we can disable hole punching +*/ +#define SFX_DISABLE_PUNCH_HOLE_RATIO (2) struct sfx_dev { char dev_name[32]; dev_t st_dev; - int atomic_size; + int atomic_write; + int disable_punch_hole; }; static struct sfx_dev sfx_devices[SFX_MAX_DEVICES + 1]; @@ -280,7 +292,8 @@ static struct sfx_dev sfx_devices[SFX_MAX_DEVICES + 1]; /** Check if the system has a ScaleFlux card If card exists, record device numbers to allow us to later check if - a given file is on this device. + a given file is on this device + Variables for atomic_write and disable_punch_hole will be initialized @return TRUE Card exists */ @@ -303,38 +316,41 @@ static my_bool test_if_sfx_card_exists() The atomic size will be checked on first access. This is needed as a normal user can't open the /dev/sfdvXn1 file */ - sfx_devices[sfx_found_devices].atomic_size = SFX_NO_ATOMIC_SIZE_YET; + sfx_devices[sfx_found_devices].atomic_write= SFX_UNKNOWN_ATOMIC_WRITE_YET; + sfx_devices[sfx_found_devices].disable_punch_hole= + SFX_UNKNOWN_PUNCH_HOLE_YET; if (++sfx_found_devices == SFX_MAX_DEVICES) goto end; } end: sfx_devices[sfx_found_devices].st_dev= 0; + has_sfx_card = (sfx_found_devices > 0); + return sfx_found_devices > 0; } static my_bool sfx_dev_has_atomic_write(struct sfx_dev *dev, int page_size) { - if (dev->atomic_size == SFX_NO_ATOMIC_SIZE_YET) + int result= -1, max_atomic_size= SFX_MAX_ATOMIC_SIZE; + + if (dev->atomic_write == SFX_UNKNOWN_ATOMIC_WRITE_YET) { int fd= open(dev->dev_name, 0); if (fd < 0) - { fprintf(stderr, "Unable to determine if atomic writes are supported:" " open(\"%s\"): %m\n", dev->dev_name); - dev->atomic_size= 0; /* Don't try again */ - } else { - dev->atomic_size= ioctl(fd, SFX_GET_ATOMIC_SIZE); + result= ioctl(fd, SFX_GET_ATOMIC_SIZE, &max_atomic_size); close(fd); } + dev->atomic_write= result == 0 && page_size <= max_atomic_size; } - return (page_size <= dev->atomic_size); + return dev->atomic_write; } - /** Check if a file is on a ScaleFlux device and that it supports atomic_write @param[in] file OS file handle @@ -342,7 +358,7 @@ static my_bool sfx_dev_has_atomic_write(struct sfx_dev *dev, @return TRUE Atomic write supported @notes - This is called only at first open of a file. In this case it's doesn't + This is called only at first open of a file. In this case it doesn't matter so much that we loop over all cards. We update the atomic size on first access. */ @@ -358,12 +374,63 @@ static my_bool sfx_has_atomic_write(File file, int page_size) return sfx_dev_has_atomic_write(dev, page_size); return 0; } + +static my_bool sfx_dev_could_disable_punch_hole(struct sfx_dev *dev, File file) +{ + int result = 0; + + if (dev->disable_punch_hole == SFX_UNKNOWN_PUNCH_HOLE_YET) + { + int fd= open(dev->dev_name, 0); + if (fd < 0) + { + fprintf(stderr, "Unable to determine if thin provisioning is used:" + " open(\"%s\"): %m\n", dev->dev_name); + dev->disable_punch_hole= 0; /* Don't try again */ + return FALSE; + } + + /* + Ratio left-shifts 8 (multiplies 256) inside the ioctl; + will also add 1 to guarantee a round-up integer. + */ + result= ioctl(fd, SFX_GET_SPACE_RATIO); + result+= 1; + dev->disable_punch_hole= (result >= (((double)SFX_DISABLE_PUNCH_HOLE_RATIO) * 256)); + } + + return dev->disable_punch_hole; +} + +/** + Check if a file is on a ScaleFlux device and whether it is possible to + disable hole punch. + @param[in] file OS file handle + @return TRUE Could disable hole punch + + @notes + This is called only at first open of a file. In this case it's doesn't + matter so much that we loop over all cards +*/ + +static my_bool sfx_could_disable_punch_hole(File file) +{ + struct sfx_dev *dev; + struct stat stat_buff; + + if (fstat(file, &stat_buff) == 0) + for (dev = sfx_devices; dev->st_dev; dev++) + if (SAME_DEV(stat_buff.st_dev, dev->st_dev)) + return sfx_dev_could_disable_punch_hole(dev, file); + return 0; +} + /*********************************************************************** Generic atomic write code ************************************************************************/ -/* - Initialize automic write sub systems. +/** + Initialize the atomic write subsystem. Checks if we have any devices that supports atomic write */ @@ -418,6 +485,22 @@ my_bool my_test_if_atomic_write(File handle, int page_size) return 0; } + +/** + Check if a file resides on thinly provisioned storage. + + @return FALSE File cannot disable hole punch + TRUE File could disable hole punch +*/ + +my_bool my_test_if_thinly_provisioned(File handle) +{ + if (has_sfx_card && sfx_could_disable_punch_hole(handle)) + return 1; + + return 0; +} + #ifdef TEST_SHANNON int main() { From e04bbf73dc372917cbcdaa965fdc69e8b575d75f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 28 Jun 2021 17:10:09 +0300 Subject: [PATCH 200/251] MDEV-25496 Assertion 'trx->bulk_insert' failed on INSERT row_get_prebuilt_insert_row(): Remove some fallback code that had been added in commit 8ea923f55b7666a359ac2c54f6c10e8609d16846 (MDEV-24818). It seems that after all, statement boundaries are being reliably indicated by ha_innobase::start_stmt() or (for partitioned tables) ha_innobase::external_lock(). --- mysql-test/suite/innodb/r/insert_into_empty.result | 8 ++++++++ mysql-test/suite/innodb/t/insert_into_empty.test | 10 ++++++++++ storage/innobase/row/row0mysql.cc | 7 ------- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/mysql-test/suite/innodb/r/insert_into_empty.result b/mysql-test/suite/innodb/r/insert_into_empty.result index c92778f5a4c..b35b508fa7f 100644 --- a/mysql-test/suite/innodb/r/insert_into_empty.result +++ b/mysql-test/suite/innodb/r/insert_into_empty.result @@ -174,3 +174,11 @@ COMMIT; SET autocommit=1; DROP TABLE t1; DROP TEMPORARY TABLE t0; +# +# MDEV-25496 Assertion 'trx->bulk_insert' failed +# in trx_undo_report_row_operation on INSERT +# +CREATE TABLE t (i INT) ENGINE=InnoDB PARTITION BY HASH (i) PARTITIONS 2; +INSERT INTO t VALUES (0); +INSERT INTO t VALUES (1),(0),(1); +DROP TABLE t; diff --git a/mysql-test/suite/innodb/t/insert_into_empty.test b/mysql-test/suite/innodb/t/insert_into_empty.test index 87da67dc0c5..8b885cb5b4f 100644 --- a/mysql-test/suite/innodb/t/insert_into_empty.test +++ b/mysql-test/suite/innodb/t/insert_into_empty.test @@ -1,6 +1,7 @@ --source include/have_innodb.inc --source include/have_sequence.inc --source include/maybe_debug.inc +--source include/have_partition.inc # Enable MDEV-515 table-level undo logging for insert into empty table SET foreign_key_checks=0, unique_checks=0; @@ -183,3 +184,12 @@ COMMIT; SET autocommit=1; DROP TABLE t1; DROP TEMPORARY TABLE t0; + +--echo # +--echo # MDEV-25496 Assertion 'trx->bulk_insert' failed +--echo # in trx_undo_report_row_operation on INSERT +--echo # +CREATE TABLE t (i INT) ENGINE=InnoDB PARTITION BY HASH (i) PARTITIONS 2; +INSERT INTO t VALUES (0); +INSERT INTO t VALUES (1),(0),(1); +DROP TABLE t; diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc index 4adc279fb32..bb85e82cbb8 100644 --- a/storage/innobase/row/row0mysql.cc +++ b/storage/innobase/row/row0mysql.cc @@ -1051,13 +1051,6 @@ row_get_prebuilt_insert_row( if (prebuilt->trx_id == table->def_trx_id && prebuilt->ins_node->entry_list.size() == UT_LIST_GET_LEN(table->indexes)) { - - if (prebuilt->trx->bulk_insert - && prebuilt->ins_node->trx_id - != prebuilt->trx->id) { - prebuilt->trx->bulk_insert = false; - } - return(prebuilt->ins_node->row); } From 0237e9bb65a9a70303bd59c3febc4e738df1b72a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 29 Jun 2021 13:39:42 +0300 Subject: [PATCH 201/251] MDEV-26041 Recovery failure due to delete-marked SYS_FIELDS record trx_t::drop_table(): Delete-mark the SYS_TABLES and SYS_INDEXES record before delete-marking any SYS_COLUMNS or SYS_FIELDS records. Otherwise, dict_load_indexes() could fail on recovery. This fixes up commit 1bd681c8b3c5213ce1f7976940a7dc38b48a0d39 (MDEV-25506). --- storage/innobase/dict/drop.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/storage/innobase/dict/drop.cc b/storage/innobase/dict/drop.cc index ff8e108b26d..6d9e892fc73 100644 --- a/storage/innobase/dict/drop.cc +++ b/storage/innobase/dict/drop.cc @@ -205,18 +205,19 @@ dberr_t trx_t::drop_table(const dict_table_t &table) "WHERE TABLE_ID=:id FOR UPDATE;\n" "BEGIN\n" + + "DELETE FROM SYS_TABLES WHERE ID=:id;\n" + "DELETE FROM SYS_COLUMNS WHERE TABLE_ID=:id;\n" + "OPEN idx;\n" "WHILE 1 = 1 LOOP\n" " FETCH idx INTO iid;\n" " IF (SQL % NOTFOUND) THEN EXIT; END IF;\n" - " DELETE FROM SYS_FIELDS WHERE INDEX_ID=iid;\n" " DELETE FROM SYS_INDEXES WHERE CURRENT OF idx;\n" + " DELETE FROM SYS_FIELDS WHERE INDEX_ID=iid;\n" "END LOOP;\n" "CLOSE idx;\n" - "DELETE FROM SYS_COLUMNS WHERE TABLE_ID=:id;\n" - "DELETE FROM SYS_TABLES WHERE ID=:id;\n" - "END;\n", FALSE, this); } From c2ebe8147d72f62ee10ec0a0815971ebd21aa8ff Mon Sep 17 00:00:00 2001 From: Alexey Botchkov Date: Tue, 29 Jun 2021 16:03:26 +0400 Subject: [PATCH 202/251] MDEV-25837 Assertion `thd->locked_tables_mode == LTM_NONE' failed in Locked_tables_list::init_locked_tables. don't do prelocking for the FLUSH command. --- mysql-test/main/flush.result | 11 +++++++++++ mysql-test/main/flush.test | 13 +++++++++++++ sql/sql_base.cc | 3 ++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/mysql-test/main/flush.result b/mysql-test/main/flush.result index 941dc63e3da..c73125e3420 100644 --- a/mysql-test/main/flush.result +++ b/mysql-test/main/flush.result @@ -606,6 +606,17 @@ drop view v1, v2; drop table t1; disconnect con1; # +# MDEV-25837 Assertion `thd->locked_tables_mode == LTM_NONE' failed in Locked_tables_list::init_locked_tables. +# +CREATE FUNCTION f() RETURNS INTEGER RETURN 1; +CREATE TABLE t (a INT); +CREATE VIEW v AS SELECT 2 FROM t WHERE f() < 3; +FLUSH TABLE v WITH READ LOCK; +UNLOCK TABLES; +DROP VIEW v; +DROP FUNCTION f; +DROP TABLE t; +# # Test FLUSH THREADS # set @save_thread_cache_size=@@global.thread_cache_size; diff --git a/mysql-test/main/flush.test b/mysql-test/main/flush.test index 97830238b0e..f546b6f1fca 100644 --- a/mysql-test/main/flush.test +++ b/mysql-test/main/flush.test @@ -722,6 +722,19 @@ drop view v1, v2; drop table t1; disconnect con1; +--echo # +--echo # MDEV-25837 Assertion `thd->locked_tables_mode == LTM_NONE' failed in Locked_tables_list::init_locked_tables. +--echo # + +CREATE FUNCTION f() RETURNS INTEGER RETURN 1; +CREATE TABLE t (a INT); +CREATE VIEW v AS SELECT 2 FROM t WHERE f() < 3; +FLUSH TABLE v WITH READ LOCK; + +UNLOCK TABLES; +DROP VIEW v; +DROP FUNCTION f; +DROP TABLE t; --echo # --echo # Test FLUSH THREADS diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 51e4bcad16b..e46a8587503 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -5553,7 +5553,8 @@ bool lock_tables(THD *thd, TABLE_LIST *tables, uint count, uint flags) DEBUG_SYNC(thd, "after_lock_tables_takes_lock"); if (thd->lex->requires_prelocking() && - thd->lex->sql_command != SQLCOM_LOCK_TABLES) + thd->lex->sql_command != SQLCOM_LOCK_TABLES && + thd->lex->sql_command != SQLCOM_FLUSH) { /* We just have done implicit LOCK TABLES, and now we have From 617dee34886987c53b14e09a9ee73abe923a18e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 29 Jun 2021 15:04:27 +0300 Subject: [PATCH 203/251] MDEV-26042 Atomic write capability is not detected correctly my_init_atomic_write(): Detect all forms of SSD, in case multiple types of devices are installed in the same machine. This was broken in commit ed008a74cf4cfe8619595ec71a6073a9e94f984c and further in commit 70684afef2ce6d797f78db192c4472260cd22660. SAME_DEV(): Match block devices, ignoring partition numbers. Let us use stat() instead of lstat(), in case someone has a symbolic link in /dev. Instead of reporting errors with perror(), let us use fprintf(stderr) with the file name, the impact of the error, and the strerror(errno). Because this code is specific to Linux, we may depend on the GNU libc/uClibc/musl extension %m for strerror(errno). --- mysys/my_atomic_writes.c | 61 +++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/mysys/my_atomic_writes.c b/mysys/my_atomic_writes.c index 34207a6fd07..cfd7dbb3cbf 100644 --- a/mysys/my_atomic_writes.c +++ b/mysys/my_atomic_writes.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2016, MariaDB Corporation +/* Copyright (c) 2016, 2021, 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 @@ -24,6 +24,10 @@ my_bool has_shannon_atomic_write= 0, has_fusion_io_atomic_write= 0, #include +/* Linux seems to allow up to 15 partitions per block device. +Partition number 0 is the whole block device. */ +# define SAME_DEV(fs_dev, blk_dev) \ + (fs_dev == blk_dev) || ((fs_dev & ~15U) == blk_dev) /*********************************************************************** FUSION_IO @@ -115,9 +119,9 @@ static my_bool test_if_shannon_card_exists() sprintf(path, "/dev/df%c", dev_part); #ifdef TEST_SHANNON - if (lstat(path, &stat_buff) < 0) + if (stat(path, &stat_buff) < 0) { - printf("%s(): lstat failed.\n", __func__); + printf("%s(): stat %s failed.\n", __func__, path); break; } #endif @@ -147,7 +151,7 @@ static my_bool test_if_shannon_card_exists() for (dev_no= 1 ; dev_no < 9 ; dev_no++) { sprintf(path, "/dev/df%c%d", dev_part, dev_no); - if (lstat(path, &stat_buff) < 0) + if (stat(path, &stat_buff) < 0) break; shannon_devices[shannon_found_devices].st_dev= stat_buff.st_rdev; @@ -194,12 +198,13 @@ static my_bool shannon_dev_has_atomic_write(struct shannon_dev *dev, int fd= open(dev->dev_name, 0); if (fd < 0) { - perror("open() failed!"); + fprintf(stderr, "Unable to determine if atomic writes are supported:" + " open(\"%s\"): %m\n", dev->dev_name); dev->atomic_size= 0; /* Don't try again */ return FALSE; } - dev->atomic_size= ioctl(fd, SHANNON_IOCQATOMIC_SIZE); - close(fd); + dev->atomic_size= ioctl(fd, SHANNON_IOCQATOMIC_SIZE); + close(fd); } #ifdef TEST_SHANNON @@ -248,7 +253,7 @@ static my_bool shannon_has_atomic_write(File file, int page_size) #ifdef TEST_SHANNON printf("%s(): st_rdev=0x%lx\n", __func__, (ulong) dev->st_dev); #endif - if (stat_buff.st_dev == dev->st_dev) + if (SAME_DEV(stat_buff.st_dev, dev->st_dev)) return shannon_dev_has_atomic_write(dev, page_size); } return 0; @@ -290,8 +295,7 @@ static my_bool test_if_sfx_card_exists() sprintf(sfx_devices[sfx_found_devices].dev_name, "/dev/sfdv%dn1", dev_num); - if (lstat(sfx_devices[sfx_found_devices].dev_name, - &stat_buff) < 0) + if (stat(sfx_devices[sfx_found_devices].dev_name, &stat_buff) < 0) break; sfx_devices[sfx_found_devices].st_dev= stat_buff.st_rdev; @@ -316,13 +320,15 @@ static my_bool sfx_dev_has_atomic_write(struct sfx_dev *dev, int fd= open(dev->dev_name, 0); if (fd < 0) { - perror("open() failed!"); + fprintf(stderr, "Unable to determine if atomic writes are supported:" + " open(\"%s\"): %m\n", dev->dev_name); dev->atomic_size= 0; /* Don't try again */ - return FALSE; } - - dev->atomic_size= ioctl(fd, SFX_GET_ATOMIC_SIZE); - close(fd); + else + { + dev->atomic_size= ioctl(fd, SFX_GET_ATOMIC_SIZE); + close(fd); + } } return (page_size <= dev->atomic_size); @@ -346,16 +352,10 @@ static my_bool sfx_has_atomic_write(File file, int page_size) struct sfx_dev *dev; struct stat stat_buff; - if (fstat(file, &stat_buff) < 0) - { - return 0; - } - - for (dev = sfx_devices; dev->st_dev; dev++) - { - if (stat_buff.st_dev == dev->st_dev) - return sfx_dev_has_atomic_write(dev, page_size); - } + if (fstat(file, &stat_buff) == 0) + for (dev= sfx_devices; dev->st_dev; dev++) + if (SAME_DEV(stat_buff.st_dev, dev->st_dev)) + return sfx_dev_has_atomic_write(dev, page_size); return 0; } /*********************************************************************** @@ -369,10 +369,13 @@ static my_bool sfx_has_atomic_write(File file, int page_size) void my_init_atomic_write(void) { - if ((has_shannon_atomic_write= test_if_shannon_card_exists()) || - (has_fusion_io_atomic_write= test_if_fusion_io_card_exists()) || - (has_sfx_atomic_write= test_if_sfx_card_exists())) - my_may_have_atomic_write= 1; + has_shannon_atomic_write= test_if_shannon_card_exists(); + has_fusion_io_atomic_write= test_if_fusion_io_card_exists(); + has_sfx_atomic_write= test_if_sfx_card_exists(); + + my_may_have_atomic_write= has_shannon_atomic_write || + has_fusion_io_atomic_write || has_sfx_atomic_write; + #ifdef TEST_SHANNON printf("%s(): has_shannon_atomic_write=%d, my_may_have_atomic_write=%d\n", __func__, From 768c51880a5aa6d25d4c0fe7de7a88561ff46422 Mon Sep 17 00:00:00 2001 From: "xing-zhi, jiang" Date: Thu, 24 Jun 2021 14:16:11 +0300 Subject: [PATCH 204/251] MDEV-25129 Add KEYWORDS view to the INFORMATION_SCHEMA Add KEYWORDS table and SQL_FUNCTIONS table to INFORMATION_SCHEMA. This commits needs some minor changes when propagated upwards (e.g. func_array in item_create.cc has a termination element that doesn't exist in later versions of MariaDB) --- .gitignore | 2 + mysql-test/r/information_schema.result | 2 + .../r/information_schema_all_engines.result | 12 ++- .../suite/funcs_1/r/is_columns_is.result | 4 + .../funcs_1/r/is_columns_is_embedded.result | 4 + .../suite/funcs_1/r/is_tables_is.result | 92 +++++++++++++++++++ .../funcs_1/r/is_tables_is_embedded.result | 92 +++++++++++++++++++ sql/handler.h | 2 + sql/item_create.cc | 11 +-- sql/item_create.h | 6 ++ sql/lex.h | 7 +- sql/sql_show.cc | 83 +++++++++++++++++ 12 files changed, 306 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 00754884d3d..dc8f6940fdf 100644 --- a/.gitignore +++ b/.gitignore @@ -517,3 +517,5 @@ compile_commands.json # Visual Studio Code workspace .vscode/ + +.cache/clangd diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index 1594ebf75e0..c7153bd6383 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -65,6 +65,7 @@ GEOMETRY_COLUMNS GLOBAL_STATUS GLOBAL_VARIABLES INDEX_STATISTICS +KEYWORDS KEY_CACHES KEY_COLUMN_USAGE PARAMETERS @@ -79,6 +80,7 @@ SCHEMA_PRIVILEGES SESSION_STATUS SESSION_VARIABLES SPATIAL_REF_SYS +SQL_FUNCTIONS STATISTICS SYSTEM_VARIABLES TABLES diff --git a/mysql-test/r/information_schema_all_engines.result b/mysql-test/r/information_schema_all_engines.result index 0ce9f15f753..542299ca5c1 100644 --- a/mysql-test/r/information_schema_all_engines.result +++ b/mysql-test/r/information_schema_all_engines.result @@ -41,6 +41,7 @@ INNODB_SYS_VIRTUAL INNODB_TABLESPACES_ENCRYPTION INNODB_TABLESPACES_SCRUBBING INNODB_TRX +KEYWORDS KEY_CACHES KEY_COLUMN_USAGE PARAMETERS @@ -55,6 +56,7 @@ SCHEMA_PRIVILEGES SESSION_STATUS SESSION_VARIABLES SPATIAL_REF_SYS +SQL_FUNCTIONS STATISTICS SYSTEM_VARIABLES TABLES @@ -121,6 +123,7 @@ INNODB_SYS_VIRTUAL TABLE_ID INNODB_TABLESPACES_ENCRYPTION SPACE INNODB_TABLESPACES_SCRUBBING SPACE INNODB_TRX trx_id +KEYWORDS WORD KEY_CACHES KEY_CACHE_NAME KEY_COLUMN_USAGE CONSTRAINT_SCHEMA PARAMETERS SPECIFIC_SCHEMA @@ -135,6 +138,7 @@ SCHEMA_PRIVILEGES TABLE_SCHEMA SESSION_STATUS VARIABLE_NAME SESSION_VARIABLES VARIABLE_NAME SPATIAL_REF_SYS SRID +SQL_FUNCTIONS FUNCTION STATISTICS TABLE_SCHEMA SYSTEM_VARIABLES VARIABLE_NAME TABLES TABLE_SCHEMA @@ -201,6 +205,7 @@ INNODB_SYS_VIRTUAL TABLE_ID INNODB_TABLESPACES_ENCRYPTION SPACE INNODB_TABLESPACES_SCRUBBING SPACE INNODB_TRX trx_id +KEYWORDS WORD KEY_CACHES KEY_CACHE_NAME KEY_COLUMN_USAGE CONSTRAINT_SCHEMA PARAMETERS SPECIFIC_SCHEMA @@ -215,6 +220,7 @@ SCHEMA_PRIVILEGES TABLE_SCHEMA SESSION_STATUS VARIABLE_NAME SESSION_VARIABLES VARIABLE_NAME SPATIAL_REF_SYS SRID +SQL_FUNCTIONS FUNCTION STATISTICS TABLE_SCHEMA SYSTEM_VARIABLES VARIABLE_NAME TABLES TABLE_SCHEMA @@ -356,6 +362,7 @@ Database: information_schema | INNODB_TABLESPACES_ENCRYPTION | | INNODB_TABLESPACES_SCRUBBING | | INNODB_TRX | +| KEYWORDS | | KEY_CACHES | | KEY_COLUMN_USAGE | | PARAMETERS | @@ -370,6 +377,7 @@ Database: information_schema | SESSION_STATUS | | SESSION_VARIABLES | | SPATIAL_REF_SYS | +| SQL_FUNCTIONS | | STATISTICS | | SYSTEM_VARIABLES | | TABLES | @@ -426,6 +434,7 @@ Database: INFORMATION_SCHEMA | INNODB_TABLESPACES_ENCRYPTION | | INNODB_TABLESPACES_SCRUBBING | | INNODB_TRX | +| KEYWORDS | | KEY_CACHES | | KEY_COLUMN_USAGE | | PARAMETERS | @@ -440,6 +449,7 @@ Database: INFORMATION_SCHEMA | SESSION_STATUS | | SESSION_VARIABLES | | SPATIAL_REF_SYS | +| SQL_FUNCTIONS | | STATISTICS | | SYSTEM_VARIABLES | | TABLES | @@ -459,5 +469,5 @@ Wildcard: inf_rmation_schema | information_schema | SELECT table_schema, count(*) FROM information_schema.TABLES WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test', 'mysqltest') GROUP BY TABLE_SCHEMA; table_schema count(*) -information_schema 65 +information_schema 67 mysql 30 diff --git a/mysql-test/suite/funcs_1/r/is_columns_is.result b/mysql-test/suite/funcs_1/r/is_columns_is.result index 672c8e0810a..3282d30669e 100644 --- a/mysql-test/suite/funcs_1/r/is_columns_is.result +++ b/mysql-test/suite/funcs_1/r/is_columns_is.result @@ -181,6 +181,7 @@ def information_schema INDEX_STATISTICS INDEX_NAME 3 '' NO varchar 192 576 NULL def information_schema INDEX_STATISTICS ROWS_READ 4 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select NEVER NULL def information_schema INDEX_STATISTICS TABLE_NAME 2 '' NO varchar 192 576 NULL NULL NULL utf8 utf8_general_ci varchar(192) select NEVER NULL def information_schema INDEX_STATISTICS TABLE_SCHEMA 1 '' NO varchar 192 576 NULL NULL NULL utf8 utf8_general_ci varchar(192) select NEVER NULL +def information_schema KEYWORDS WORD 1 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select NEVER NULL def information_schema KEY_CACHES BLOCK_SIZE 5 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select NEVER NULL def information_schema KEY_CACHES DIRTY_BLOCKS 8 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select NEVER NULL def information_schema KEY_CACHES FULL_SIZE 4 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select NEVER NULL @@ -336,6 +337,7 @@ def information_schema SPATIAL_REF_SYS AUTH_NAME 2 '' NO varchar 512 1536 NULL N def information_schema SPATIAL_REF_SYS AUTH_SRID 3 0 NO int NULL NULL 10 0 NULL NULL NULL int(5) select NEVER NULL def information_schema SPATIAL_REF_SYS SRID 1 0 NO smallint NULL NULL 5 0 NULL NULL NULL smallint(5) select NEVER NULL def information_schema SPATIAL_REF_SYS SRTEXT 4 '' NO varchar 2048 6144 NULL NULL NULL utf8 utf8_general_ci varchar(2048) select NEVER NULL +def information_schema SQL_FUNCTIONS FUNCTION 1 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select NEVER NULL def information_schema STATISTICS CARDINALITY 10 NULL YES bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select NEVER NULL def information_schema STATISTICS COLLATION 9 NULL YES varchar 1 3 NULL NULL NULL utf8 utf8_general_ci varchar(1) select NEVER NULL def information_schema STATISTICS COLUMN_NAME 8 '' NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) select NEVER NULL @@ -716,6 +718,7 @@ NULL information_schema GEOMETRY_COLUMNS SRID smallint NULL NULL NULL NULL small 3.0000 information_schema INDEX_STATISTICS TABLE_NAME varchar 192 576 utf8 utf8_general_ci varchar(192) 3.0000 information_schema INDEX_STATISTICS INDEX_NAME varchar 192 576 utf8 utf8_general_ci varchar(192) NULL information_schema INDEX_STATISTICS ROWS_READ bigint NULL NULL NULL NULL bigint(21) +3.0000 information_schema KEYWORDS WORD varchar 64 192 utf8 utf8_general_ci varchar(64) 3.0000 information_schema KEY_CACHES KEY_CACHE_NAME varchar 192 576 utf8 utf8_general_ci varchar(192) NULL information_schema KEY_CACHES SEGMENTS int NULL NULL NULL NULL int(3) unsigned NULL information_schema KEY_CACHES SEGMENT_NUMBER int NULL NULL NULL NULL int(3) unsigned @@ -871,6 +874,7 @@ NULL information_schema SPATIAL_REF_SYS SRID smallint NULL NULL NULL NULL smalli 3.0000 information_schema SPATIAL_REF_SYS AUTH_NAME varchar 512 1536 utf8 utf8_general_ci varchar(512) NULL information_schema SPATIAL_REF_SYS AUTH_SRID int NULL NULL NULL NULL int(5) 3.0000 information_schema SPATIAL_REF_SYS SRTEXT varchar 2048 6144 utf8 utf8_general_ci varchar(2048) +3.0000 information_schema SQL_FUNCTIONS FUNCTION varchar 64 192 utf8 utf8_general_ci varchar(64) 3.0000 information_schema STATISTICS TABLE_CATALOG varchar 512 1536 utf8 utf8_general_ci varchar(512) 3.0000 information_schema STATISTICS TABLE_SCHEMA varchar 64 192 utf8 utf8_general_ci varchar(64) 3.0000 information_schema STATISTICS TABLE_NAME varchar 64 192 utf8 utf8_general_ci varchar(64) diff --git a/mysql-test/suite/funcs_1/r/is_columns_is_embedded.result b/mysql-test/suite/funcs_1/r/is_columns_is_embedded.result index 85026160b41..9116830e88c 100644 --- a/mysql-test/suite/funcs_1/r/is_columns_is_embedded.result +++ b/mysql-test/suite/funcs_1/r/is_columns_is_embedded.result @@ -181,6 +181,7 @@ def information_schema INDEX_STATISTICS INDEX_NAME 3 '' NO varchar 192 576 NULL def information_schema INDEX_STATISTICS ROWS_READ 4 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) NEVER NULL def information_schema INDEX_STATISTICS TABLE_NAME 2 '' NO varchar 192 576 NULL NULL NULL utf8 utf8_general_ci varchar(192) NEVER NULL def information_schema INDEX_STATISTICS TABLE_SCHEMA 1 '' NO varchar 192 576 NULL NULL NULL utf8 utf8_general_ci varchar(192) NEVER NULL +def information_schema KEYWORDS WORD 1 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) NEVER NULL def information_schema KEY_CACHES BLOCK_SIZE 5 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned NEVER NULL def information_schema KEY_CACHES DIRTY_BLOCKS 8 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned NEVER NULL def information_schema KEY_CACHES FULL_SIZE 4 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned NEVER NULL @@ -336,6 +337,7 @@ def information_schema SPATIAL_REF_SYS AUTH_NAME 2 '' NO varchar 512 1536 NULL N def information_schema SPATIAL_REF_SYS AUTH_SRID 3 0 NO int NULL NULL 10 0 NULL NULL NULL int(5) NEVER NULL def information_schema SPATIAL_REF_SYS SRID 1 0 NO smallint NULL NULL 5 0 NULL NULL NULL smallint(5) NEVER NULL def information_schema SPATIAL_REF_SYS SRTEXT 4 '' NO varchar 2048 6144 NULL NULL NULL utf8 utf8_general_ci varchar(2048) NEVER NULL +def information_schema SQL_FUNCTIONS FUNCTION 1 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) NEVER NULL def information_schema STATISTICS CARDINALITY 10 NULL YES bigint NULL NULL 19 0 NULL NULL NULL bigint(21) NEVER NULL def information_schema STATISTICS COLLATION 9 NULL YES varchar 1 3 NULL NULL NULL utf8 utf8_general_ci varchar(1) NEVER NULL def information_schema STATISTICS COLUMN_NAME 8 '' NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(64) NEVER NULL @@ -716,6 +718,7 @@ NULL information_schema GEOMETRY_COLUMNS SRID smallint NULL NULL NULL NULL small 3.0000 information_schema INDEX_STATISTICS TABLE_NAME varchar 192 576 utf8 utf8_general_ci varchar(192) 3.0000 information_schema INDEX_STATISTICS INDEX_NAME varchar 192 576 utf8 utf8_general_ci varchar(192) NULL information_schema INDEX_STATISTICS ROWS_READ bigint NULL NULL NULL NULL bigint(21) +3.0000 information_schema KEYWORDS WORD varchar 64 192 utf8 utf8_general_ci varchar(64) 3.0000 information_schema KEY_CACHES KEY_CACHE_NAME varchar 192 576 utf8 utf8_general_ci varchar(192) NULL information_schema KEY_CACHES SEGMENTS int NULL NULL NULL NULL int(3) unsigned NULL information_schema KEY_CACHES SEGMENT_NUMBER int NULL NULL NULL NULL int(3) unsigned @@ -871,6 +874,7 @@ NULL information_schema SPATIAL_REF_SYS SRID smallint NULL NULL NULL NULL smalli 3.0000 information_schema SPATIAL_REF_SYS AUTH_NAME varchar 512 1536 utf8 utf8_general_ci varchar(512) NULL information_schema SPATIAL_REF_SYS AUTH_SRID int NULL NULL NULL NULL int(5) 3.0000 information_schema SPATIAL_REF_SYS SRTEXT varchar 2048 6144 utf8 utf8_general_ci varchar(2048) +3.0000 information_schema SQL_FUNCTIONS FUNCTION varchar 64 192 utf8 utf8_general_ci varchar(64) 3.0000 information_schema STATISTICS TABLE_CATALOG varchar 512 1536 utf8 utf8_general_ci varchar(512) 3.0000 information_schema STATISTICS TABLE_SCHEMA varchar 64 192 utf8 utf8_general_ci varchar(64) 3.0000 information_schema STATISTICS TABLE_NAME varchar 64 192 utf8 utf8_general_ci varchar(64) diff --git a/mysql-test/suite/funcs_1/r/is_tables_is.result b/mysql-test/suite/funcs_1/r/is_tables_is.result index 502b165cde3..aca57297574 100644 --- a/mysql-test/suite/funcs_1/r/is_tables_is.result +++ b/mysql-test/suite/funcs_1/r/is_tables_is.result @@ -405,6 +405,29 @@ user_comment Separator ----------------------------------------------------- TABLE_CATALOG def TABLE_SCHEMA information_schema +TABLE_NAME KEYWORDS +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 11 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG def +TABLE_SCHEMA information_schema TABLE_NAME KEY_CACHES TABLE_TYPE SYSTEM VIEW ENGINE MEMORY @@ -704,6 +727,29 @@ user_comment Separator ----------------------------------------------------- TABLE_CATALOG def TABLE_SCHEMA information_schema +TABLE_NAME SQL_FUNCTIONS +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 11 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG def +TABLE_SCHEMA information_schema TABLE_NAME STATISTICS TABLE_TYPE SYSTEM VIEW ENGINE MEMORY @@ -1364,6 +1410,29 @@ user_comment Separator ----------------------------------------------------- TABLE_CATALOG def TABLE_SCHEMA information_schema +TABLE_NAME KEYWORDS +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 11 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG def +TABLE_SCHEMA information_schema TABLE_NAME KEY_CACHES TABLE_TYPE SYSTEM VIEW ENGINE MEMORY @@ -1663,6 +1732,29 @@ user_comment Separator ----------------------------------------------------- TABLE_CATALOG def TABLE_SCHEMA information_schema +TABLE_NAME SQL_FUNCTIONS +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 11 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG def +TABLE_SCHEMA information_schema TABLE_NAME STATISTICS TABLE_TYPE SYSTEM VIEW ENGINE MEMORY diff --git a/mysql-test/suite/funcs_1/r/is_tables_is_embedded.result b/mysql-test/suite/funcs_1/r/is_tables_is_embedded.result index 502b165cde3..aca57297574 100644 --- a/mysql-test/suite/funcs_1/r/is_tables_is_embedded.result +++ b/mysql-test/suite/funcs_1/r/is_tables_is_embedded.result @@ -405,6 +405,29 @@ user_comment Separator ----------------------------------------------------- TABLE_CATALOG def TABLE_SCHEMA information_schema +TABLE_NAME KEYWORDS +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 11 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG def +TABLE_SCHEMA information_schema TABLE_NAME KEY_CACHES TABLE_TYPE SYSTEM VIEW ENGINE MEMORY @@ -704,6 +727,29 @@ user_comment Separator ----------------------------------------------------- TABLE_CATALOG def TABLE_SCHEMA information_schema +TABLE_NAME SQL_FUNCTIONS +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 11 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG def +TABLE_SCHEMA information_schema TABLE_NAME STATISTICS TABLE_TYPE SYSTEM VIEW ENGINE MEMORY @@ -1364,6 +1410,29 @@ user_comment Separator ----------------------------------------------------- TABLE_CATALOG def TABLE_SCHEMA information_schema +TABLE_NAME KEYWORDS +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 11 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG def +TABLE_SCHEMA information_schema TABLE_NAME KEY_CACHES TABLE_TYPE SYSTEM VIEW ENGINE MEMORY @@ -1663,6 +1732,29 @@ user_comment Separator ----------------------------------------------------- TABLE_CATALOG def TABLE_SCHEMA information_schema +TABLE_NAME SQL_FUNCTIONS +TABLE_TYPE SYSTEM VIEW +ENGINE MEMORY +VERSION 11 +ROW_FORMAT Fixed +TABLE_ROWS #TBLR# +AVG_ROW_LENGTH #ARL# +DATA_LENGTH #DL# +MAX_DATA_LENGTH #MDL# +INDEX_LENGTH #IL# +DATA_FREE #DF# +AUTO_INCREMENT NULL +CREATE_TIME #CRT# +UPDATE_TIME #UT# +CHECK_TIME #CT# +TABLE_COLLATION utf8_general_ci +CHECKSUM NULL +CREATE_OPTIONS #CO# +TABLE_COMMENT #TC# +user_comment +Separator ----------------------------------------------------- +TABLE_CATALOG def +TABLE_SCHEMA information_schema TABLE_NAME STATISTICS TABLE_TYPE SYSTEM VIEW ENGINE MEMORY diff --git a/sql/handler.h b/sql/handler.h index b3617d7a47a..542b91c570d 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -741,6 +741,7 @@ enum enum_schema_tables SCH_FILES, SCH_GLOBAL_STATUS, SCH_GLOBAL_VARIABLES, + SCH_KEYWORDS, SCH_KEY_CACHES, SCH_KEY_COLUMN_USAGE, SCH_OPEN_TABLES, @@ -756,6 +757,7 @@ enum enum_schema_tables SCH_SESSION_STATUS, SCH_SESSION_VARIABLES, SCH_STATISTICS, + SCH_SQL_FUNCTIONS, SCH_SYSTEM_VARIABLES, SCH_TABLES, SCH_TABLESPACES, diff --git a/sql/item_create.cc b/sql/item_create.cc index 4bfb2615fbe..a3c51d1949e 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -6745,13 +6745,6 @@ Create_func_year_week::create_native(THD *thd, LEX_STRING name, return func; } - -struct Native_func_registry -{ - LEX_STRING name; - Create_func *builder; -}; - #define BUILDER(F) & F::s_singleton #ifdef HAVE_SPATIAL @@ -6771,7 +6764,7 @@ struct Native_func_registry - keep 1 line per entry, it makes grep | sort easier */ -static Native_func_registry func_array[] = +Native_func_registry func_array[] = { { { C_STRING_WITH_LEN("ABS") }, BUILDER(Create_func_abs)}, { { C_STRING_WITH_LEN("ACOS") }, BUILDER(Create_func_acos)}, @@ -7113,6 +7106,8 @@ static Native_func_registry func_array[] = { {0, 0}, NULL} }; +size_t func_array_length= sizeof(func_array) / sizeof(Native_func_registry) - 1; + static HASH native_functions_hash; extern "C" uchar* diff --git a/sql/item_create.h b/sql/item_create.h index 97dc594b11c..3ce731e2d69 100644 --- a/sql/item_create.h +++ b/sql/item_create.h @@ -183,6 +183,12 @@ Item *create_temporal_literal(THD *thd, const String *str, type, send_error); } +struct Native_func_registry +{ + LEX_STRING name; + Create_func *builder; +}; + int item_create_init(); void item_create_cleanup(); diff --git a/sql/lex.h b/sql/lex.h index ca7c6635329..c0cb9adc236 100644 --- a/sql/lex.h +++ b/sql/lex.h @@ -45,7 +45,7 @@ SYM_GROUP sym_group_rtree= {"RTree keys", "HAVE_RTREE_KEYS"}; lists */ -static SYMBOL symbols[] = { +SYMBOL symbols[] = { { "&&", SYM(AND_AND_SYM)}, { "<=", SYM(LE)}, { "<>", SYM(NE)}, @@ -687,7 +687,7 @@ static SYMBOL symbols[] = { }; -static SYMBOL sql_functions[] = { +SYMBOL sql_functions[] = { { "ADDDATE", SYM(ADDDATE_SYM)}, { "BIT_AND", SYM(BIT_AND)}, { "BIT_OR", SYM(BIT_OR)}, @@ -732,4 +732,7 @@ static SYMBOL sql_functions[] = { { "VAR_SAMP", SYM(VAR_SAMP_SYM)}, }; +size_t symbols_length= sizeof(symbols) / sizeof(SYMBOL); +size_t sql_functions_length= sizeof(sql_functions) / sizeof(SYMBOL); + #endif /* LEX_INCLUDED */ diff --git a/sql/sql_show.cc b/sql/sql_show.cc index b5622497a06..f8f784bbbad 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -62,6 +62,19 @@ #ifdef WITH_PARTITION_STORAGE_ENGINE #include "ha_partition.h" #endif + +#include "lex_symbol.h" +#define KEYWORD_SIZE 64 + +extern SYMBOL symbols[]; +extern size_t symbols_length; + +extern SYMBOL sql_functions[]; +extern size_t sql_functions_length; + +extern Native_func_registry func_array[]; +extern size_t func_array_length; + enum enum_i_s_events_fields { ISE_EVENT_CATALOG= 0, @@ -7556,6 +7569,60 @@ int fill_variables(THD *thd, TABLE_LIST *tables, COND *cond) DBUG_RETURN(res); } +int add_symbol_to_table(const char* name, TABLE* table){ + DBUG_ENTER("add_symbol_to_table"); + + uint length= strlen(name); + + // If you've added a new SQL keyword longer than KEYWORD_SIZE, + // please increase the defined max length + DBUG_ASSERT(length < KEYWORD_SIZE); + + restore_record(table, s->default_values); + table->field[0]->set_notnull(); + table->field[0]->store(name, length, + system_charset_info); + if (schema_table_store_record(table->in_use, table)) + DBUG_RETURN(1); + + DBUG_RETURN(0); +} + +int fill_i_s_keywords(THD *thd, TABLE_LIST *tables, COND *cond) +{ + DBUG_ENTER("fill_i_s_keywords"); + + TABLE *table= tables->table; + + for (uint i= 0; i < symbols_length; i++){ + const char *name= symbols[i].name; + if (add_symbol_to_table(name, table)) + DBUG_RETURN(1); + } + + DBUG_RETURN(0); +} + +int fill_i_s_sql_functions(THD *thd, TABLE_LIST *tables, COND *cond) { + DBUG_ENTER("fill_i_s_sql_functions"); + + TABLE *table= tables->table; + + for (uint i= 0; i < sql_functions_length; i++){ + const char *name= sql_functions[i].name; + if (add_symbol_to_table(name, table)) + DBUG_RETURN(1); + } + + for (uint i= 0; i < func_array_length; i++){ + const char *name= func_array[i].name.str; + if (add_symbol_to_table(name, table)) + DBUG_RETURN(1); + } + + DBUG_RETURN(0); +} + int fill_status(THD *thd, TABLE_LIST *tables, COND *cond) { @@ -8763,6 +8830,18 @@ ST_FIELD_INFO enabled_roles_fields_info[]= {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} }; +ST_FIELD_INFO keywords_field_info[]= +{ + {"WORD", KEYWORD_SIZE, MYSQL_TYPE_STRING, 0, MY_I_S_MAYBE_NULL, 0, SKIP_OPEN_TABLE}, + {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} +}; + +ST_FIELD_INFO sql_functions_field_info[]= +{ + {"FUNCTION", KEYWORD_SIZE, MYSQL_TYPE_STRING, 0, MY_I_S_MAYBE_NULL, 0, SKIP_OPEN_TABLE}, + {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} +}; + ST_FIELD_INFO engines_fields_info[]= { @@ -9465,6 +9544,8 @@ ST_SCHEMA_TABLE schema_tables[]= fill_status, make_old_format, 0, 0, -1, 0, 0}, {"GLOBAL_VARIABLES", variables_fields_info, 0, fill_variables, make_old_format, 0, 0, -1, 0, 0}, + {"KEYWORDS", keywords_field_info, 0, + fill_i_s_keywords, 0, 0, -1, -1, 0, 0}, {"KEY_CACHES", keycache_fields_info, 0, fill_key_cache_tables, 0, 0, -1,-1, 0, 0}, {"KEY_COLUMN_USAGE", key_column_usage_fields_info, 0, @@ -9500,6 +9581,8 @@ ST_SCHEMA_TABLE schema_tables[]= {"STATISTICS", stat_fields_info, 0, get_all_tables, make_old_format, get_schema_stat_record, 1, 2, 0, OPEN_TABLE_ONLY|OPTIMIZE_I_S_TABLE}, + {"SQL_FUNCTIONS", sql_functions_field_info, 0, + fill_i_s_sql_functions, 0, 0, -1, -1, 0, 0}, {"SYSTEM_VARIABLES", sysvars_fields_info, 0, fill_sysvars, make_old_format, 0, 0, -1, 0, 0}, {"TABLES", tables_fields_info, 0, From ff9150f3c50f3cb3ab89bcce8dd3e28b5d390625 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 30 Jun 2021 09:00:52 +0300 Subject: [PATCH 205/251] MDEV-25942: Assertion failure in trx_t::drop_table() trx_t::drop_table(): Relax also another assertion that would fail due to an AUTO_INCREMENT lock that is being held by the current test case. This should have been part of commit 63e9a05440953bf451ebe1cd808ca445e4c7634e. --- .../innodb/r/lock_insert_into_empty.result | 15 +++++++++++++++ .../innodb/t/lock_insert_into_empty.test | 19 +++++++++++++++++++ storage/innobase/dict/drop.cc | 12 +++++++++--- 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/mysql-test/suite/innodb/r/lock_insert_into_empty.result b/mysql-test/suite/innodb/r/lock_insert_into_empty.result index 7f4baf67fda..b5e7ecf6311 100644 --- a/mysql-test/suite/innodb/r/lock_insert_into_empty.result +++ b/mysql-test/suite/innodb/r/lock_insert_into_empty.result @@ -37,3 +37,18 @@ REPLACE INTO t1 VALUES (1,12); ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t1`, CONSTRAINT `t1_ibfk_1` FOREIGN KEY (`f`) REFERENCES `nonexistent` (`x`)) COMMIT; DROP TABLE t1; +# +# MDEV-25942 Assertion failed in trx_t::drop_table() +# +CREATE TABLE t1 (k INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 SET k=1; +START TRANSACTION; +INSERT INTO t1 SET k=2; +connect con1,localhost,root,,test; +SET innodb_lock_wait_timeout= 1; +CREATE TABLE t2 (pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=InnoDB +AS SELECT k FROM t1; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +disconnect con1; +connection default; +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/lock_insert_into_empty.test b/mysql-test/suite/innodb/t/lock_insert_into_empty.test index 03a9b1c9626..cc2b169a52e 100644 --- a/mysql-test/suite/innodb/t/lock_insert_into_empty.test +++ b/mysql-test/suite/innodb/t/lock_insert_into_empty.test @@ -39,3 +39,22 @@ REPLACE INTO t1 VALUES (1,12); COMMIT; DROP TABLE t1; + +--echo # +--echo # MDEV-25942 Assertion failed in trx_t::drop_table() +--echo # + +CREATE TABLE t1 (k INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 SET k=1; +START TRANSACTION; +INSERT INTO t1 SET k=2; + +--connect (con1,localhost,root,,test) +SET innodb_lock_wait_timeout= 1; +--error ER_LOCK_WAIT_TIMEOUT +CREATE TABLE t2 (pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=InnoDB +AS SELECT k FROM t1; +--disconnect con1 +--connection default + +DROP TABLE t1; diff --git a/storage/innobase/dict/drop.cc b/storage/innobase/dict/drop.cc index 6d9e892fc73..b2aab6992bb 100644 --- a/storage/innobase/dict/drop.cc +++ b/storage/innobase/dict/drop.cc @@ -159,10 +159,16 @@ dberr_t trx_t::drop_table(const dict_table_t &table) lock= UT_LIST_GET_NEXT(un_member.tab_lock.locks, lock)) { ut_ad(lock->trx == this); - if (lock->type_mode == (LOCK_X | LOCK_TABLE)) + switch (lock->type_mode) { + case LOCK_TABLE | LOCK_X: found_x= true; - else - ut_ad(lock->type_mode == (LOCK_IX | LOCK_TABLE)); + break; + case LOCK_TABLE | LOCK_IX: + case LOCK_TABLE | LOCK_AUTO_INC: + break; + default: + ut_ad("unexpected lock type" == 0); + } } ut_ad(found_x); #endif From fa5c314377e9ec2fc8168adab6af6717d05819dc Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 28 Jun 2021 10:31:55 +0200 Subject: [PATCH 206/251] fix spider tests for --ps in 10.6 see also c3a1ba0fd99, 068246c006b, 690ae1de459 --- .../mysql-test/spider/bg/t/basic_sql.test | 180 +++++++++--------- .../spider/bg/t/basic_sql_part.test | 44 ++--- .../spider/bg/t/direct_aggregate.test | 2 +- .../spider/bg/t/direct_aggregate_part.test | 4 +- .../mysql-test/spider/bg/t/direct_update.test | 2 +- .../spider/bg/t/direct_update_part.test | 4 +- .../mysql-test/spider/bg/t/function.test | 4 +- storage/spider/mysql-test/spider/bg/t/ha.test | 20 +- .../mysql-test/spider/bg/t/ha_part.test | 34 ++-- .../mysql-test/spider/bg/t/spider3_fixes.test | 4 +- .../spider/bg/t/spider3_fixes_part.test | 6 +- .../mysql-test/spider/bg/t/spider_fixes.test | 48 ++--- .../spider/bg/t/spider_fixes_part.test | 30 +-- .../mysql-test/spider/bg/t/vp_fixes.test | 4 +- .../checksum_table_with_quick_mode_3_init.inc | 2 +- .../bugfix/include/cp932_column_init.inc | 2 +- .../include/delete_with_float_column_init.inc | 2 +- .../include/group_by_order_by_limit_init.inc | 4 +- .../bugfix/include/insert_select_init.inc | 2 +- .../spider/bugfix/include/mdev_19866_init.inc | 4 +- .../spider/bugfix/include/mdev_20100_init.inc | 2 +- .../spider/bugfix/include/mdev_20502_init.inc | 2 +- .../spider/bugfix/include/mdev_21884_init.inc | 2 +- .../bugfix/include/quick_mode_0_init.inc | 4 +- .../bugfix/include/quick_mode_1_init.inc | 4 +- .../bugfix/include/quick_mode_2_init.inc | 4 +- .../bugfix/include/quick_mode_3_init.inc | 4 +- .../include/return_found_rows_insert_init.inc | 2 +- .../include/return_found_rows_update_init.inc | 2 +- .../bugfix/include/select_by_null_init.inc | 2 +- .../include/select_with_backquote_init.inc | 2 +- .../include/slave_trx_isolation_init.inc | 2 +- .../spider/bugfix/include/sql_mode_init.inc | 2 +- .../bugfix/include/strict_group_by_init.inc | 4 +- .../bugfix/include/wait_timeout_init.inc | 4 +- .../bugfix/include/wrapper_mariadb_init.inc | 2 +- .../spider/bugfix/include/xa_cmd_init.inc | 2 +- .../r/checksum_table_with_quick_mode_3.result | 4 +- .../spider/bugfix/r/cp932_column.result | 4 +- .../r/delete_with_float_column_default.result | 4 +- .../r/delete_with_float_column_mariadb.result | 4 +- .../r/delete_with_float_column_mysql.result | 4 +- .../bugfix/r/group_by_order_by_limit.result | 8 +- .../spider/bugfix/r/insert_select.result | 4 +- .../spider/bugfix/r/mdev_19866.result | 8 +- .../spider/bugfix/r/mdev_20100.result | 4 +- .../spider/bugfix/r/mdev_20502.result | 4 +- .../spider/bugfix/r/mdev_21884.result | 4 +- .../spider/bugfix/r/quick_mode_0.result | 24 +-- .../spider/bugfix/r/quick_mode_1.result | 24 +-- .../spider/bugfix/r/quick_mode_2.result | 24 +-- .../spider/bugfix/r/quick_mode_3.result | 24 +-- .../bugfix/r/return_found_rows_insert.result | 12 +- .../bugfix/r/return_found_rows_update.result | 4 +- .../spider/bugfix/r/select_by_null.result | 4 +- .../bugfix/r/select_with_backquote.result | 4 +- .../bugfix/r/slave_trx_isolation.result | 4 +- .../spider/bugfix/r/sql_mode_mariadb.result | 4 +- .../spider/bugfix/r/sql_mode_mysql.result | 4 +- .../spider/bugfix/r/strict_group_by.result | 8 +- .../spider/bugfix/r/wait_timeout.result | 8 +- .../spider/bugfix/r/wrapper_mariadb.result | 4 +- .../mysql-test/spider/bugfix/r/xa_cmd.result | 4 +- .../include/checksum_table_parallel_init.inc | 4 +- .../r/checksum_table_parallel_extended.result | 8 +- .../r/checksum_table_parallel_no_opt.result | 8 +- .../r/checksum_table_parallel_quick.result | 8 +- .../spider/handler/t/basic_sql.test | 180 +++++++++--------- .../spider/handler/t/basic_sql_part.test | 44 ++--- .../spider/handler/t/direct_aggregate.test | 2 +- .../handler/t/direct_aggregate_part.test | 4 +- .../spider/handler/t/direct_update.test | 2 +- .../spider/handler/t/direct_update_part.test | 4 +- .../mysql-test/spider/handler/t/function.test | 4 +- .../mysql-test/spider/handler/t/ha.test | 20 +- .../mysql-test/spider/handler/t/ha_part.test | 34 ++-- .../spider/handler/t/spider3_fixes.test | 4 +- .../spider/handler/t/spider3_fixes_part.test | 6 +- .../spider/handler/t/spider_fixes.test | 48 ++--- .../spider/handler/t/spider_fixes_part.test | 30 +-- .../mysql-test/spider/handler/t/vp_fixes.test | 4 +- .../checksum_table_with_quick_mode_3_init.inc | 2 +- .../spider/include/direct_join_init.inc | 2 +- .../spider/include/direct_join_using_init.inc | 2 +- .../spider/include/direct_left_join_init.inc | 2 +- .../direct_left_join_nullable_init.inc | 2 +- .../direct_left_right_join_nullable_init.inc | 2 +- ...ect_left_right_left_join_nullable_init.inc | 2 +- .../spider/include/direct_right_join_init.inc | 2 +- .../direct_right_join_nullable_init.inc | 2 +- .../direct_right_left_join_nullable_init.inc | 2 +- ...ct_right_left_right_join_nullable_init.inc | 2 +- .../include/partition_cond_push_init.inc | 6 +- .../include/partition_fulltext_init.inc | 6 +- ...oin_pushdown_for_single_partition_init.inc | 6 +- .../spider/include/partition_mrr_init.inc | 6 +- .../spider/include/quick_mode_0_init.inc | 4 +- .../spider/include/quick_mode_1_init.inc | 4 +- .../spider/include/quick_mode_2_init.inc | 4 +- .../spider/include/quick_mode_3_init.inc | 4 +- .../include/slave_trx_isolation_init.inc | 2 +- .../mysql-test/spider/oracle/t/basic_sql.test | 180 +++++++++--------- .../spider/oracle/t/basic_sql_part.test | 44 ++--- .../spider/oracle/t/direct_aggregate.test | 2 +- .../oracle/t/direct_aggregate_part.test | 4 +- .../spider/oracle/t/direct_update.test | 2 +- .../spider/oracle/t/direct_update_part.test | 4 +- .../mysql-test/spider/oracle/t/function.test | 4 +- .../spider/mysql-test/spider/oracle/t/ha.test | 20 +- .../mysql-test/spider/oracle/t/ha_part.test | 34 ++-- .../spider/oracle/t/spider3_fixes.test | 2 +- .../spider/oracle/t/spider3_fixes_part.test | 4 +- .../spider/oracle/t/spider_fixes.test | 46 ++--- .../spider/oracle/t/spider_fixes_part.test | 28 +-- .../mysql-test/spider/oracle/t/vp_fixes.test | 4 +- .../spider/oracle2/t/basic_sql.test | 180 +++++++++--------- .../spider/oracle2/t/basic_sql_part.test | 44 ++--- .../spider/oracle2/t/direct_aggregate.test | 2 +- .../oracle2/t/direct_aggregate_part.test | 4 +- .../spider/oracle2/t/direct_update.test | 2 +- .../spider/oracle2/t/direct_update_part.test | 4 +- .../mysql-test/spider/oracle2/t/function.test | 4 +- .../mysql-test/spider/oracle2/t/ha.test | 20 +- .../mysql-test/spider/oracle2/t/ha_part.test | 34 ++-- .../spider/oracle2/t/spider3_fixes.test | 2 +- .../spider/oracle2/t/spider3_fixes_part.test | 4 +- .../spider/oracle2/t/spider_fixes.test | 46 ++--- .../spider/oracle2/t/spider_fixes_part.test | 28 +-- .../mysql-test/spider/oracle2/t/vp_fixes.test | 4 +- .../mysql-test/spider/r/auto_increment.result | 4 +- .../r/checksum_table_with_quick_mode_3.result | 4 +- .../mysql-test/spider/r/direct_join.result | 8 +- .../spider/r/direct_join_using.result | 4 +- .../spider/r/direct_left_join.result | 4 +- .../spider/r/direct_left_join_nullable.result | 4 +- .../r/direct_left_right_join_nullable.result | 4 +- ...irect_left_right_left_join_nullable.result | 4 +- .../spider/r/direct_right_join.result | 4 +- .../r/direct_right_join_nullable.result | 4 +- .../r/direct_right_left_join_nullable.result | 4 +- ...rect_right_left_right_join_nullable.result | 4 +- .../spider/r/partition_cond_push.result | 12 +- .../spider/r/partition_fulltext.result | 12 +- ..._join_pushdown_for_single_partition.result | 12 +- .../mysql-test/spider/r/partition_mrr.result | 12 +- .../spider/r/pushdown_not_like.result | 4 +- .../mysql-test/spider/r/quick_mode_0.result | 24 +-- .../mysql-test/spider/r/quick_mode_1.result | 24 +-- .../mysql-test/spider/r/quick_mode_2.result | 24 +-- .../mysql-test/spider/r/quick_mode_3.result | 24 +-- .../spider/r/slave_trx_isolation.result | 4 +- .../mysql-test/spider/r/timestamp.result | 28 +-- .../include/direct_join_by_pkey_key_init.inc | 4 +- .../include/direct_join_by_pkey_pkey_init.inc | 4 +- .../e1121/include/load_data_init.inc | 2 +- .../e1121/r/direct_join_by_pkey_key.result | 12 +- .../e1121/r/direct_join_by_pkey_pkey.result | 12 +- .../regression/e1121/r/load_data_ddi0.result | 4 +- .../regression/e1121/r/load_data_ddi1.result | 4 +- .../e1121/r/load_data_ignore_ddi0.result | 4 +- .../e1121/r/load_data_ignore_ddi1.result | 4 +- .../e1121/r/load_data_local_ddi0.result | 4 +- .../e1121/r/load_data_local_ddi1.result | 4 +- .../r/load_data_local_ignore_ddi0.result | 4 +- .../r/load_data_local_ignore_ddi1.result | 4 +- .../r/load_data_local_replace_ddi0.result | 4 +- .../r/load_data_local_replace_ddi1.result | 4 +- .../e1121/r/load_data_replace_ddi0.result | 4 +- .../e1121/r/load_data_replace_ddi1.result | 4 +- .../group_by_order_by_limit_ok_init.inc | 4 +- .../e112122/include/load_data_part_init.inc | 4 +- .../r/group_by_order_by_limit_ok.result | 8 +- .../e112122/r/load_data_part_ddi0.result | 8 +- .../e112122/r/load_data_part_ddi1.result | 8 +- .../r/load_data_part_ignore_ddi0.result | 8 +- .../r/load_data_part_ignore_ddi1.result | 8 +- .../r/load_data_part_local_ddi0.result | 8 +- .../r/load_data_part_local_ddi1.result | 8 +- .../r/load_data_part_local_ignore_ddi0.result | 8 +- .../r/load_data_part_local_ignore_ddi1.result | 8 +- .../load_data_part_local_replace_ddi0.result | 8 +- .../load_data_part_local_replace_ddi1.result | 8 +- .../r/load_data_part_replace_ddi0.result | 8 +- .../r/load_data_part_replace_ddi1.result | 8 +- .../spider/t/auto_increment_init.inc | 2 +- .../spider/mysql-test/spider/t/basic_sql.test | 180 +++++++++--------- .../mysql-test/spider/t/basic_sql_part.test | 44 ++--- .../mysql-test/spider/t/direct_aggregate.test | 2 +- .../spider/t/direct_aggregate_part.test | 4 +- .../mysql-test/spider/t/direct_update.test | 2 +- .../spider/t/direct_update_part.test | 4 +- .../spider/mysql-test/spider/t/function.test | 4 +- storage/spider/mysql-test/spider/t/ha.test | 20 +- .../spider/mysql-test/spider/t/ha_part.test | 34 ++-- .../spider/t/pushdown_not_like.test | 2 +- .../mysql-test/spider/t/spider3_fixes.test | 4 +- .../spider/t/spider3_fixes_part.test | 6 +- .../mysql-test/spider/t/spider_fixes.test | 48 ++--- .../spider/t/spider_fixes_part.test | 36 ++-- .../mysql-test/spider/t/timestamp_init.inc | 2 +- .../spider/mysql-test/spider/t/vp_fixes.test | 4 +- 201 files changed, 1369 insertions(+), 1345 deletions(-) diff --git a/storage/spider/mysql-test/spider/bg/t/basic_sql.test b/storage/spider/mysql-test/spider/bg/t/basic_sql.test index 5bb040047fc..9cf4ce99dc3 100644 --- a/storage/spider/mysql-test/spider/bg/t/basic_sql.test +++ b/storage/spider/mysql-test/spider/bg/t/basic_sql.test @@ -146,7 +146,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -241,7 +241,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -315,7 +315,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%replace %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%replace %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -416,7 +416,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_TABLES3; if (!$OUTPUT_CHILD_GROUP2) @@ -460,7 +460,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -502,7 +502,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -544,7 +544,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -586,7 +586,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -628,7 +628,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -670,7 +670,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -712,7 +712,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -754,7 +754,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -796,7 +796,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -838,7 +838,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -880,7 +880,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -924,7 +924,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -966,7 +966,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -1007,7 +1007,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -1049,7 +1049,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -1091,7 +1091,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -1133,7 +1133,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -1176,7 +1176,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1222,7 +1222,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1269,7 +1269,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1315,7 +1315,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1362,7 +1362,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1406,7 +1406,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1453,10 +1453,10 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1501,10 +1501,10 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1551,10 +1551,10 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'replace %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'replace %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1598,10 +1598,10 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'replace %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'replace %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1646,10 +1646,10 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'replace %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'replace %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1694,10 +1694,10 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'replace %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'replace %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1744,8 +1744,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1790,8 +1790,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1836,8 +1836,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1881,8 +1881,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1927,8 +1927,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1972,8 +1972,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2017,8 +2017,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2062,8 +2062,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2107,8 +2107,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2159,8 +2159,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2204,8 +2204,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2256,8 +2256,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2308,8 +2308,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2360,8 +2360,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2412,8 +2412,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2464,8 +2464,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2516,8 +2516,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2568,8 +2568,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2620,8 +2620,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2665,7 +2665,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE 'truncate %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'truncate %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/bg/t/basic_sql_part.test b/storage/spider/mysql-test/spider/bg/t/basic_sql_part.test index e1638642ab7..1bb18358d5d 100644 --- a/storage/spider/mysql-test/spider/bg/t/basic_sql_part.test +++ b/storage/spider/mysql-test/spider/bg/t/basic_sql_part.test @@ -176,13 +176,13 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_TABLES2; if (!$OUTPUT_CHILD_GROUP2) @@ -235,12 +235,12 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -290,12 +290,12 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -344,15 +344,15 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES2; if (!$OUTPUT_CHILD_GROUP2) @@ -404,15 +404,15 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES2; if (!$OUTPUT_CHILD_GROUP2) @@ -466,15 +466,15 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES2; if (!$OUTPUT_CHILD_GROUP2) @@ -528,15 +528,15 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES2; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/bg/t/direct_aggregate.test b/storage/spider/mysql-test/spider/bg/t/direct_aggregate.test index d65f4c5a624..5c0c37f483d 100644 --- a/storage/spider/mysql-test/spider/bg/t/direct_aggregate.test +++ b/storage/spider/mysql-test/spider/bg/t/direct_aggregate.test @@ -147,7 +147,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%handler %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/bg/t/direct_aggregate_part.test b/storage/spider/mysql-test/spider/bg/t/direct_aggregate_part.test index aebf210c745..cb0b55e9788 100644 --- a/storage/spider/mysql-test/spider/bg/t/direct_aggregate_part.test +++ b/storage/spider/mysql-test/spider/bg/t/direct_aggregate_part.test @@ -153,13 +153,13 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%handler %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%handler %'; } eval $CHILD2_1_SELECT_TABLES2; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/bg/t/direct_update.test b/storage/spider/mysql-test/spider/bg/t/direct_update.test index e0901062201..94f27e2859c 100644 --- a/storage/spider/mysql-test/spider/bg/t/direct_update.test +++ b/storage/spider/mysql-test/spider/bg/t/direct_update.test @@ -166,7 +166,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%handler %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/bg/t/direct_update_part.test b/storage/spider/mysql-test/spider/bg/t/direct_update_part.test index 95e2e2ab0d5..e8f1882594c 100644 --- a/storage/spider/mysql-test/spider/bg/t/direct_update_part.test +++ b/storage/spider/mysql-test/spider/bg/t/direct_update_part.test @@ -172,13 +172,13 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%handler %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%handler %'; } eval $CHILD2_1_SELECT_TABLES2; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/bg/t/function.test b/storage/spider/mysql-test/spider/bg/t/function.test index ec2eeab9c94..2472e774782 100644 --- a/storage/spider/mysql-test/spider/bg/t/function.test +++ b/storage/spider/mysql-test/spider/bg/t/function.test @@ -125,7 +125,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TEXT_PK_TABLES1; if (!$OUTPUT_CHILD_GROUP2) @@ -219,7 +219,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/bg/t/ha.test b/storage/spider/mysql-test/spider/bg/t/ha.test index c12930e4aed..c36b7363a6d 100644 --- a/storage/spider/mysql-test/spider/bg/t/ha.test +++ b/storage/spider/mysql-test/spider/bg/t/ha.test @@ -233,13 +233,13 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -303,7 +303,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -435,13 +435,13 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -623,13 +623,13 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -693,7 +693,7 @@ if ($USE_CHILD_GROUP2) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -799,13 +799,13 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/bg/t/ha_part.test b/storage/spider/mysql-test/spider/bg/t/ha_part.test index 72ddcfd1f10..33fe9850b68 100644 --- a/storage/spider/mysql-test/spider/bg/t/ha_part.test +++ b/storage/spider/mysql-test/spider/bg/t/ha_part.test @@ -274,20 +274,20 @@ if ($HAVE_PARTITION) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; eval $CHILD2_1_SELECT_TABLES2; --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_3 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_3_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -356,14 +356,14 @@ if ($HAVE_PARTITION) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; eval $CHILD2_1_SELECT_TABLES2; --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -501,20 +501,20 @@ if ($HAVE_PARTITION) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; eval $CHILD2_1_SELECT_TABLES2; --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_3 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_3_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -723,20 +723,20 @@ if ($HAVE_PARTITION) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; eval $CHILD2_1_SELECT_TABLES2; --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_3 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_3_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -809,19 +809,19 @@ if ($HAVE_PARTITION) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_3 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_3_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -933,20 +933,20 @@ if ($HAVE_PARTITION) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; eval $CHILD2_1_SELECT_TABLES2; --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_3 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_3_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/bg/t/spider3_fixes.test b/storage/spider/mysql-test/spider/bg/t/spider3_fixes.test index 13fa6f5fa39..64d3b657ae8 100644 --- a/storage/spider/mysql-test/spider/bg/t/spider3_fixes.test +++ b/storage/spider/mysql-test/spider/bg/t/spider3_fixes.test @@ -129,8 +129,10 @@ eval CREATE TABLE t2 ( id int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (id) ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_1; +--disable_ps_protocol eval $MASTER_1_AUTO_INCREMENT_INCREMENT2; eval $MASTER_1_AUTO_INCREMENT_OFFSET2; +--enable_ps_protocol if ($USE_REPLICATION) { SET SESSION sql_log_bin= 1; @@ -241,7 +243,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_INCREMENT_TABLES1; if ($OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/bg/t/spider3_fixes_part.test b/storage/spider/mysql-test/spider/bg/t/spider3_fixes_part.test index 3288c490a46..bcd85f42b81 100644 --- a/storage/spider/mysql-test/spider/bg/t/spider3_fixes_part.test +++ b/storage/spider/mysql-test/spider/bg/t/spider3_fixes_part.test @@ -163,8 +163,10 @@ if ($HAVE_PARTITION) id int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (id) ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_P_1; + --disable_ps_protocol eval $MASTER_1_AUTO_INCREMENT_INCREMENT2; eval $MASTER_1_AUTO_INCREMENT_OFFSET2; + --enable_ps_protocol if ($USE_REPLICATION) { SET SESSION sql_log_bin= 1; @@ -275,7 +277,7 @@ if ($HAVE_PARTITION) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_INCREMENT_TABLES1; if ($OUTPUT_CHILD_GROUP2) @@ -293,7 +295,7 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_2_SELECT_INCREMENT_TABLES1; if ($OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/bg/t/spider_fixes.test b/storage/spider/mysql-test/spider/bg/t/spider_fixes.test index 04e806fb612..9f7ada052ed 100644 --- a/storage/spider/mysql-test/spider/bg/t/spider_fixes.test +++ b/storage/spider/mysql-test/spider/bg/t/spider_fixes.test @@ -164,7 +164,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -206,7 +206,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -248,7 +248,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -337,7 +337,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -359,7 +359,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -381,7 +381,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -403,7 +403,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -425,7 +425,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -447,7 +447,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -469,7 +469,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -491,7 +491,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -513,7 +513,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -535,7 +535,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -557,7 +557,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -579,7 +579,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -676,7 +676,7 @@ if ($HAVE_TRIGGER) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_TABLES4; if (!$OUTPUT_CHILD_GROUP2) @@ -722,7 +722,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -812,7 +812,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -899,8 +899,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%update %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -1073,8 +1073,10 @@ eval CREATE TABLE t1 ( id int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (id) ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_1; +--disable_ps_protocol eval $MASTER_1_AUTO_INCREMENT_INCREMENT2; eval $MASTER_1_AUTO_INCREMENT_OFFSET2; +--enable_ps_protocol if ($USE_REPLICATION) { SET SESSION sql_log_bin= 1; @@ -1139,7 +1141,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_INCREMENT_TABLES1; if ($OUTPUT_CHILD_GROUP2) @@ -1324,7 +1326,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TEXT_PK_TABLES1; if (!$OUTPUT_CHILD_GROUP2) @@ -1380,7 +1382,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TEXT_PK_TABLES1; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/bg/t/spider_fixes_part.test b/storage/spider/mysql-test/spider/bg/t/spider_fixes_part.test index ef5a8026c02..e6c4456edcb 100644 --- a/storage/spider/mysql-test/spider/bg/t/spider_fixes_part.test +++ b/storage/spider/mysql-test/spider/bg/t/spider_fixes_part.test @@ -176,13 +176,13 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES2; if (!$OUTPUT_CHILD_GROUP2) @@ -281,19 +281,19 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%delete %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%delete %'; } eval $CHILD2_1_SELECT_TABLES2; if (!$OUTPUT_CHILD_GROUP2) @@ -404,12 +404,12 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -509,8 +509,10 @@ if ($HAVE_PARTITION) id int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (id) ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_P_1; + --disable_ps_protocol eval $MASTER_1_AUTO_INCREMENT_INCREMENT2; eval $MASTER_1_AUTO_INCREMENT_OFFSET2; + --enable_ps_protocol if ($USE_REPLICATION) { SET SESSION sql_log_bin= 1; @@ -575,7 +577,7 @@ if ($HAVE_PARTITION) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_INCREMENT_TABLES1; if ($OUTPUT_CHILD_GROUP2) @@ -593,7 +595,7 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_2_SELECT_INCREMENT_TABLES1; if ($OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/bg/t/vp_fixes.test b/storage/spider/mysql-test/spider/bg/t/vp_fixes.test index 90380227040..2c3e1523611 100644 --- a/storage/spider/mysql-test/spider/bg/t/vp_fixes.test +++ b/storage/spider/mysql-test/spider/bg/t/vp_fixes.test @@ -206,7 +206,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_TABLES5; if (!$OUTPUT_CHILD_GROUP2) @@ -303,7 +303,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_TABLES5; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/bugfix/include/checksum_table_with_quick_mode_3_init.inc b/storage/spider/mysql-test/spider/bugfix/include/checksum_table_with_quick_mode_3_init.inc index 123410380ab..a5dc920e86e 100644 --- a/storage/spider/mysql-test/spider/bugfix/include/checksum_table_with_quick_mode_3_init.inc +++ b/storage/spider/mysql-test/spider/bugfix/include/checksum_table_with_quick_mode_3_init.inc @@ -21,7 +21,7 @@ let $CHILD2_1_CREATE_TABLES= let $CHILD2_1_SELECT_TABLES= SELECT pkey FROM tbl_a ORDER BY pkey; let $CHILD2_1_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%checksum %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%checksum %'; --connection master_1 set @old_spider_quick_mode= @@spider_quick_mode; set session spider_quick_mode= 3; diff --git a/storage/spider/mysql-test/spider/bugfix/include/cp932_column_init.inc b/storage/spider/mysql-test/spider/bugfix/include/cp932_column_init.inc index ba412b567f8..5ef1c301de5 100644 --- a/storage/spider/mysql-test/spider/bugfix/include/cp932_column_init.inc +++ b/storage/spider/mysql-test/spider/bugfix/include/cp932_column_init.inc @@ -23,7 +23,7 @@ let $CHILD2_1_CREATE_TABLES= let $CHILD2_1_SELECT_TABLES= SELECT pkey, txt_utf8, txt_cp932 FROM tbl_a ORDER BY pkey; let $CHILD2_1_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %' OR argument LIKE '%update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND (argument LIKE '%insert %' OR argument LIKE '%update %'); --connection master_1 set @old_spider_direct_dup_insert= @@spider_direct_dup_insert; set session spider_direct_dup_insert= 1; diff --git a/storage/spider/mysql-test/spider/bugfix/include/delete_with_float_column_init.inc b/storage/spider/mysql-test/spider/bugfix/include/delete_with_float_column_init.inc index f2f8635f9e3..b08c9fb11be 100644 --- a/storage/spider/mysql-test/spider/bugfix/include/delete_with_float_column_init.inc +++ b/storage/spider/mysql-test/spider/bugfix/include/delete_with_float_column_init.inc @@ -10,7 +10,7 @@ let $CHILD2_1_SELECT_TABLES= SELECT pkey, f FROM tbl_a ORDER BY pkey; let $CHILD2_1_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%delete %'; --connection slave1_1 --disable_warnings --disable_query_log diff --git a/storage/spider/mysql-test/spider/bugfix/include/group_by_order_by_limit_init.inc b/storage/spider/mysql-test/spider/bugfix/include/group_by_order_by_limit_init.inc index ac60580f463..b11ac98d8b0 100644 --- a/storage/spider/mysql-test/spider/bugfix/include/group_by_order_by_limit_init.inc +++ b/storage/spider/mysql-test/spider/bugfix/include/group_by_order_by_limit_init.inc @@ -35,7 +35,7 @@ let $CHILD2_1_CREATE_TABLES= let $CHILD2_1_SELECT_TABLES= SELECT pkey, skey FROM tbl_a ORDER BY pkey; let $CHILD2_1_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; --let $CHILD2_2_DROP_TABLES_BACKUP= $CHILD2_2_DROP_TABLES let $CHILD2_2_DROP_TABLES= DROP TABLE IF EXISTS tbl_a; @@ -51,4 +51,4 @@ let $CHILD2_2_CREATE_TABLES= let $CHILD2_2_SELECT_TABLES= SELECT pkey, skey FROM tbl_a ORDER BY pkey; let $CHILD2_2_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; diff --git a/storage/spider/mysql-test/spider/bugfix/include/insert_select_init.inc b/storage/spider/mysql-test/spider/bugfix/include/insert_select_init.inc index 62a8821a3c9..972fdb7e74c 100644 --- a/storage/spider/mysql-test/spider/bugfix/include/insert_select_init.inc +++ b/storage/spider/mysql-test/spider/bugfix/include/insert_select_init.inc @@ -37,7 +37,7 @@ let $CHILD2_1_CREATE_TABLES2= let $CHILD2_1_SELECT_TABLES= SELECT pkey, dt FROM tbl_b ORDER BY pkey; let $CHILD2_1_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; --connection master_1 set @old_spider_direct_dup_insert= @@spider_direct_dup_insert; set session spider_direct_dup_insert= 1; diff --git a/storage/spider/mysql-test/spider/bugfix/include/mdev_19866_init.inc b/storage/spider/mysql-test/spider/bugfix/include/mdev_19866_init.inc index dceae8226b0..379cb0fb746 100644 --- a/storage/spider/mysql-test/spider/bugfix/include/mdev_19866_init.inc +++ b/storage/spider/mysql-test/spider/bugfix/include/mdev_19866_init.inc @@ -34,7 +34,7 @@ let $CHILD2_1_CREATE_TABLES= let $CHILD2_1_SELECT_TABLES= SELECT pkey, val FROM tbl_a ORDER BY pkey; let $CHILD2_1_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; --let $CHILD2_2_DROP_TABLES_BACKUP= $CHILD2_2_DROP_TABLES let $CHILD2_2_DROP_TABLES= DROP TABLE IF EXISTS tbl_a; @@ -49,4 +49,4 @@ let $CHILD2_2_CREATE_TABLES= let $CHILD2_2_SELECT_TABLES= SELECT pkey, val FROM tbl_a ORDER BY pkey; let $CHILD2_2_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; diff --git a/storage/spider/mysql-test/spider/bugfix/include/mdev_20100_init.inc b/storage/spider/mysql-test/spider/bugfix/include/mdev_20100_init.inc index ed6e27962d2..ca71d739024 100644 --- a/storage/spider/mysql-test/spider/bugfix/include/mdev_20100_init.inc +++ b/storage/spider/mysql-test/spider/bugfix/include/mdev_20100_init.inc @@ -43,4 +43,4 @@ let $CHILD2_1_SELECT_TABLES= SELECT a, b, c FROM ta_r3 ORDER BY a $STR_SEMICOLON SELECT a, b, c FROM ta_r4 ORDER BY a; let $CHILD2_1_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; diff --git a/storage/spider/mysql-test/spider/bugfix/include/mdev_20502_init.inc b/storage/spider/mysql-test/spider/bugfix/include/mdev_20502_init.inc index fd8cc0d8170..924d3b72895 100644 --- a/storage/spider/mysql-test/spider/bugfix/include/mdev_20502_init.inc +++ b/storage/spider/mysql-test/spider/bugfix/include/mdev_20502_init.inc @@ -22,4 +22,4 @@ let $CHILD2_1_CREATE_TABLES= let $CHILD2_1_SELECT_TABLES= SELECT id, val FROM tbl_a ORDER BY id; let $CHILD2_1_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; diff --git a/storage/spider/mysql-test/spider/bugfix/include/mdev_21884_init.inc b/storage/spider/mysql-test/spider/bugfix/include/mdev_21884_init.inc index 25455ffcdf1..68a496a7d5f 100644 --- a/storage/spider/mysql-test/spider/bugfix/include/mdev_21884_init.inc +++ b/storage/spider/mysql-test/spider/bugfix/include/mdev_21884_init.inc @@ -49,7 +49,7 @@ let $CHILD2_1_SELECT_TABLES= SELECT a, b, c FROM ta_r2 ORDER BY a $STR_SEMICOLON SELECT a, b, c FROM ta_r3 ORDER BY a; let $CHILD2_1_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; --connection master_1 set @old_spider_bgs_mode= @@spider_bgs_mode; set session spider_bgs_mode= 2; diff --git a/storage/spider/mysql-test/spider/bugfix/include/quick_mode_0_init.inc b/storage/spider/mysql-test/spider/bugfix/include/quick_mode_0_init.inc index 2656517216c..2ff26472eba 100644 --- a/storage/spider/mysql-test/spider/bugfix/include/quick_mode_0_init.inc +++ b/storage/spider/mysql-test/spider/bugfix/include/quick_mode_0_init.inc @@ -24,7 +24,7 @@ let $CHILD2_1_CREATE_TABLES= let $CHILD2_1_SELECT_TABLES= SELECT pkey FROM tbl_a ORDER BY pkey; let $CHILD2_1_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; --let $CHILD2_2_DROP_TABLES_BACKUP= $CHILD2_2_DROP_TABLES let $CHILD2_2_DROP_TABLES= DROP TABLE IF EXISTS tbl_b; @@ -38,7 +38,7 @@ let $CHILD2_2_CREATE_TABLES= let $CHILD2_2_SELECT_TABLES= SELECT pkey FROM tbl_b ORDER BY pkey; let $CHILD2_2_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; --connection master_1 set @old_spider_quick_mode= @@spider_quick_mode; set session spider_quick_mode= 0; diff --git a/storage/spider/mysql-test/spider/bugfix/include/quick_mode_1_init.inc b/storage/spider/mysql-test/spider/bugfix/include/quick_mode_1_init.inc index 9a8de407569..2120fdaacc5 100644 --- a/storage/spider/mysql-test/spider/bugfix/include/quick_mode_1_init.inc +++ b/storage/spider/mysql-test/spider/bugfix/include/quick_mode_1_init.inc @@ -24,7 +24,7 @@ let $CHILD2_1_CREATE_TABLES= let $CHILD2_1_SELECT_TABLES= SELECT pkey FROM tbl_a ORDER BY pkey; let $CHILD2_1_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; --let $CHILD2_2_DROP_TABLES_BACKUP= $CHILD2_2_DROP_TABLES let $CHILD2_2_DROP_TABLES= DROP TABLE IF EXISTS tbl_b; @@ -38,7 +38,7 @@ let $CHILD2_2_CREATE_TABLES= let $CHILD2_2_SELECT_TABLES= SELECT pkey FROM tbl_b ORDER BY pkey; let $CHILD2_2_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; --connection master_1 set @old_spider_quick_mode= @@spider_quick_mode; set session spider_quick_mode= 1; diff --git a/storage/spider/mysql-test/spider/bugfix/include/quick_mode_2_init.inc b/storage/spider/mysql-test/spider/bugfix/include/quick_mode_2_init.inc index dbe3f703a2f..0f0644c81fa 100644 --- a/storage/spider/mysql-test/spider/bugfix/include/quick_mode_2_init.inc +++ b/storage/spider/mysql-test/spider/bugfix/include/quick_mode_2_init.inc @@ -24,7 +24,7 @@ let $CHILD2_1_CREATE_TABLES= let $CHILD2_1_SELECT_TABLES= SELECT pkey FROM tbl_a ORDER BY pkey; let $CHILD2_1_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; --let $CHILD2_2_DROP_TABLES_BACKUP= $CHILD2_2_DROP_TABLES let $CHILD2_2_DROP_TABLES= DROP TABLE IF EXISTS tbl_b; @@ -38,7 +38,7 @@ let $CHILD2_2_CREATE_TABLES= let $CHILD2_2_SELECT_TABLES= SELECT pkey FROM tbl_b ORDER BY pkey; let $CHILD2_2_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; --connection master_1 set @old_spider_quick_mode= @@spider_quick_mode; set session spider_quick_mode= 2; diff --git a/storage/spider/mysql-test/spider/bugfix/include/quick_mode_3_init.inc b/storage/spider/mysql-test/spider/bugfix/include/quick_mode_3_init.inc index 81239206dfc..9556d2e44e8 100644 --- a/storage/spider/mysql-test/spider/bugfix/include/quick_mode_3_init.inc +++ b/storage/spider/mysql-test/spider/bugfix/include/quick_mode_3_init.inc @@ -24,7 +24,7 @@ let $CHILD2_1_CREATE_TABLES= let $CHILD2_1_SELECT_TABLES= SELECT pkey FROM tbl_a ORDER BY pkey; let $CHILD2_1_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; --let $CHILD2_2_DROP_TABLES_BACKUP= $CHILD2_2_DROP_TABLES let $CHILD2_2_DROP_TABLES= DROP TABLE IF EXISTS tbl_b; @@ -38,7 +38,7 @@ let $CHILD2_2_CREATE_TABLES= let $CHILD2_2_SELECT_TABLES= SELECT pkey FROM tbl_b ORDER BY pkey; let $CHILD2_2_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; --connection master_1 set @old_spider_quick_mode= @@spider_quick_mode; set session spider_quick_mode= 3; diff --git a/storage/spider/mysql-test/spider/bugfix/include/return_found_rows_insert_init.inc b/storage/spider/mysql-test/spider/bugfix/include/return_found_rows_insert_init.inc index da6778de504..e383327b624 100644 --- a/storage/spider/mysql-test/spider/bugfix/include/return_found_rows_insert_init.inc +++ b/storage/spider/mysql-test/spider/bugfix/include/return_found_rows_insert_init.inc @@ -23,5 +23,5 @@ let $CHILD2_1_CREATE_TABLES= let $CHILD2_1_SELECT_TABLES= SELECT skey, dt, tm FROM tbl_a ORDER BY skey; let $CHILD2_1_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %' OR argument LIKE '%replace %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND (argument LIKE '%insert %' OR argument LIKE '%replace %'); --let $MASTER_1_SET_COMMAND=set session spider_direct_dup_insert=1 $STR_SEMICOLON diff --git a/storage/spider/mysql-test/spider/bugfix/include/return_found_rows_update_init.inc b/storage/spider/mysql-test/spider/bugfix/include/return_found_rows_update_init.inc index 884ef74c47e..e0c25939244 100644 --- a/storage/spider/mysql-test/spider/bugfix/include/return_found_rows_update_init.inc +++ b/storage/spider/mysql-test/spider/bugfix/include/return_found_rows_update_init.inc @@ -23,4 +23,4 @@ let $CHILD2_1_CREATE_TABLES= let $CHILD2_1_SELECT_TABLES= SELECT skey, dt, tm FROM tbl_a ORDER BY skey; let $CHILD2_1_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%update %'; diff --git a/storage/spider/mysql-test/spider/bugfix/include/select_by_null_init.inc b/storage/spider/mysql-test/spider/bugfix/include/select_by_null_init.inc index d07ba2a9fee..3a5f91deb76 100644 --- a/storage/spider/mysql-test/spider/bugfix/include/select_by_null_init.inc +++ b/storage/spider/mysql-test/spider/bugfix/include/select_by_null_init.inc @@ -21,4 +21,4 @@ let $CHILD2_1_CREATE_TABLES= let $CHILD2_1_SELECT_TABLES= SELECT pkey FROM tbl_a ORDER BY pkey; let $CHILD2_1_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; diff --git a/storage/spider/mysql-test/spider/bugfix/include/select_with_backquote_init.inc b/storage/spider/mysql-test/spider/bugfix/include/select_with_backquote_init.inc index 37bf690c066..41c4fd3a0b4 100644 --- a/storage/spider/mysql-test/spider/bugfix/include/select_with_backquote_init.inc +++ b/storage/spider/mysql-test/spider/bugfix/include/select_with_backquote_init.inc @@ -22,4 +22,4 @@ let $CHILD2_1_CREATE_TABLES= let $CHILD2_1_SELECT_TABLES= SELECT pkey, txt_utf8 FROM tbl_a ORDER BY pkey; let $CHILD2_1_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; diff --git a/storage/spider/mysql-test/spider/bugfix/include/slave_trx_isolation_init.inc b/storage/spider/mysql-test/spider/bugfix/include/slave_trx_isolation_init.inc index 3a058a55303..bfdb08318b6 100644 --- a/storage/spider/mysql-test/spider/bugfix/include/slave_trx_isolation_init.inc +++ b/storage/spider/mysql-test/spider/bugfix/include/slave_trx_isolation_init.inc @@ -22,7 +22,7 @@ let $CHILD2_1_CREATE_TABLES= let $CHILD2_1_SELECT_TABLES= SELECT pkey FROM tbl_a ORDER BY pkey; let $CHILD2_1_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%set %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%set %'; --connection slave1_1 --disable_warnings --disable_query_log diff --git a/storage/spider/mysql-test/spider/bugfix/include/sql_mode_init.inc b/storage/spider/mysql-test/spider/bugfix/include/sql_mode_init.inc index 65e2f9102e7..09ab2934aea 100644 --- a/storage/spider/mysql-test/spider/bugfix/include/sql_mode_init.inc +++ b/storage/spider/mysql-test/spider/bugfix/include/sql_mode_init.inc @@ -37,4 +37,4 @@ let $CHILD2_1_CREATE_TABLES= let $CHILD2_1_SELECT_TABLES= SELECT pkey FROM tbl_a ORDER BY pkey; let $CHILD2_1_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%sql_mode%'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%sql_mode%'; diff --git a/storage/spider/mysql-test/spider/bugfix/include/strict_group_by_init.inc b/storage/spider/mysql-test/spider/bugfix/include/strict_group_by_init.inc index 15c2a9eed7c..e4614c871f8 100644 --- a/storage/spider/mysql-test/spider/bugfix/include/strict_group_by_init.inc +++ b/storage/spider/mysql-test/spider/bugfix/include/strict_group_by_init.inc @@ -35,7 +35,7 @@ let $CHILD2_1_CREATE_TABLES= let $CHILD2_1_SELECT_TABLES= SELECT pkey, skey FROM tbl_a ORDER BY pkey; let $CHILD2_1_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; --let $CHILD2_2_DROP_TABLES_BACKUP= $CHILD2_2_DROP_TABLES let $CHILD2_2_DROP_TABLES= DROP TABLE IF EXISTS tbl_a; @@ -51,7 +51,7 @@ let $CHILD2_2_CREATE_TABLES= let $CHILD2_2_SELECT_TABLES= SELECT pkey, skey FROM tbl_a ORDER BY pkey; let $CHILD2_2_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; --connection master_1 set @old_spider_sync_sql_mode= @@spider_sync_sql_mode; set session spider_sync_sql_mode= FALSE; diff --git a/storage/spider/mysql-test/spider/bugfix/include/wait_timeout_init.inc b/storage/spider/mysql-test/spider/bugfix/include/wait_timeout_init.inc index d56d7a20940..b98f7216ec6 100644 --- a/storage/spider/mysql-test/spider/bugfix/include/wait_timeout_init.inc +++ b/storage/spider/mysql-test/spider/bugfix/include/wait_timeout_init.inc @@ -33,7 +33,7 @@ let $CHILD2_1_CREATE_TABLES= let $CHILD2_1_SELECT_TABLES= SELECT pkey FROM tbl_a ORDER BY pkey; let $CHILD2_1_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; --let $CHILD2_2_DROP_TABLES_BACKUP= $CHILD2_2_DROP_TABLES let $CHILD2_2_DROP_TABLES= DROP TABLE IF EXISTS tbl_a; @@ -47,7 +47,7 @@ let $CHILD2_2_CREATE_TABLES= let $CHILD2_2_SELECT_TABLES= SELECT pkey FROM tbl_a ORDER BY pkey; let $CHILD2_2_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; --connection child2_1 set @old_wait_timeout= @@wait_timeout; set global wait_timeout= 1; diff --git a/storage/spider/mysql-test/spider/bugfix/include/wrapper_mariadb_init.inc b/storage/spider/mysql-test/spider/bugfix/include/wrapper_mariadb_init.inc index df3d44c39bc..80c5440facb 100644 --- a/storage/spider/mysql-test/spider/bugfix/include/wrapper_mariadb_init.inc +++ b/storage/spider/mysql-test/spider/bugfix/include/wrapper_mariadb_init.inc @@ -21,4 +21,4 @@ let $CHILD2_1_CREATE_TABLES= let $CHILD2_1_SELECT_TABLES= SELECT pkey FROM tbl_a ORDER BY pkey; let $CHILD2_1_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; diff --git a/storage/spider/mysql-test/spider/bugfix/include/xa_cmd_init.inc b/storage/spider/mysql-test/spider/bugfix/include/xa_cmd_init.inc index 5c607bd1ff5..025ed8354d9 100644 --- a/storage/spider/mysql-test/spider/bugfix/include/xa_cmd_init.inc +++ b/storage/spider/mysql-test/spider/bugfix/include/xa_cmd_init.inc @@ -21,4 +21,4 @@ let $CHILD2_1_CREATE_TABLES= let $CHILD2_1_SELECT_TABLES= SELECT pkey FROM tbl_a ORDER BY pkey; let $CHILD2_1_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; diff --git a/storage/spider/mysql-test/spider/bugfix/r/checksum_table_with_quick_mode_3.result b/storage/spider/mysql-test/spider/bugfix/r/checksum_table_with_quick_mode_3.result index bd423d934f5..033e1593962 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/checksum_table_with_quick_mode_3.result +++ b/storage/spider/mysql-test/spider/bugfix/r/checksum_table_with_quick_mode_3.result @@ -44,10 +44,10 @@ CHECKSUM TABLE tbl_a EXTENDED; Table Checksum auto_test_local.tbl_a 1061386331 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%checksum %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%checksum %'; argument checksum table `auto_test_remote`.`tbl_a` extended -SELECT argument FROM mysql.general_log WHERE argument LIKE '%checksum %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%checksum %' SELECT pkey FROM tbl_a ORDER BY pkey; pkey 0 diff --git a/storage/spider/mysql-test/spider/bugfix/r/cp932_column.result b/storage/spider/mysql-test/spider/bugfix/r/cp932_column.result index 30b333c5008..c0566840463 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/cp932_column.result +++ b/storage/spider/mysql-test/spider/bugfix/r/cp932_column.result @@ -45,12 +45,12 @@ UPDATE tbl_a SET txt_cp932 = ' SET NAMES utf8; connection child2_1; SET NAMES cp932; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %' OR argument LIKE '%update %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND (argument LIKE '%insert %' OR argument LIKE '%update %'); argument insert into `auto_test_remote`.`tbl_a`(`pkey`,`txt_utf8`,`txt_cp932`)values(10,'',_cp932'\\x92\\x86\\x8D\\x91') insert high_priority into `auto_test_remote`.`tbl_a`(`pkey`,`txt_utf8`,`txt_cp932`)values(0,'',_cp932'') on duplicate key update `txt_cp932` = _cp932'\x92\x86\x8D\x91' update `auto_test_remote`.`tbl_a` set `txt_cp932` = _cp932'\x92\x86\x8D\x91' where (`pkey` = 2) -SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %' OR argument LIKE '%update %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND (argument LIKE '%insert %' OR argument LIKE '%update %') SELECT pkey, txt_utf8, txt_cp932 FROM tbl_a ORDER BY pkey; pkey txt_utf8 txt_cp932 0 diff --git a/storage/spider/mysql-test/spider/bugfix/r/delete_with_float_column_default.result b/storage/spider/mysql-test/spider/bugfix/r/delete_with_float_column_default.result index d9fb00a09fc..cb1b190f71d 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/delete_with_float_column_default.result +++ b/storage/spider/mysql-test/spider/bugfix/r/delete_with_float_column_default.result @@ -52,11 +52,11 @@ connection slave1_1; connection master_1; SET SESSION sql_log_bin= 0; connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%delete %'; argument delete from `auto_test_remote`.`tbl_a` where `pkey` = 0 and `f` is null limit 1 delete from `auto_test_remote`.`tbl_a` where `pkey` = 1 and `f` = cast(0.671437 as float) limit 1 -SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%delete %' SELECT pkey, f FROM tbl_a ORDER BY pkey; pkey f connection slave1_1; diff --git a/storage/spider/mysql-test/spider/bugfix/r/delete_with_float_column_mariadb.result b/storage/spider/mysql-test/spider/bugfix/r/delete_with_float_column_mariadb.result index d9fb00a09fc..cb1b190f71d 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/delete_with_float_column_mariadb.result +++ b/storage/spider/mysql-test/spider/bugfix/r/delete_with_float_column_mariadb.result @@ -52,11 +52,11 @@ connection slave1_1; connection master_1; SET SESSION sql_log_bin= 0; connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%delete %'; argument delete from `auto_test_remote`.`tbl_a` where `pkey` = 0 and `f` is null limit 1 delete from `auto_test_remote`.`tbl_a` where `pkey` = 1 and `f` = cast(0.671437 as float) limit 1 -SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%delete %' SELECT pkey, f FROM tbl_a ORDER BY pkey; pkey f connection slave1_1; diff --git a/storage/spider/mysql-test/spider/bugfix/r/delete_with_float_column_mysql.result b/storage/spider/mysql-test/spider/bugfix/r/delete_with_float_column_mysql.result index 9b11de7cff6..1131021258d 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/delete_with_float_column_mysql.result +++ b/storage/spider/mysql-test/spider/bugfix/r/delete_with_float_column_mysql.result @@ -52,11 +52,11 @@ connection slave1_1; connection master_1; SET SESSION sql_log_bin= 0; connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%delete %'; argument delete from `auto_test_remote`.`tbl_a` where `pkey` = 0 and `f` is null limit 1 delete from `auto_test_remote`.`tbl_a` where `pkey` = 1 and `f` = /* create function to_float(a decimal(20,6)) returns float return a */ to_float(0.671437) limit 1 -SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%delete %' SELECT pkey, f FROM tbl_a ORDER BY pkey; pkey f connection slave1_1; diff --git a/storage/spider/mysql-test/spider/bugfix/r/group_by_order_by_limit.result b/storage/spider/mysql-test/spider/bugfix/r/group_by_order_by_limit.result index 8a2bcb73537..efdf212dab8 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/group_by_order_by_limit.result +++ b/storage/spider/mysql-test/spider/bugfix/r/group_by_order_by_limit.result @@ -54,10 +54,10 @@ skey cnt 11 2 10 2 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select count(0),`skey` from `auto_test_remote`.`tbl_a` group by `skey` order by `skey` -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey, skey FROM tbl_a ORDER BY pkey; pkey skey 1 1 @@ -76,10 +76,10 @@ pkey skey 27 12 29 14 connection child2_2; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select count(0),`skey` from `auto_test_remote2`.`tbl_a` group by `skey` order by `skey` -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey, skey FROM tbl_a ORDER BY pkey; pkey skey 0 0 diff --git a/storage/spider/mysql-test/spider/bugfix/r/insert_select.result b/storage/spider/mysql-test/spider/bugfix/r/insert_select.result index 0783995e287..670777d95d9 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/insert_select.result +++ b/storage/spider/mysql-test/spider/bugfix/r/insert_select.result @@ -58,7 +58,7 @@ INSERT IGNORE INTO tbl_b (SELECT skey, CAST(CONCAT(dt, ' ', tm) AS datetime) FRO INSERT IGNORE INTO tbl_b (SELECT skey, CAST(CONCAT(dt, ' ', tm) AS datetime) FROM tbl_a WHERE skey = 6 AND dt > DATE_ADD('2012-12-01', INTERVAL -10 DAY)); INSERT IGNORE INTO tbl_b (SELECT skey, CAST(CONCAT(dt, ' ', tm) AS datetime) FROM tbl_a WHERE skey = 5 AND dt > DATE_ADD('2012-12-01', INTERVAL -10 DAY)); connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select t0.`skey` `skey`,cast((concat(t0.`dt` , _latin1' ' , t0.`tm`)) as datetime) `CAST(CONCAT(dt, ' ', tm) AS datetime)` from `auto_test_remote`.`tbl_a` t0 where ((t0.`skey` = 4) and (t0.`dt` > _latin1'2012-11-21')) lock in share mode select t0.`skey` `skey`,cast((concat(t0.`dt` , _latin1' ' , t0.`tm`)) as datetime) `CAST(CONCAT(dt, ' ', tm) AS datetime)` from `auto_test_remote`.`tbl_a` t0 where ((t0.`skey` = 3) and (t0.`dt` > _latin1'2012-11-21')) lock in share mode @@ -70,7 +70,7 @@ select t0.`skey` `skey`,cast((concat(t0.`dt` , _latin1' ' , t0.`tm`)) as datetim select t0.`skey` `skey`,cast((concat(t0.`dt` , _latin1' ' , t0.`tm`)) as datetime) `CAST(CONCAT(dt, ' ', tm) AS datetime)` from `auto_test_remote`.`tbl_a` t0 where ((t0.`skey` = 7) and (t0.`dt` > _latin1'2012-11-21')) lock in share mode select t0.`skey` `skey`,cast((concat(t0.`dt` , _latin1' ' , t0.`tm`)) as datetime) `CAST(CONCAT(dt, ' ', tm) AS datetime)` from `auto_test_remote`.`tbl_a` t0 where ((t0.`skey` = 6) and (t0.`dt` > _latin1'2012-11-21')) lock in share mode select t0.`skey` `skey`,cast((concat(t0.`dt` , _latin1' ' , t0.`tm`)) as datetime) `CAST(CONCAT(dt, ' ', tm) AS datetime)` from `auto_test_remote`.`tbl_a` t0 where ((t0.`skey` = 5) and (t0.`dt` > _latin1'2012-11-21')) lock in share mode -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey, dt FROM tbl_b ORDER BY pkey; pkey dt 0 2013-01-01 13:00:00 diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_19866.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_19866.result index 5d483481edd..dbf0f54c804 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/mdev_19866.result +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_19866.result @@ -68,25 +68,25 @@ pkey val 2 2 4 4 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `pkey`,`val` from `auto_test_remote`.`tbl_a` select `pkey`,`val` from `auto_test_remote`.`tbl_a` where `pkey` = 1 select `pkey`,`val` from `auto_test_remote`.`tbl_a` select `pkey`,`val` from `auto_test_remote`.`tbl_a` -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey, val FROM tbl_a ORDER BY pkey; pkey val 1 1 3 3 connection child2_2; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `pkey`,`val` from `auto_test_remote2`.`tbl_a` select `pkey`,`val` from `auto_test_remote2`.`tbl_a` select `pkey`,`val` from `auto_test_remote2`.`tbl_a` where `pkey` = 2 select `pkey`,`val` from `auto_test_remote2`.`tbl_a` -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey, val FROM tbl_a ORDER BY pkey; pkey val 2 2 diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_20100.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_20100.result index 9d2297b4daf..52876c34841 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/mdev_20100.result +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_20100.result @@ -76,7 +76,7 @@ SELECT a, b, c FROM tbl_a PARTITION (pt2,pt3); a b c 5 c 2001-12-31 23:59:59 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select t0.`a` `a`,t0.`b` `b`,t0.`c` `c` from `auto_test_remote`.`ta_r3` t0 where (t0.`b` = 'c') select `a`,`b`,`c` from `auto_test_remote`.`ta_r2` @@ -90,7 +90,7 @@ select `a`,`b`,`c` from `auto_test_remote`.`ta_r4` select t0.`a` `a`,t0.`b` `b`,t0.`c` `c` from `auto_test_remote`.`ta_r2` t0 where (t0.`b` = 'c') select `a`,`b`,`c` from `auto_test_remote`.`ta_r3` select `a`,`b`,`c` from `auto_test_remote`.`ta_r4` -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT a, b, c FROM ta_r2 ORDER BY a ; SELECT a, b, c FROM ta_r3 ORDER BY a ; SELECT a, b, c FROM ta_r4 ORDER BY a; diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_20502.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_20502.result index e5f16b81329..ee06e449fd3 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/mdev_20502.result +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_20502.result @@ -52,7 +52,7 @@ m const val sq 3 0 1 2 2 0 2 2 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select t0.`id` `id`,t0.`val` `val` from `auto_test_remote`.`tbl_a` t0 select t0.`id` `id`,t0.`val` `val`,(t0.`val` + 10) `val+10` from `auto_test_remote`.`tbl_a` t0 @@ -62,7 +62,7 @@ select (t0.`val` + 10) `val+10`,t0.`val` `val` from `auto_test_remote`.`tbl_a` t select (t0.`val` + 1) `tbl_a.val+1` from `auto_test_remote`.`tbl_a` t0 limit 1 select max(t0.`id`) `m`,t0.`val` `val` from `auto_test_remote`.`tbl_a` t0 group by t0.`val` order by t0.`val` select (t0.`val` + 1) `tbl_a.val+1` from `auto_test_remote`.`tbl_a` t0 limit 1 -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT id, val FROM tbl_a ORDER BY id; id val 1 1 diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_21884.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_21884.result index d5ba9b1e64a..7a9c58e6f36 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/mdev_21884.result +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_21884.result @@ -70,11 +70,11 @@ a b 13 c connection child2_1; SET NAMES utf8; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `a`,`b` from `auto_test_remote`.`ta_r2` order by `a`,`b` select `a`,`b` from `auto_test_remote`.`ta_r3` order by `a`,`b` -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT a, b, c FROM ta_r2 ORDER BY a ; SELECT a, b, c FROM ta_r3 ORDER BY a; a b c diff --git a/storage/spider/mysql-test/spider/bugfix/r/quick_mode_0.result b/storage/spider/mysql-test/spider/bugfix/r/quick_mode_0.result index 6e5a0052370..f785ad3575a 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/quick_mode_0.result +++ b/storage/spider/mysql-test/spider/bugfix/r/quick_mode_0.result @@ -90,10 +90,10 @@ pkey 28 29 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `pkey` from `auto_test_remote`.`tbl_a` order by `pkey` -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_a ORDER BY pkey; pkey 0 @@ -127,7 +127,7 @@ pkey 28 29 connection child2_2; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 0 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 1 @@ -159,7 +159,7 @@ select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 26 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 27 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 28 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 29 -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_b ORDER BY pkey; pkey 0 @@ -234,10 +234,10 @@ pkey 28 29 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `pkey` from `auto_test_remote`.`tbl_a` order by `pkey` -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_a ORDER BY pkey; pkey 0 @@ -271,7 +271,7 @@ pkey 28 29 connection child2_2; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 0 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 1 @@ -303,7 +303,7 @@ select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 26 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 27 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 28 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 29 -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_b ORDER BY pkey; pkey 0 @@ -378,10 +378,10 @@ pkey 28 29 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `pkey` from `auto_test_remote`.`tbl_a` order by `pkey` -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_a ORDER BY pkey; pkey 0 @@ -415,7 +415,7 @@ pkey 28 29 connection child2_2; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 0 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 1 @@ -447,7 +447,7 @@ select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 26 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 27 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 28 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 29 -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_b ORDER BY pkey; pkey 0 diff --git a/storage/spider/mysql-test/spider/bugfix/r/quick_mode_1.result b/storage/spider/mysql-test/spider/bugfix/r/quick_mode_1.result index bca6d172a49..89a07bf64e6 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/quick_mode_1.result +++ b/storage/spider/mysql-test/spider/bugfix/r/quick_mode_1.result @@ -90,10 +90,10 @@ pkey 28 29 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `pkey` from `auto_test_remote`.`tbl_a` order by `pkey` -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_a ORDER BY pkey; pkey 0 @@ -127,7 +127,7 @@ pkey 28 29 connection child2_2; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 0 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 1 @@ -159,7 +159,7 @@ select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 26 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 27 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 28 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 29 -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_b ORDER BY pkey; pkey 0 @@ -234,10 +234,10 @@ pkey 28 29 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `pkey` from `auto_test_remote`.`tbl_a` order by `pkey` -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_a ORDER BY pkey; pkey 0 @@ -271,7 +271,7 @@ pkey 28 29 connection child2_2; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 0 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 1 @@ -303,7 +303,7 @@ select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 26 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 27 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 28 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 29 -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_b ORDER BY pkey; pkey 0 @@ -378,10 +378,10 @@ pkey 28 29 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `pkey` from `auto_test_remote`.`tbl_a` order by `pkey` -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_a ORDER BY pkey; pkey 0 @@ -415,7 +415,7 @@ pkey 28 29 connection child2_2; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 0 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 1 @@ -447,7 +447,7 @@ select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 26 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 27 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 28 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 29 -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_b ORDER BY pkey; pkey 0 diff --git a/storage/spider/mysql-test/spider/bugfix/r/quick_mode_2.result b/storage/spider/mysql-test/spider/bugfix/r/quick_mode_2.result index 61a7764dddb..cc94cfe4ad2 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/quick_mode_2.result +++ b/storage/spider/mysql-test/spider/bugfix/r/quick_mode_2.result @@ -90,10 +90,10 @@ pkey 28 29 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `pkey` from `auto_test_remote`.`tbl_a` order by `pkey` -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_a ORDER BY pkey; pkey 0 @@ -127,7 +127,7 @@ pkey 28 29 connection child2_2; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 0 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 1 @@ -159,7 +159,7 @@ select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 26 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 27 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 28 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 29 -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_b ORDER BY pkey; pkey 0 @@ -234,10 +234,10 @@ pkey 28 29 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `pkey` from `auto_test_remote`.`tbl_a` order by `pkey` -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_a ORDER BY pkey; pkey 0 @@ -271,7 +271,7 @@ pkey 28 29 connection child2_2; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 0 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 1 @@ -303,7 +303,7 @@ select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 26 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 27 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 28 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 29 -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_b ORDER BY pkey; pkey 0 @@ -378,10 +378,10 @@ pkey 28 29 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `pkey` from `auto_test_remote`.`tbl_a` order by `pkey` -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_a ORDER BY pkey; pkey 0 @@ -415,7 +415,7 @@ pkey 28 29 connection child2_2; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 0 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 1 @@ -447,7 +447,7 @@ select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 26 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 27 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 28 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 29 -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_b ORDER BY pkey; pkey 0 diff --git a/storage/spider/mysql-test/spider/bugfix/r/quick_mode_3.result b/storage/spider/mysql-test/spider/bugfix/r/quick_mode_3.result index 38387a45509..bc1daa77480 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/quick_mode_3.result +++ b/storage/spider/mysql-test/spider/bugfix/r/quick_mode_3.result @@ -90,10 +90,10 @@ pkey 28 29 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `pkey` from `auto_test_remote`.`tbl_a` order by `pkey` -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_a ORDER BY pkey; pkey 0 @@ -127,7 +127,7 @@ pkey 28 29 connection child2_2; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 0 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 1 @@ -159,7 +159,7 @@ select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 26 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 27 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 28 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 29 -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_b ORDER BY pkey; pkey 0 @@ -234,10 +234,10 @@ pkey 28 29 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `pkey` from `auto_test_remote`.`tbl_a` order by `pkey` -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_a ORDER BY pkey; pkey 0 @@ -271,7 +271,7 @@ pkey 28 29 connection child2_2; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 0 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 1 @@ -303,7 +303,7 @@ select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 26 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 27 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 28 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 29 -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_b ORDER BY pkey; pkey 0 @@ -378,10 +378,10 @@ pkey 28 29 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `pkey` from `auto_test_remote`.`tbl_a` order by `pkey` -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_a ORDER BY pkey; pkey 0 @@ -415,7 +415,7 @@ pkey 28 29 connection child2_2; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 0 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 1 @@ -447,7 +447,7 @@ select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 26 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 27 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 28 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 29 -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_b ORDER BY pkey; pkey 0 diff --git a/storage/spider/mysql-test/spider/bugfix/r/return_found_rows_insert.result b/storage/spider/mysql-test/spider/bugfix/r/return_found_rows_insert.result index 2ddec02ef81..24f9cf7c95c 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/return_found_rows_insert.result +++ b/storage/spider/mysql-test/spider/bugfix/r/return_found_rows_insert.result @@ -50,10 +50,10 @@ Records: 10 Duplicates: 5 Warnings: 0 Bye connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %' OR argument LIKE '%replace %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND (argument LIKE '%insert %' OR argument LIKE '%replace %'); argument insert ignore into `auto_test_remote`.`tbl_a`(`skey`,`dt`,`tm`)values(0,_latin1'2013-01-01',_latin1'13:00:00'),(2,_latin1'2013-02-01',_latin1'13:00:00'),(4,_latin1'2013-03-01',_latin1'13:00:00'),(7,_latin1'2013-04-01',_latin1'13:00:00'),(8,_latin1'2013-05-01',_latin1'13:00:00'),(10,_latin1'2013-06-01',_latin1'13:00:00'),(11,_latin1'2013-07-01',_latin1'13:00:00'),(12,_latin1'2013-08-01',_latin1'13:00:00'),(13,_latin1'2013-09-01',_latin1'13:00:00'),(14,_latin1'2013-10-01',_latin1'13:00:00') -SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %' OR argument LIKE '%replace %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND (argument LIKE '%insert %' OR argument LIKE '%replace %') SELECT skey, dt, tm FROM tbl_a ORDER BY skey; skey dt tm 0 2012-01-01 12:00:00 @@ -88,10 +88,10 @@ Records: 10 Duplicates: 4 Warnings: 0 Bye connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %' OR argument LIKE '%replace %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND (argument LIKE '%insert %' OR argument LIKE '%replace %'); argument replace into `auto_test_remote`.`tbl_a`(`skey`,`dt`,`tm`)values(1,_latin1'2012-02-01',_latin1'12:00:00'),(3,_latin1'2012-12-01',_latin1'11:00:00'),(8,_latin1'2012-11-30',_latin1'11:00:00'),(9,_latin1'2012-11-29',_latin1'11:00:00'),(10,_latin1'2012-11-28',_latin1'11:00:00'),(15,_latin1'2012-11-27',_latin1'11:00:00'),(16,_latin1'2012-11-26',_latin1'11:00:00'),(17,_latin1'2012-11-25',_latin1'11:00:00'),(18,_latin1'2012-11-24',_latin1'11:00:00'),(19,_latin1'2012-11-23',_latin1'11:00:00') -SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %' OR argument LIKE '%replace %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND (argument LIKE '%insert %' OR argument LIKE '%replace %') SELECT skey, dt, tm FROM tbl_a ORDER BY skey; skey dt tm 0 2012-01-01 12:00:00 @@ -131,10 +131,10 @@ Records: 10 Duplicates: 4 Warnings: 0 Bye connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %' OR argument LIKE '%replace %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND (argument LIKE '%insert %' OR argument LIKE '%replace %'); argument insert high_priority into `auto_test_remote`.`tbl_a`(`skey`,`dt`,`tm`)values(1,_latin1'2012-11-01',_latin1'11:00:00'),(3,_latin1'2012-12-01',_latin1'11:00:00'),(11,_latin1'2012-11-30',_latin1'11:00:00'),(15,_latin1'2012-11-29',_latin1'11:00:00'),(16,_latin1'2012-11-28',_latin1'11:00:00'),(20,_latin1'2012-11-27',_latin1'11:00:00'),(21,_latin1'2012-11-26',_latin1'11:00:00'),(22,_latin1'2012-11-25',_latin1'11:00:00'),(23,_latin1'2012-11-24',_latin1'11:00:00'),(24,_latin1'2012-11-23',_latin1'11:00:00') on duplicate key update `dt` = values(`dt`),`tm` = values(`tm`) -SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %' OR argument LIKE '%replace %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND (argument LIKE '%insert %' OR argument LIKE '%replace %') SELECT skey, dt, tm FROM tbl_a ORDER BY skey; skey dt tm 0 2012-01-01 12:00:00 diff --git a/storage/spider/mysql-test/spider/bugfix/r/return_found_rows_update.result b/storage/spider/mysql-test/spider/bugfix/r/return_found_rows_update.result index cd5423ed272..ecca29c8ad0 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/return_found_rows_update.result +++ b/storage/spider/mysql-test/spider/bugfix/r/return_found_rows_update.result @@ -46,10 +46,10 @@ Rows matched: 3 Changed: 2 Warnings: 0 Bye connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%update %'; argument update `auto_test_remote`.`tbl_a` set `tm` = _latin1'12:00:00' where (`skey` = 0) -SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%update %' SELECT skey, dt, tm FROM tbl_a ORDER BY skey; skey dt tm 0 2012-01-01 12:00:00 diff --git a/storage/spider/mysql-test/spider/bugfix/r/select_by_null.result b/storage/spider/mysql-test/spider/bugfix/r/select_by_null.result index a7fa1b3b91f..182dd31a4ba 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/select_by_null.result +++ b/storage/spider/mysql-test/spider/bugfix/r/select_by_null.result @@ -38,9 +38,9 @@ connection master_1; SELECT pkey FROM tbl_a WHERE NULL; pkey connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_a ORDER BY pkey; pkey 0 diff --git a/storage/spider/mysql-test/spider/bugfix/r/select_with_backquote.result b/storage/spider/mysql-test/spider/bugfix/r/select_with_backquote.result index 52f8c98bf98..bfdf8796dbb 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/select_with_backquote.result +++ b/storage/spider/mysql-test/spider/bugfix/r/select_with_backquote.result @@ -42,10 +42,10 @@ pkey LEFT(`txt_utf8`, 4) 2 2345 connection child2_1; SET NAMES utf8; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select t0.`pkey` `pkey`,(left(t0.`txt_utf8` , 4)) `LEFT(``txt_utf8``, 4)` from `auto_test_remote`.`tbl_a` t0 order by `LEFT(``txt_utf8``, 4)` limit 3 -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey, txt_utf8 FROM tbl_a ORDER BY pkey; pkey txt_utf8 0 01234567 diff --git a/storage/spider/mysql-test/spider/bugfix/r/slave_trx_isolation.result b/storage/spider/mysql-test/spider/bugfix/r/slave_trx_isolation.result index 40d85e07a99..e84d42bbc8a 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/slave_trx_isolation.result +++ b/storage/spider/mysql-test/spider/bugfix/r/slave_trx_isolation.result @@ -46,12 +46,12 @@ connection slave1_1; connection master_1; SET SESSION sql_log_bin= 0; connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%set %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%set %'; argument set session time_zone = '+00:00';set @`spider_lc_./auto_test_remote/tbl_a` = '-xxxxxxxxxxxx-xxxxx-./auto_test_local/tbl_a-' SET NAMES utf8mb3 set session transaction isolation level read committed;set session autocommit = 1;set session wait_timeout = 604800;set session sql_mode = 'strict_trans_tables,error_for_division_by_zero,no_auto_create_user,no_engine_substitution';start transaction -SELECT argument FROM mysql.general_log WHERE argument LIKE '%set %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%set %' SELECT pkey FROM tbl_a ORDER BY pkey; pkey 0 diff --git a/storage/spider/mysql-test/spider/bugfix/r/sql_mode_mariadb.result b/storage/spider/mysql-test/spider/bugfix/r/sql_mode_mariadb.result index 1bf6fbccbc9..a0103695d5a 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/sql_mode_mariadb.result +++ b/storage/spider/mysql-test/spider/bugfix/r/sql_mode_mariadb.result @@ -48,10 +48,10 @@ pkey 8 9 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%sql_mode%'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%sql_mode%'; argument set session transaction isolation level repeatable read;set session autocommit = 1;set session sql_log_off = 0;set session wait_timeout = 604800;set session sql_mode = 'real_as_float,ignore_bad_table_options,no_unsigned_subtraction,no_dir_in_create,no_auto_value_on_zero,strict_trans_tables,strict_all_tables,no_zero_in_date,no_zero_date,allow_invalid_dates,error_for_division_by_zero,no_auto_create_user,high_not_precedence,no_engine_substitution,pad_char_to_full_length,empty_string_is_null,simultaneous_assignment,time_round_fractional';set session time_zone = '+00:00';set @`spider_lc_./auto_test_remote/tbl_a` = '-xxxxxxxxxxxx-xxxxx-./auto_test_local/tbl_a-';start transaction -SELECT argument FROM mysql.general_log WHERE argument LIKE '%sql_mode%' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%sql_mode%' SELECT pkey FROM tbl_a ORDER BY pkey; pkey 0 diff --git a/storage/spider/mysql-test/spider/bugfix/r/sql_mode_mysql.result b/storage/spider/mysql-test/spider/bugfix/r/sql_mode_mysql.result index 3ec96a66031..e75378a5e40 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/sql_mode_mysql.result +++ b/storage/spider/mysql-test/spider/bugfix/r/sql_mode_mysql.result @@ -48,10 +48,10 @@ pkey 8 9 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%sql_mode%'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%sql_mode%'; argument set session transaction isolation level repeatable read;set session autocommit = 1;set session sql_log_off = 0;set session wait_timeout = 604800;set session sql_mode = 'real_as_float,ignore_bad_table_options,no_unsigned_subtraction,no_dir_in_create,no_auto_value_on_zero,strict_trans_tables,strict_all_tables,no_zero_in_date,no_zero_date,allow_invalid_dates,error_for_division_by_zero,no_auto_create_user,high_not_precedence,no_engine_substitution,pad_char_to_full_length';set session time_zone = '+00:00';set @`spider_lc_./auto_test_remote/tbl_a` = '-xxxxxxxxxxxx-xxxxx-./auto_test_local/tbl_a-';start transaction -SELECT argument FROM mysql.general_log WHERE argument LIKE '%sql_mode%' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%sql_mode%' SELECT pkey FROM tbl_a ORDER BY pkey; pkey 0 diff --git a/storage/spider/mysql-test/spider/bugfix/r/strict_group_by.result b/storage/spider/mysql-test/spider/bugfix/r/strict_group_by.result index f2287dea65a..7797d0487f9 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/strict_group_by.result +++ b/storage/spider/mysql-test/spider/bugfix/r/strict_group_by.result @@ -57,10 +57,10 @@ SELECT count(pkey) cnt, skey FROM tbl_a; cnt skey 30 1 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select count(`pkey`),min(`pkey`),min(`skey`) from `auto_test_remote`.`tbl_a` -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey, skey FROM tbl_a ORDER BY pkey; pkey skey 1 1 @@ -79,10 +79,10 @@ pkey skey 27 12 29 14 connection child2_2; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select count(`pkey`),min(`pkey`),min(`skey`) from `auto_test_remote2`.`tbl_a` -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey, skey FROM tbl_a ORDER BY pkey; pkey skey 0 0 diff --git a/storage/spider/mysql-test/spider/bugfix/r/wait_timeout.result b/storage/spider/mysql-test/spider/bugfix/r/wait_timeout.result index ec9534f7592..bd4ef0c8090 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/wait_timeout.result +++ b/storage/spider/mysql-test/spider/bugfix/r/wait_timeout.result @@ -60,14 +60,14 @@ connection child2_1_2; SELECT SLEEP(2); SLEEP(2) 0 -SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; argument insert into `auto_test_remote`.`tbl_a`(`pkey`)values(31),(33),(35),(37),(39),(41),(43),(45),(47),(49),(51),(53),(55),(57),(59) -SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %' connection child2_2_2; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; argument -SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %' connection child2_1; UNLOCK TABLES; SELECT pkey FROM tbl_a ORDER BY pkey; diff --git a/storage/spider/mysql-test/spider/bugfix/r/wrapper_mariadb.result b/storage/spider/mysql-test/spider/bugfix/r/wrapper_mariadb.result index 7c01421fa13..ef50d3a31c2 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/wrapper_mariadb.result +++ b/storage/spider/mysql-test/spider/bugfix/r/wrapper_mariadb.result @@ -45,10 +45,10 @@ pkey 8 9 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select t0.`pkey` `pkey` from `auto_test_remote`.`tbl_a` t0 order by `pkey` -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_a ORDER BY pkey; pkey 0 diff --git a/storage/spider/mysql-test/spider/bugfix/r/xa_cmd.result b/storage/spider/mysql-test/spider/bugfix/r/xa_cmd.result index 846dc6c737b..8e1b2994c66 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/xa_cmd.result +++ b/storage/spider/mysql-test/spider/bugfix/r/xa_cmd.result @@ -35,10 +35,10 @@ XA END 'test'; XA PREPARE 'test'; XA COMMIT 'test'; connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; argument insert into `auto_test_remote`.`tbl_a`(`pkey`)values(0),(1),(2),(3),(4),(5),(6),(7),(8),(9) -SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %' SELECT pkey FROM tbl_a ORDER BY pkey; pkey 0 diff --git a/storage/spider/mysql-test/spider/feature/include/checksum_table_parallel_init.inc b/storage/spider/mysql-test/spider/feature/include/checksum_table_parallel_init.inc index 7aab82515a0..73c358b7030 100644 --- a/storage/spider/mysql-test/spider/feature/include/checksum_table_parallel_init.inc +++ b/storage/spider/mysql-test/spider/feature/include/checksum_table_parallel_init.inc @@ -33,7 +33,7 @@ let $CHILD2_1_CREATE_TABLES= let $CHILD2_1_SELECT_TABLES= SELECT pkey FROM tbl_a ORDER BY pkey; let $CHILD2_1_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%checksum %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%checksum %'; --let $CHILD2_2_DROP_TABLES_BACKUP= $CHILD2_2_DROP_TABLES let $CHILD2_2_DROP_TABLES= DROP TABLE IF EXISTS tbl_a; @@ -47,7 +47,7 @@ let $CHILD2_2_CREATE_TABLES= let $CHILD2_2_SELECT_TABLES= SELECT pkey FROM tbl_a ORDER BY pkey; let $CHILD2_2_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%checksum %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%checksum %'; --connection master_1 set @old_spider_bgs_mode= @@spider_bgs_mode; set session spider_bgs_mode= 1; diff --git a/storage/spider/mysql-test/spider/feature/r/checksum_table_parallel_extended.result b/storage/spider/mysql-test/spider/feature/r/checksum_table_parallel_extended.result index 34587052181..91f162a61a9 100644 --- a/storage/spider/mysql-test/spider/feature/r/checksum_table_parallel_extended.result +++ b/storage/spider/mysql-test/spider/feature/r/checksum_table_parallel_extended.result @@ -58,15 +58,15 @@ connection child2_1_2; SELECT SLEEP(1); SLEEP(1) 0 -SELECT argument FROM mysql.general_log WHERE argument LIKE '%checksum %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%checksum %'; argument checksum table `auto_test_remote`.`tbl_a` extended -SELECT argument FROM mysql.general_log WHERE argument LIKE '%checksum %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%checksum %' connection child2_2_2; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%checksum %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%checksum %'; argument checksum table `auto_test_remote2`.`tbl_a` extended -SELECT argument FROM mysql.general_log WHERE argument LIKE '%checksum %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%checksum %' connection child2_1; UNLOCK TABLES; SELECT pkey FROM tbl_a ORDER BY pkey; diff --git a/storage/spider/mysql-test/spider/feature/r/checksum_table_parallel_no_opt.result b/storage/spider/mysql-test/spider/feature/r/checksum_table_parallel_no_opt.result index 4e44bd4cc73..ac114702bf3 100644 --- a/storage/spider/mysql-test/spider/feature/r/checksum_table_parallel_no_opt.result +++ b/storage/spider/mysql-test/spider/feature/r/checksum_table_parallel_no_opt.result @@ -58,13 +58,13 @@ connection child2_1_2; SELECT SLEEP(1); SLEEP(1) 0 -SELECT argument FROM mysql.general_log WHERE argument LIKE '%checksum %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%checksum %'; argument -SELECT argument FROM mysql.general_log WHERE argument LIKE '%checksum %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%checksum %' connection child2_2_2; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%checksum %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%checksum %'; argument -SELECT argument FROM mysql.general_log WHERE argument LIKE '%checksum %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%checksum %' connection child2_1; UNLOCK TABLES; SELECT pkey FROM tbl_a ORDER BY pkey; diff --git a/storage/spider/mysql-test/spider/feature/r/checksum_table_parallel_quick.result b/storage/spider/mysql-test/spider/feature/r/checksum_table_parallel_quick.result index b2c55b34130..34786113f87 100644 --- a/storage/spider/mysql-test/spider/feature/r/checksum_table_parallel_quick.result +++ b/storage/spider/mysql-test/spider/feature/r/checksum_table_parallel_quick.result @@ -58,13 +58,13 @@ connection child2_1_2; SELECT SLEEP(1); SLEEP(1) 0 -SELECT argument FROM mysql.general_log WHERE argument LIKE '%checksum %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%checksum %'; argument -SELECT argument FROM mysql.general_log WHERE argument LIKE '%checksum %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%checksum %' connection child2_2_2; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%checksum %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%checksum %'; argument -SELECT argument FROM mysql.general_log WHERE argument LIKE '%checksum %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%checksum %' connection child2_1; UNLOCK TABLES; SELECT pkey FROM tbl_a ORDER BY pkey; diff --git a/storage/spider/mysql-test/spider/handler/t/basic_sql.test b/storage/spider/mysql-test/spider/handler/t/basic_sql.test index 5bb040047fc..9cf4ce99dc3 100644 --- a/storage/spider/mysql-test/spider/handler/t/basic_sql.test +++ b/storage/spider/mysql-test/spider/handler/t/basic_sql.test @@ -146,7 +146,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -241,7 +241,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -315,7 +315,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%replace %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%replace %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -416,7 +416,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_TABLES3; if (!$OUTPUT_CHILD_GROUP2) @@ -460,7 +460,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -502,7 +502,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -544,7 +544,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -586,7 +586,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -628,7 +628,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -670,7 +670,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -712,7 +712,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -754,7 +754,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -796,7 +796,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -838,7 +838,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -880,7 +880,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -924,7 +924,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -966,7 +966,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -1007,7 +1007,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -1049,7 +1049,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -1091,7 +1091,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -1133,7 +1133,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -1176,7 +1176,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1222,7 +1222,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1269,7 +1269,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1315,7 +1315,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1362,7 +1362,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1406,7 +1406,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1453,10 +1453,10 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1501,10 +1501,10 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1551,10 +1551,10 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'replace %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'replace %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1598,10 +1598,10 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'replace %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'replace %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1646,10 +1646,10 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'replace %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'replace %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1694,10 +1694,10 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'replace %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'replace %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1744,8 +1744,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1790,8 +1790,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1836,8 +1836,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1881,8 +1881,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1927,8 +1927,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1972,8 +1972,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2017,8 +2017,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2062,8 +2062,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2107,8 +2107,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2159,8 +2159,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2204,8 +2204,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2256,8 +2256,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2308,8 +2308,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2360,8 +2360,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2412,8 +2412,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2464,8 +2464,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2516,8 +2516,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2568,8 +2568,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2620,8 +2620,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2665,7 +2665,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE 'truncate %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'truncate %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/handler/t/basic_sql_part.test b/storage/spider/mysql-test/spider/handler/t/basic_sql_part.test index e1638642ab7..1bb18358d5d 100644 --- a/storage/spider/mysql-test/spider/handler/t/basic_sql_part.test +++ b/storage/spider/mysql-test/spider/handler/t/basic_sql_part.test @@ -176,13 +176,13 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_TABLES2; if (!$OUTPUT_CHILD_GROUP2) @@ -235,12 +235,12 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -290,12 +290,12 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -344,15 +344,15 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES2; if (!$OUTPUT_CHILD_GROUP2) @@ -404,15 +404,15 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES2; if (!$OUTPUT_CHILD_GROUP2) @@ -466,15 +466,15 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES2; if (!$OUTPUT_CHILD_GROUP2) @@ -528,15 +528,15 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES2; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/handler/t/direct_aggregate.test b/storage/spider/mysql-test/spider/handler/t/direct_aggregate.test index d65f4c5a624..5c0c37f483d 100644 --- a/storage/spider/mysql-test/spider/handler/t/direct_aggregate.test +++ b/storage/spider/mysql-test/spider/handler/t/direct_aggregate.test @@ -147,7 +147,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%handler %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/handler/t/direct_aggregate_part.test b/storage/spider/mysql-test/spider/handler/t/direct_aggregate_part.test index aebf210c745..cb0b55e9788 100644 --- a/storage/spider/mysql-test/spider/handler/t/direct_aggregate_part.test +++ b/storage/spider/mysql-test/spider/handler/t/direct_aggregate_part.test @@ -153,13 +153,13 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%handler %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%handler %'; } eval $CHILD2_1_SELECT_TABLES2; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/handler/t/direct_update.test b/storage/spider/mysql-test/spider/handler/t/direct_update.test index e0901062201..94f27e2859c 100644 --- a/storage/spider/mysql-test/spider/handler/t/direct_update.test +++ b/storage/spider/mysql-test/spider/handler/t/direct_update.test @@ -166,7 +166,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%handler %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/handler/t/direct_update_part.test b/storage/spider/mysql-test/spider/handler/t/direct_update_part.test index 95e2e2ab0d5..e8f1882594c 100644 --- a/storage/spider/mysql-test/spider/handler/t/direct_update_part.test +++ b/storage/spider/mysql-test/spider/handler/t/direct_update_part.test @@ -172,13 +172,13 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%handler %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%handler %'; } eval $CHILD2_1_SELECT_TABLES2; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/handler/t/function.test b/storage/spider/mysql-test/spider/handler/t/function.test index ec2eeab9c94..2472e774782 100644 --- a/storage/spider/mysql-test/spider/handler/t/function.test +++ b/storage/spider/mysql-test/spider/handler/t/function.test @@ -125,7 +125,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TEXT_PK_TABLES1; if (!$OUTPUT_CHILD_GROUP2) @@ -219,7 +219,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/handler/t/ha.test b/storage/spider/mysql-test/spider/handler/t/ha.test index c12930e4aed..c36b7363a6d 100644 --- a/storage/spider/mysql-test/spider/handler/t/ha.test +++ b/storage/spider/mysql-test/spider/handler/t/ha.test @@ -233,13 +233,13 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -303,7 +303,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -435,13 +435,13 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -623,13 +623,13 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -693,7 +693,7 @@ if ($USE_CHILD_GROUP2) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -799,13 +799,13 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/handler/t/ha_part.test b/storage/spider/mysql-test/spider/handler/t/ha_part.test index 72ddcfd1f10..33fe9850b68 100644 --- a/storage/spider/mysql-test/spider/handler/t/ha_part.test +++ b/storage/spider/mysql-test/spider/handler/t/ha_part.test @@ -274,20 +274,20 @@ if ($HAVE_PARTITION) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; eval $CHILD2_1_SELECT_TABLES2; --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_3 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_3_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -356,14 +356,14 @@ if ($HAVE_PARTITION) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; eval $CHILD2_1_SELECT_TABLES2; --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -501,20 +501,20 @@ if ($HAVE_PARTITION) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; eval $CHILD2_1_SELECT_TABLES2; --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_3 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_3_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -723,20 +723,20 @@ if ($HAVE_PARTITION) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; eval $CHILD2_1_SELECT_TABLES2; --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_3 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_3_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -809,19 +809,19 @@ if ($HAVE_PARTITION) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_3 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_3_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -933,20 +933,20 @@ if ($HAVE_PARTITION) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; eval $CHILD2_1_SELECT_TABLES2; --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_3 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_3_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/handler/t/spider3_fixes.test b/storage/spider/mysql-test/spider/handler/t/spider3_fixes.test index 13fa6f5fa39..64d3b657ae8 100644 --- a/storage/spider/mysql-test/spider/handler/t/spider3_fixes.test +++ b/storage/spider/mysql-test/spider/handler/t/spider3_fixes.test @@ -129,8 +129,10 @@ eval CREATE TABLE t2 ( id int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (id) ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_1; +--disable_ps_protocol eval $MASTER_1_AUTO_INCREMENT_INCREMENT2; eval $MASTER_1_AUTO_INCREMENT_OFFSET2; +--enable_ps_protocol if ($USE_REPLICATION) { SET SESSION sql_log_bin= 1; @@ -241,7 +243,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_INCREMENT_TABLES1; if ($OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/handler/t/spider3_fixes_part.test b/storage/spider/mysql-test/spider/handler/t/spider3_fixes_part.test index 3288c490a46..bcd85f42b81 100644 --- a/storage/spider/mysql-test/spider/handler/t/spider3_fixes_part.test +++ b/storage/spider/mysql-test/spider/handler/t/spider3_fixes_part.test @@ -163,8 +163,10 @@ if ($HAVE_PARTITION) id int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (id) ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_P_1; + --disable_ps_protocol eval $MASTER_1_AUTO_INCREMENT_INCREMENT2; eval $MASTER_1_AUTO_INCREMENT_OFFSET2; + --enable_ps_protocol if ($USE_REPLICATION) { SET SESSION sql_log_bin= 1; @@ -275,7 +277,7 @@ if ($HAVE_PARTITION) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_INCREMENT_TABLES1; if ($OUTPUT_CHILD_GROUP2) @@ -293,7 +295,7 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_2_SELECT_INCREMENT_TABLES1; if ($OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/handler/t/spider_fixes.test b/storage/spider/mysql-test/spider/handler/t/spider_fixes.test index 04e806fb612..9f7ada052ed 100644 --- a/storage/spider/mysql-test/spider/handler/t/spider_fixes.test +++ b/storage/spider/mysql-test/spider/handler/t/spider_fixes.test @@ -164,7 +164,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -206,7 +206,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -248,7 +248,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -337,7 +337,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -359,7 +359,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -381,7 +381,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -403,7 +403,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -425,7 +425,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -447,7 +447,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -469,7 +469,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -491,7 +491,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -513,7 +513,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -535,7 +535,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -557,7 +557,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -579,7 +579,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -676,7 +676,7 @@ if ($HAVE_TRIGGER) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_TABLES4; if (!$OUTPUT_CHILD_GROUP2) @@ -722,7 +722,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -812,7 +812,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -899,8 +899,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%update %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -1073,8 +1073,10 @@ eval CREATE TABLE t1 ( id int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (id) ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_1; +--disable_ps_protocol eval $MASTER_1_AUTO_INCREMENT_INCREMENT2; eval $MASTER_1_AUTO_INCREMENT_OFFSET2; +--enable_ps_protocol if ($USE_REPLICATION) { SET SESSION sql_log_bin= 1; @@ -1139,7 +1141,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_INCREMENT_TABLES1; if ($OUTPUT_CHILD_GROUP2) @@ -1324,7 +1326,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TEXT_PK_TABLES1; if (!$OUTPUT_CHILD_GROUP2) @@ -1380,7 +1382,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TEXT_PK_TABLES1; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/handler/t/spider_fixes_part.test b/storage/spider/mysql-test/spider/handler/t/spider_fixes_part.test index ef5a8026c02..e6c4456edcb 100644 --- a/storage/spider/mysql-test/spider/handler/t/spider_fixes_part.test +++ b/storage/spider/mysql-test/spider/handler/t/spider_fixes_part.test @@ -176,13 +176,13 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES2; if (!$OUTPUT_CHILD_GROUP2) @@ -281,19 +281,19 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%delete %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%delete %'; } eval $CHILD2_1_SELECT_TABLES2; if (!$OUTPUT_CHILD_GROUP2) @@ -404,12 +404,12 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -509,8 +509,10 @@ if ($HAVE_PARTITION) id int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (id) ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_P_1; + --disable_ps_protocol eval $MASTER_1_AUTO_INCREMENT_INCREMENT2; eval $MASTER_1_AUTO_INCREMENT_OFFSET2; + --enable_ps_protocol if ($USE_REPLICATION) { SET SESSION sql_log_bin= 1; @@ -575,7 +577,7 @@ if ($HAVE_PARTITION) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_INCREMENT_TABLES1; if ($OUTPUT_CHILD_GROUP2) @@ -593,7 +595,7 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_2_SELECT_INCREMENT_TABLES1; if ($OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/handler/t/vp_fixes.test b/storage/spider/mysql-test/spider/handler/t/vp_fixes.test index 90380227040..2c3e1523611 100644 --- a/storage/spider/mysql-test/spider/handler/t/vp_fixes.test +++ b/storage/spider/mysql-test/spider/handler/t/vp_fixes.test @@ -206,7 +206,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_TABLES5; if (!$OUTPUT_CHILD_GROUP2) @@ -303,7 +303,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_TABLES5; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/include/checksum_table_with_quick_mode_3_init.inc b/storage/spider/mysql-test/spider/include/checksum_table_with_quick_mode_3_init.inc index 0bb12d8f874..43a98da58e1 100644 --- a/storage/spider/mysql-test/spider/include/checksum_table_with_quick_mode_3_init.inc +++ b/storage/spider/mysql-test/spider/include/checksum_table_with_quick_mode_3_init.inc @@ -21,7 +21,7 @@ let $CHILD2_1_CREATE_TABLES= let $CHILD2_1_SELECT_TABLES= SELECT pkey FROM tbl_a ORDER BY pkey; let $CHILD2_1_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%checksum %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%checksum %'; --let $OUTPUT_CHILD_GROUP2_BACKUP= $OUTPUT_CHILD_GROUP2 --let $OUTPUT_CHILD_GROUP2= 1 --let $USE_GENERAL_LOG_BACKUP= $USE_GENERAL_LOG diff --git a/storage/spider/mysql-test/spider/include/direct_join_init.inc b/storage/spider/mysql-test/spider/include/direct_join_init.inc index 25c5e7ca39b..8e51cea3db3 100644 --- a/storage/spider/mysql-test/spider/include/direct_join_init.inc +++ b/storage/spider/mysql-test/spider/include/direct_join_init.inc @@ -46,7 +46,7 @@ let $CHILD2_1_SELECT_CONST_TABLE_JOIN= let $CHILD2_1_SELECT_CONST_TABLE2_JOIN= SELECT * FROM tbl_ncd_cm_person; let $CHILD2_1_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; --let $OUTPUT_CHILD_GROUP2_BACKUP= $OUTPUT_CHILD_GROUP2 --let $OUTPUT_CHILD_GROUP2= 1 --let $USE_GENERAL_LOG_BACKUP= $USE_GENERAL_LOG diff --git a/storage/spider/mysql-test/spider/include/direct_join_using_init.inc b/storage/spider/mysql-test/spider/include/direct_join_using_init.inc index 7e4947bf078..77afbc14d9a 100644 --- a/storage/spider/mysql-test/spider/include/direct_join_using_init.inc +++ b/storage/spider/mysql-test/spider/include/direct_join_using_init.inc @@ -6,7 +6,7 @@ --enable_query_log --enable_warnings let $CHILD2_1_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; --let $OUTPUT_CHILD_GROUP2_BACKUP= $OUTPUT_CHILD_GROUP2 --let $OUTPUT_CHILD_GROUP2= 1 --let $USE_GENERAL_LOG_BACKUP= $USE_GENERAL_LOG diff --git a/storage/spider/mysql-test/spider/include/direct_left_join_init.inc b/storage/spider/mysql-test/spider/include/direct_left_join_init.inc index 7e4947bf078..77afbc14d9a 100644 --- a/storage/spider/mysql-test/spider/include/direct_left_join_init.inc +++ b/storage/spider/mysql-test/spider/include/direct_left_join_init.inc @@ -6,7 +6,7 @@ --enable_query_log --enable_warnings let $CHILD2_1_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; --let $OUTPUT_CHILD_GROUP2_BACKUP= $OUTPUT_CHILD_GROUP2 --let $OUTPUT_CHILD_GROUP2= 1 --let $USE_GENERAL_LOG_BACKUP= $USE_GENERAL_LOG diff --git a/storage/spider/mysql-test/spider/include/direct_left_join_nullable_init.inc b/storage/spider/mysql-test/spider/include/direct_left_join_nullable_init.inc index 7e4947bf078..77afbc14d9a 100644 --- a/storage/spider/mysql-test/spider/include/direct_left_join_nullable_init.inc +++ b/storage/spider/mysql-test/spider/include/direct_left_join_nullable_init.inc @@ -6,7 +6,7 @@ --enable_query_log --enable_warnings let $CHILD2_1_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; --let $OUTPUT_CHILD_GROUP2_BACKUP= $OUTPUT_CHILD_GROUP2 --let $OUTPUT_CHILD_GROUP2= 1 --let $USE_GENERAL_LOG_BACKUP= $USE_GENERAL_LOG diff --git a/storage/spider/mysql-test/spider/include/direct_left_right_join_nullable_init.inc b/storage/spider/mysql-test/spider/include/direct_left_right_join_nullable_init.inc index 7e4947bf078..77afbc14d9a 100644 --- a/storage/spider/mysql-test/spider/include/direct_left_right_join_nullable_init.inc +++ b/storage/spider/mysql-test/spider/include/direct_left_right_join_nullable_init.inc @@ -6,7 +6,7 @@ --enable_query_log --enable_warnings let $CHILD2_1_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; --let $OUTPUT_CHILD_GROUP2_BACKUP= $OUTPUT_CHILD_GROUP2 --let $OUTPUT_CHILD_GROUP2= 1 --let $USE_GENERAL_LOG_BACKUP= $USE_GENERAL_LOG diff --git a/storage/spider/mysql-test/spider/include/direct_left_right_left_join_nullable_init.inc b/storage/spider/mysql-test/spider/include/direct_left_right_left_join_nullable_init.inc index 7e4947bf078..77afbc14d9a 100644 --- a/storage/spider/mysql-test/spider/include/direct_left_right_left_join_nullable_init.inc +++ b/storage/spider/mysql-test/spider/include/direct_left_right_left_join_nullable_init.inc @@ -6,7 +6,7 @@ --enable_query_log --enable_warnings let $CHILD2_1_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; --let $OUTPUT_CHILD_GROUP2_BACKUP= $OUTPUT_CHILD_GROUP2 --let $OUTPUT_CHILD_GROUP2= 1 --let $USE_GENERAL_LOG_BACKUP= $USE_GENERAL_LOG diff --git a/storage/spider/mysql-test/spider/include/direct_right_join_init.inc b/storage/spider/mysql-test/spider/include/direct_right_join_init.inc index 7e4947bf078..77afbc14d9a 100644 --- a/storage/spider/mysql-test/spider/include/direct_right_join_init.inc +++ b/storage/spider/mysql-test/spider/include/direct_right_join_init.inc @@ -6,7 +6,7 @@ --enable_query_log --enable_warnings let $CHILD2_1_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; --let $OUTPUT_CHILD_GROUP2_BACKUP= $OUTPUT_CHILD_GROUP2 --let $OUTPUT_CHILD_GROUP2= 1 --let $USE_GENERAL_LOG_BACKUP= $USE_GENERAL_LOG diff --git a/storage/spider/mysql-test/spider/include/direct_right_join_nullable_init.inc b/storage/spider/mysql-test/spider/include/direct_right_join_nullable_init.inc index 7e4947bf078..77afbc14d9a 100644 --- a/storage/spider/mysql-test/spider/include/direct_right_join_nullable_init.inc +++ b/storage/spider/mysql-test/spider/include/direct_right_join_nullable_init.inc @@ -6,7 +6,7 @@ --enable_query_log --enable_warnings let $CHILD2_1_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; --let $OUTPUT_CHILD_GROUP2_BACKUP= $OUTPUT_CHILD_GROUP2 --let $OUTPUT_CHILD_GROUP2= 1 --let $USE_GENERAL_LOG_BACKUP= $USE_GENERAL_LOG diff --git a/storage/spider/mysql-test/spider/include/direct_right_left_join_nullable_init.inc b/storage/spider/mysql-test/spider/include/direct_right_left_join_nullable_init.inc index 7e4947bf078..77afbc14d9a 100644 --- a/storage/spider/mysql-test/spider/include/direct_right_left_join_nullable_init.inc +++ b/storage/spider/mysql-test/spider/include/direct_right_left_join_nullable_init.inc @@ -6,7 +6,7 @@ --enable_query_log --enable_warnings let $CHILD2_1_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; --let $OUTPUT_CHILD_GROUP2_BACKUP= $OUTPUT_CHILD_GROUP2 --let $OUTPUT_CHILD_GROUP2= 1 --let $USE_GENERAL_LOG_BACKUP= $USE_GENERAL_LOG diff --git a/storage/spider/mysql-test/spider/include/direct_right_left_right_join_nullable_init.inc b/storage/spider/mysql-test/spider/include/direct_right_left_right_join_nullable_init.inc index 7e4947bf078..77afbc14d9a 100644 --- a/storage/spider/mysql-test/spider/include/direct_right_left_right_join_nullable_init.inc +++ b/storage/spider/mysql-test/spider/include/direct_right_left_right_join_nullable_init.inc @@ -6,7 +6,7 @@ --enable_query_log --enable_warnings let $CHILD2_1_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; --let $OUTPUT_CHILD_GROUP2_BACKUP= $OUTPUT_CHILD_GROUP2 --let $OUTPUT_CHILD_GROUP2= 1 --let $USE_GENERAL_LOG_BACKUP= $USE_GENERAL_LOG diff --git a/storage/spider/mysql-test/spider/include/partition_cond_push_init.inc b/storage/spider/mysql-test/spider/include/partition_cond_push_init.inc index 30a333d6699..40a0923c850 100644 --- a/storage/spider/mysql-test/spider/include/partition_cond_push_init.inc +++ b/storage/spider/mysql-test/spider/include/partition_cond_push_init.inc @@ -25,7 +25,7 @@ let $CHILD2_1_CREATE_TABLES= let $CHILD2_1_SELECT_TABLES= SELECT value FROM tbl_a ORDER BY value; let $CHILD2_1_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; --let $CHILD2_2_DROP_TABLES_BACKUP= $CHILD2_2_DROP_TABLES let $CHILD2_2_DROP_TABLES= DROP TABLE IF EXISTS tbl_a; @@ -38,7 +38,7 @@ let $CHILD2_2_CREATE_TABLES= let $CHILD2_2_SELECT_TABLES= SELECT value FROM tbl_a ORDER BY value; let $CHILD2_2_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; --let $CHILD2_3_DROP_TABLES_BACKUP= $CHILD2_3_DROP_TABLES let $CHILD2_3_DROP_TABLES= DROP TABLE IF EXISTS tbl_a; @@ -51,7 +51,7 @@ let $CHILD2_3_CREATE_TABLES= let $CHILD2_3_SELECT_TABLES= SELECT value FROM tbl_a ORDER BY value; let $CHILD2_3_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; --let $OUTPUT_CHILD_GROUP2_BACKUP= $OUTPUT_CHILD_GROUP2 --let $OUTPUT_CHILD_GROUP2= 1 --let $USE_GENERAL_LOG_BACKUP= $USE_GENERAL_LOG diff --git a/storage/spider/mysql-test/spider/include/partition_fulltext_init.inc b/storage/spider/mysql-test/spider/include/partition_fulltext_init.inc index 754395493af..aaceeee4b38 100644 --- a/storage/spider/mysql-test/spider/include/partition_fulltext_init.inc +++ b/storage/spider/mysql-test/spider/include/partition_fulltext_init.inc @@ -28,7 +28,7 @@ let $CHILD2_1_CREATE_TABLES= let $CHILD2_1_SELECT_TABLES= SELECT pkey FROM tbl_a ORDER BY pkey; let $CHILD2_1_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; --let $CHILD2_2_DROP_TABLES_BACKUP= $CHILD2_2_DROP_TABLES let $CHILD2_2_DROP_TABLES= DROP TABLE IF EXISTS tbl_a; @@ -44,7 +44,7 @@ let $CHILD2_2_CREATE_TABLES= let $CHILD2_2_SELECT_TABLES= SELECT pkey FROM tbl_a ORDER BY pkey; let $CHILD2_2_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; --let $CHILD2_3_DROP_TABLES_BACKUP= $CHILD2_3_DROP_TABLES let $CHILD2_3_DROP_TABLES= DROP TABLE IF EXISTS tbl_a; @@ -60,7 +60,7 @@ let $CHILD2_3_CREATE_TABLES= let $CHILD2_3_SELECT_TABLES= SELECT pkey FROM tbl_a ORDER BY pkey; let $CHILD2_3_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; --let $OUTPUT_CHILD_GROUP2_BACKUP= $OUTPUT_CHILD_GROUP2 --let $OUTPUT_CHILD_GROUP2= 1 --let $USE_GENERAL_LOG_BACKUP= $USE_GENERAL_LOG diff --git a/storage/spider/mysql-test/spider/include/partition_join_pushdown_for_single_partition_init.inc b/storage/spider/mysql-test/spider/include/partition_join_pushdown_for_single_partition_init.inc index dccffa60c0d..64e4e2a13a7 100644 --- a/storage/spider/mysql-test/spider/include/partition_join_pushdown_for_single_partition_init.inc +++ b/storage/spider/mysql-test/spider/include/partition_join_pushdown_for_single_partition_init.inc @@ -46,7 +46,7 @@ let $CHILD2_1_CREATE_TABLES2= let $CHILD2_1_SELECT_TABLES2= SELECT value FROM tbl_b ORDER BY value2; let $CHILD2_1_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; --let $CHILD2_2_DROP_TABLES_BACKUP= $CHILD2_2_DROP_TABLES let $CHILD2_2_DROP_TABLES= DROP TABLE IF EXISTS tbl_a; @@ -72,7 +72,7 @@ let $CHILD2_2_CREATE_TABLES2= let $CHILD2_2_SELECT_TABLES2= SELECT value FROM tbl_b ORDER BY value; let $CHILD2_2_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; --let $CHILD2_3_DROP_TABLES_BACKUP= $CHILD2_3_DROP_TABLES let $CHILD2_3_DROP_TABLES= DROP TABLE IF EXISTS tbl_a; @@ -98,7 +98,7 @@ let $CHILD2_3_CREATE_TABLES2= let $CHILD2_3_SELECT_TABLES2= SELECT value FROM tbl_b ORDER BY value; let $CHILD2_3_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; --let $OUTPUT_CHILD_GROUP2_BACKUP= $OUTPUT_CHILD_GROUP2 --let $OUTPUT_CHILD_GROUP2= 1 --let $USE_GENERAL_LOG_BACKUP= $USE_GENERAL_LOG diff --git a/storage/spider/mysql-test/spider/include/partition_mrr_init.inc b/storage/spider/mysql-test/spider/include/partition_mrr_init.inc index 03e113940a7..82e13595493 100644 --- a/storage/spider/mysql-test/spider/include/partition_mrr_init.inc +++ b/storage/spider/mysql-test/spider/include/partition_mrr_init.inc @@ -40,7 +40,7 @@ let $CHILD2_1_SELECT_TABLES= SELECT pkey FROM tbl_a ORDER BY pkey $STR_SEMICOLON SELECT pkey FROM tbl_b ORDER BY pkey; let $CHILD2_1_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; --let $CHILD2_2_DROP_TABLES_BACKUP= $CHILD2_2_DROP_TABLES let $CHILD2_2_DROP_TABLES= DROP TABLE IF EXISTS tbl_a $STR_SEMICOLON @@ -60,7 +60,7 @@ let $CHILD2_2_SELECT_TABLES= SELECT pkey FROM tbl_a ORDER BY pkey $STR_SEMICOLON SELECT pkey FROM tbl_b ORDER BY pkey; let $CHILD2_2_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; --let $CHILD2_3_DROP_TABLES_BACKUP= $CHILD2_3_DROP_TABLES let $CHILD2_3_DROP_TABLES= DROP TABLE IF EXISTS tbl_a $STR_SEMICOLON @@ -80,7 +80,7 @@ let $CHILD2_3_SELECT_TABLES= SELECT pkey FROM tbl_a ORDER BY pkey $STR_SEMICOLON SELECT pkey FROM tbl_b ORDER BY pkey; let $CHILD2_3_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; --let $OUTPUT_CHILD_GROUP2_BACKUP= $OUTPUT_CHILD_GROUP2 --let $OUTPUT_CHILD_GROUP2= 1 --let $USE_GENERAL_LOG_BACKUP= $USE_GENERAL_LOG diff --git a/storage/spider/mysql-test/spider/include/quick_mode_0_init.inc b/storage/spider/mysql-test/spider/include/quick_mode_0_init.inc index 92afb3bf10b..8f525d203af 100644 --- a/storage/spider/mysql-test/spider/include/quick_mode_0_init.inc +++ b/storage/spider/mysql-test/spider/include/quick_mode_0_init.inc @@ -24,7 +24,7 @@ let $CHILD2_1_CREATE_TABLES= let $CHILD2_1_SELECT_TABLES= SELECT pkey FROM tbl_a ORDER BY pkey; let $CHILD2_1_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; --let $CHILD2_2_DROP_TABLES_BACKUP= $CHILD2_2_DROP_TABLES let $CHILD2_2_DROP_TABLES= DROP TABLE IF EXISTS tbl_b; @@ -38,7 +38,7 @@ let $CHILD2_2_CREATE_TABLES= let $CHILD2_2_SELECT_TABLES= SELECT pkey FROM tbl_b ORDER BY pkey; let $CHILD2_2_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; --let $OUTPUT_CHILD_GROUP2_BACKUP= $OUTPUT_CHILD_GROUP2 --let $OUTPUT_CHILD_GROUP2= 1 --let $USE_GENERAL_LOG_BACKUP= $USE_GENERAL_LOG diff --git a/storage/spider/mysql-test/spider/include/quick_mode_1_init.inc b/storage/spider/mysql-test/spider/include/quick_mode_1_init.inc index cc5a847fdc0..caab7a07e3e 100644 --- a/storage/spider/mysql-test/spider/include/quick_mode_1_init.inc +++ b/storage/spider/mysql-test/spider/include/quick_mode_1_init.inc @@ -24,7 +24,7 @@ let $CHILD2_1_CREATE_TABLES= let $CHILD2_1_SELECT_TABLES= SELECT pkey FROM tbl_a ORDER BY pkey; let $CHILD2_1_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; --let $CHILD2_2_DROP_TABLES_BACKUP= $CHILD2_2_DROP_TABLES let $CHILD2_2_DROP_TABLES= DROP TABLE IF EXISTS tbl_b; @@ -38,7 +38,7 @@ let $CHILD2_2_CREATE_TABLES= let $CHILD2_2_SELECT_TABLES= SELECT pkey FROM tbl_b ORDER BY pkey; let $CHILD2_2_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; --let $OUTPUT_CHILD_GROUP2_BACKUP= $OUTPUT_CHILD_GROUP2 --let $OUTPUT_CHILD_GROUP2= 1 --let $USE_GENERAL_LOG_BACKUP= $USE_GENERAL_LOG diff --git a/storage/spider/mysql-test/spider/include/quick_mode_2_init.inc b/storage/spider/mysql-test/spider/include/quick_mode_2_init.inc index 3a16bb1dc63..b91246ed020 100644 --- a/storage/spider/mysql-test/spider/include/quick_mode_2_init.inc +++ b/storage/spider/mysql-test/spider/include/quick_mode_2_init.inc @@ -24,7 +24,7 @@ let $CHILD2_1_CREATE_TABLES= let $CHILD2_1_SELECT_TABLES= SELECT pkey FROM tbl_a ORDER BY pkey; let $CHILD2_1_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; --let $CHILD2_2_DROP_TABLES_BACKUP= $CHILD2_2_DROP_TABLES let $CHILD2_2_DROP_TABLES= DROP TABLE IF EXISTS tbl_b; @@ -38,7 +38,7 @@ let $CHILD2_2_CREATE_TABLES= let $CHILD2_2_SELECT_TABLES= SELECT pkey FROM tbl_b ORDER BY pkey; let $CHILD2_2_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; --let $OUTPUT_CHILD_GROUP2_BACKUP= $OUTPUT_CHILD_GROUP2 --let $OUTPUT_CHILD_GROUP2= 1 --let $USE_GENERAL_LOG_BACKUP= $USE_GENERAL_LOG diff --git a/storage/spider/mysql-test/spider/include/quick_mode_3_init.inc b/storage/spider/mysql-test/spider/include/quick_mode_3_init.inc index df7d713c4c7..4b5a8edcc9a 100644 --- a/storage/spider/mysql-test/spider/include/quick_mode_3_init.inc +++ b/storage/spider/mysql-test/spider/include/quick_mode_3_init.inc @@ -24,7 +24,7 @@ let $CHILD2_1_CREATE_TABLES= let $CHILD2_1_SELECT_TABLES= SELECT pkey FROM tbl_a ORDER BY pkey; let $CHILD2_1_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; --let $CHILD2_2_DROP_TABLES_BACKUP= $CHILD2_2_DROP_TABLES let $CHILD2_2_DROP_TABLES= DROP TABLE IF EXISTS tbl_b; @@ -38,7 +38,7 @@ let $CHILD2_2_CREATE_TABLES= let $CHILD2_2_SELECT_TABLES= SELECT pkey FROM tbl_b ORDER BY pkey; let $CHILD2_2_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; --let $OUTPUT_CHILD_GROUP2_BACKUP= $OUTPUT_CHILD_GROUP2 --let $OUTPUT_CHILD_GROUP2= 1 --let $USE_GENERAL_LOG_BACKUP= $USE_GENERAL_LOG diff --git a/storage/spider/mysql-test/spider/include/slave_trx_isolation_init.inc b/storage/spider/mysql-test/spider/include/slave_trx_isolation_init.inc index 94ccf1d3295..67ac5e7169e 100644 --- a/storage/spider/mysql-test/spider/include/slave_trx_isolation_init.inc +++ b/storage/spider/mysql-test/spider/include/slave_trx_isolation_init.inc @@ -22,7 +22,7 @@ let $CHILD2_1_CREATE_TABLES= let $CHILD2_1_SELECT_TABLES= SELECT pkey FROM tbl_a ORDER BY pkey; let $CHILD2_1_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%set %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%set %'; --let $OUTPUT_CHILD_GROUP2_BACKUP= $OUTPUT_CHILD_GROUP2 --let $OUTPUT_CHILD_GROUP2= 1 --let $USE_GENERAL_LOG_BACKUP= $USE_GENERAL_LOG diff --git a/storage/spider/mysql-test/spider/oracle/t/basic_sql.test b/storage/spider/mysql-test/spider/oracle/t/basic_sql.test index 5bb040047fc..9cf4ce99dc3 100644 --- a/storage/spider/mysql-test/spider/oracle/t/basic_sql.test +++ b/storage/spider/mysql-test/spider/oracle/t/basic_sql.test @@ -146,7 +146,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -241,7 +241,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -315,7 +315,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%replace %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%replace %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -416,7 +416,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_TABLES3; if (!$OUTPUT_CHILD_GROUP2) @@ -460,7 +460,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -502,7 +502,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -544,7 +544,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -586,7 +586,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -628,7 +628,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -670,7 +670,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -712,7 +712,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -754,7 +754,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -796,7 +796,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -838,7 +838,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -880,7 +880,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -924,7 +924,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -966,7 +966,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -1007,7 +1007,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -1049,7 +1049,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -1091,7 +1091,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -1133,7 +1133,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -1176,7 +1176,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1222,7 +1222,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1269,7 +1269,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1315,7 +1315,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1362,7 +1362,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1406,7 +1406,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1453,10 +1453,10 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1501,10 +1501,10 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1551,10 +1551,10 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'replace %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'replace %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1598,10 +1598,10 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'replace %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'replace %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1646,10 +1646,10 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'replace %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'replace %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1694,10 +1694,10 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'replace %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'replace %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1744,8 +1744,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1790,8 +1790,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1836,8 +1836,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1881,8 +1881,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1927,8 +1927,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1972,8 +1972,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2017,8 +2017,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2062,8 +2062,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2107,8 +2107,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2159,8 +2159,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2204,8 +2204,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2256,8 +2256,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2308,8 +2308,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2360,8 +2360,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2412,8 +2412,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2464,8 +2464,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2516,8 +2516,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2568,8 +2568,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2620,8 +2620,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2665,7 +2665,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE 'truncate %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'truncate %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/oracle/t/basic_sql_part.test b/storage/spider/mysql-test/spider/oracle/t/basic_sql_part.test index e1638642ab7..1bb18358d5d 100644 --- a/storage/spider/mysql-test/spider/oracle/t/basic_sql_part.test +++ b/storage/spider/mysql-test/spider/oracle/t/basic_sql_part.test @@ -176,13 +176,13 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_TABLES2; if (!$OUTPUT_CHILD_GROUP2) @@ -235,12 +235,12 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -290,12 +290,12 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -344,15 +344,15 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES2; if (!$OUTPUT_CHILD_GROUP2) @@ -404,15 +404,15 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES2; if (!$OUTPUT_CHILD_GROUP2) @@ -466,15 +466,15 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES2; if (!$OUTPUT_CHILD_GROUP2) @@ -528,15 +528,15 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES2; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/oracle/t/direct_aggregate.test b/storage/spider/mysql-test/spider/oracle/t/direct_aggregate.test index d65f4c5a624..5c0c37f483d 100644 --- a/storage/spider/mysql-test/spider/oracle/t/direct_aggregate.test +++ b/storage/spider/mysql-test/spider/oracle/t/direct_aggregate.test @@ -147,7 +147,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%handler %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/oracle/t/direct_aggregate_part.test b/storage/spider/mysql-test/spider/oracle/t/direct_aggregate_part.test index aebf210c745..cb0b55e9788 100644 --- a/storage/spider/mysql-test/spider/oracle/t/direct_aggregate_part.test +++ b/storage/spider/mysql-test/spider/oracle/t/direct_aggregate_part.test @@ -153,13 +153,13 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%handler %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%handler %'; } eval $CHILD2_1_SELECT_TABLES2; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/oracle/t/direct_update.test b/storage/spider/mysql-test/spider/oracle/t/direct_update.test index e0901062201..94f27e2859c 100644 --- a/storage/spider/mysql-test/spider/oracle/t/direct_update.test +++ b/storage/spider/mysql-test/spider/oracle/t/direct_update.test @@ -166,7 +166,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%handler %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/oracle/t/direct_update_part.test b/storage/spider/mysql-test/spider/oracle/t/direct_update_part.test index 95e2e2ab0d5..e8f1882594c 100644 --- a/storage/spider/mysql-test/spider/oracle/t/direct_update_part.test +++ b/storage/spider/mysql-test/spider/oracle/t/direct_update_part.test @@ -172,13 +172,13 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%handler %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%handler %'; } eval $CHILD2_1_SELECT_TABLES2; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/oracle/t/function.test b/storage/spider/mysql-test/spider/oracle/t/function.test index ec2eeab9c94..2472e774782 100644 --- a/storage/spider/mysql-test/spider/oracle/t/function.test +++ b/storage/spider/mysql-test/spider/oracle/t/function.test @@ -125,7 +125,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TEXT_PK_TABLES1; if (!$OUTPUT_CHILD_GROUP2) @@ -219,7 +219,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/oracle/t/ha.test b/storage/spider/mysql-test/spider/oracle/t/ha.test index c12930e4aed..c36b7363a6d 100644 --- a/storage/spider/mysql-test/spider/oracle/t/ha.test +++ b/storage/spider/mysql-test/spider/oracle/t/ha.test @@ -233,13 +233,13 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -303,7 +303,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -435,13 +435,13 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -623,13 +623,13 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -693,7 +693,7 @@ if ($USE_CHILD_GROUP2) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -799,13 +799,13 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/oracle/t/ha_part.test b/storage/spider/mysql-test/spider/oracle/t/ha_part.test index 72ddcfd1f10..33fe9850b68 100644 --- a/storage/spider/mysql-test/spider/oracle/t/ha_part.test +++ b/storage/spider/mysql-test/spider/oracle/t/ha_part.test @@ -274,20 +274,20 @@ if ($HAVE_PARTITION) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; eval $CHILD2_1_SELECT_TABLES2; --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_3 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_3_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -356,14 +356,14 @@ if ($HAVE_PARTITION) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; eval $CHILD2_1_SELECT_TABLES2; --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -501,20 +501,20 @@ if ($HAVE_PARTITION) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; eval $CHILD2_1_SELECT_TABLES2; --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_3 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_3_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -723,20 +723,20 @@ if ($HAVE_PARTITION) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; eval $CHILD2_1_SELECT_TABLES2; --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_3 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_3_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -809,19 +809,19 @@ if ($HAVE_PARTITION) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_3 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_3_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -933,20 +933,20 @@ if ($HAVE_PARTITION) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; eval $CHILD2_1_SELECT_TABLES2; --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_3 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_3_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/oracle/t/spider3_fixes.test b/storage/spider/mysql-test/spider/oracle/t/spider3_fixes.test index 13fa6f5fa39..962abbad19f 100644 --- a/storage/spider/mysql-test/spider/oracle/t/spider3_fixes.test +++ b/storage/spider/mysql-test/spider/oracle/t/spider3_fixes.test @@ -241,7 +241,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_INCREMENT_TABLES1; if ($OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/oracle/t/spider3_fixes_part.test b/storage/spider/mysql-test/spider/oracle/t/spider3_fixes_part.test index 3288c490a46..c609108ca9e 100644 --- a/storage/spider/mysql-test/spider/oracle/t/spider3_fixes_part.test +++ b/storage/spider/mysql-test/spider/oracle/t/spider3_fixes_part.test @@ -275,7 +275,7 @@ if ($HAVE_PARTITION) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_INCREMENT_TABLES1; if ($OUTPUT_CHILD_GROUP2) @@ -293,7 +293,7 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_2_SELECT_INCREMENT_TABLES1; if ($OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/oracle/t/spider_fixes.test b/storage/spider/mysql-test/spider/oracle/t/spider_fixes.test index 04e806fb612..d0158c7dc0b 100644 --- a/storage/spider/mysql-test/spider/oracle/t/spider_fixes.test +++ b/storage/spider/mysql-test/spider/oracle/t/spider_fixes.test @@ -164,7 +164,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -206,7 +206,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -248,7 +248,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -337,7 +337,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -359,7 +359,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -381,7 +381,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -403,7 +403,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -425,7 +425,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -447,7 +447,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -469,7 +469,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -491,7 +491,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -513,7 +513,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -535,7 +535,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -557,7 +557,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -579,7 +579,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -676,7 +676,7 @@ if ($HAVE_TRIGGER) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_TABLES4; if (!$OUTPUT_CHILD_GROUP2) @@ -722,7 +722,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -812,7 +812,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -899,8 +899,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%update %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -1139,7 +1139,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_INCREMENT_TABLES1; if ($OUTPUT_CHILD_GROUP2) @@ -1324,7 +1324,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TEXT_PK_TABLES1; if (!$OUTPUT_CHILD_GROUP2) @@ -1380,7 +1380,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TEXT_PK_TABLES1; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/oracle/t/spider_fixes_part.test b/storage/spider/mysql-test/spider/oracle/t/spider_fixes_part.test index ef5a8026c02..3053b0008e7 100644 --- a/storage/spider/mysql-test/spider/oracle/t/spider_fixes_part.test +++ b/storage/spider/mysql-test/spider/oracle/t/spider_fixes_part.test @@ -176,13 +176,13 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES2; if (!$OUTPUT_CHILD_GROUP2) @@ -281,19 +281,19 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%delete %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%delete %'; } eval $CHILD2_1_SELECT_TABLES2; if (!$OUTPUT_CHILD_GROUP2) @@ -404,12 +404,12 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -575,7 +575,7 @@ if ($HAVE_PARTITION) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_INCREMENT_TABLES1; if ($OUTPUT_CHILD_GROUP2) @@ -593,7 +593,7 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_2_SELECT_INCREMENT_TABLES1; if ($OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/oracle/t/vp_fixes.test b/storage/spider/mysql-test/spider/oracle/t/vp_fixes.test index 90380227040..2c3e1523611 100644 --- a/storage/spider/mysql-test/spider/oracle/t/vp_fixes.test +++ b/storage/spider/mysql-test/spider/oracle/t/vp_fixes.test @@ -206,7 +206,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_TABLES5; if (!$OUTPUT_CHILD_GROUP2) @@ -303,7 +303,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_TABLES5; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/oracle2/t/basic_sql.test b/storage/spider/mysql-test/spider/oracle2/t/basic_sql.test index 5bb040047fc..9cf4ce99dc3 100644 --- a/storage/spider/mysql-test/spider/oracle2/t/basic_sql.test +++ b/storage/spider/mysql-test/spider/oracle2/t/basic_sql.test @@ -146,7 +146,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -241,7 +241,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -315,7 +315,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%replace %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%replace %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -416,7 +416,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_TABLES3; if (!$OUTPUT_CHILD_GROUP2) @@ -460,7 +460,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -502,7 +502,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -544,7 +544,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -586,7 +586,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -628,7 +628,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -670,7 +670,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -712,7 +712,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -754,7 +754,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -796,7 +796,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -838,7 +838,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -880,7 +880,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -924,7 +924,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -966,7 +966,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -1007,7 +1007,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -1049,7 +1049,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -1091,7 +1091,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -1133,7 +1133,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -1176,7 +1176,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1222,7 +1222,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1269,7 +1269,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1315,7 +1315,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1362,7 +1362,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1406,7 +1406,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1453,10 +1453,10 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1501,10 +1501,10 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1551,10 +1551,10 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'replace %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'replace %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1598,10 +1598,10 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'replace %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'replace %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1646,10 +1646,10 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'replace %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'replace %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1694,10 +1694,10 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'replace %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'replace %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1744,8 +1744,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1790,8 +1790,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1836,8 +1836,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1881,8 +1881,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1927,8 +1927,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1972,8 +1972,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2017,8 +2017,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2062,8 +2062,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2107,8 +2107,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2159,8 +2159,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2204,8 +2204,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2256,8 +2256,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2308,8 +2308,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2360,8 +2360,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2412,8 +2412,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2464,8 +2464,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2516,8 +2516,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2568,8 +2568,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2620,8 +2620,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2665,7 +2665,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE 'truncate %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'truncate %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/oracle2/t/basic_sql_part.test b/storage/spider/mysql-test/spider/oracle2/t/basic_sql_part.test index e1638642ab7..1bb18358d5d 100644 --- a/storage/spider/mysql-test/spider/oracle2/t/basic_sql_part.test +++ b/storage/spider/mysql-test/spider/oracle2/t/basic_sql_part.test @@ -176,13 +176,13 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_TABLES2; if (!$OUTPUT_CHILD_GROUP2) @@ -235,12 +235,12 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -290,12 +290,12 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -344,15 +344,15 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES2; if (!$OUTPUT_CHILD_GROUP2) @@ -404,15 +404,15 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES2; if (!$OUTPUT_CHILD_GROUP2) @@ -466,15 +466,15 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES2; if (!$OUTPUT_CHILD_GROUP2) @@ -528,15 +528,15 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES2; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/oracle2/t/direct_aggregate.test b/storage/spider/mysql-test/spider/oracle2/t/direct_aggregate.test index d65f4c5a624..5c0c37f483d 100644 --- a/storage/spider/mysql-test/spider/oracle2/t/direct_aggregate.test +++ b/storage/spider/mysql-test/spider/oracle2/t/direct_aggregate.test @@ -147,7 +147,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%handler %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/oracle2/t/direct_aggregate_part.test b/storage/spider/mysql-test/spider/oracle2/t/direct_aggregate_part.test index aebf210c745..cb0b55e9788 100644 --- a/storage/spider/mysql-test/spider/oracle2/t/direct_aggregate_part.test +++ b/storage/spider/mysql-test/spider/oracle2/t/direct_aggregate_part.test @@ -153,13 +153,13 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%handler %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%handler %'; } eval $CHILD2_1_SELECT_TABLES2; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/oracle2/t/direct_update.test b/storage/spider/mysql-test/spider/oracle2/t/direct_update.test index e0901062201..94f27e2859c 100644 --- a/storage/spider/mysql-test/spider/oracle2/t/direct_update.test +++ b/storage/spider/mysql-test/spider/oracle2/t/direct_update.test @@ -166,7 +166,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%handler %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/oracle2/t/direct_update_part.test b/storage/spider/mysql-test/spider/oracle2/t/direct_update_part.test index 95e2e2ab0d5..e8f1882594c 100644 --- a/storage/spider/mysql-test/spider/oracle2/t/direct_update_part.test +++ b/storage/spider/mysql-test/spider/oracle2/t/direct_update_part.test @@ -172,13 +172,13 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%handler %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%handler %'; } eval $CHILD2_1_SELECT_TABLES2; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/oracle2/t/function.test b/storage/spider/mysql-test/spider/oracle2/t/function.test index ec2eeab9c94..2472e774782 100644 --- a/storage/spider/mysql-test/spider/oracle2/t/function.test +++ b/storage/spider/mysql-test/spider/oracle2/t/function.test @@ -125,7 +125,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TEXT_PK_TABLES1; if (!$OUTPUT_CHILD_GROUP2) @@ -219,7 +219,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/oracle2/t/ha.test b/storage/spider/mysql-test/spider/oracle2/t/ha.test index c12930e4aed..c36b7363a6d 100644 --- a/storage/spider/mysql-test/spider/oracle2/t/ha.test +++ b/storage/spider/mysql-test/spider/oracle2/t/ha.test @@ -233,13 +233,13 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -303,7 +303,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -435,13 +435,13 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -623,13 +623,13 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -693,7 +693,7 @@ if ($USE_CHILD_GROUP2) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -799,13 +799,13 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/oracle2/t/ha_part.test b/storage/spider/mysql-test/spider/oracle2/t/ha_part.test index 72ddcfd1f10..33fe9850b68 100644 --- a/storage/spider/mysql-test/spider/oracle2/t/ha_part.test +++ b/storage/spider/mysql-test/spider/oracle2/t/ha_part.test @@ -274,20 +274,20 @@ if ($HAVE_PARTITION) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; eval $CHILD2_1_SELECT_TABLES2; --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_3 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_3_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -356,14 +356,14 @@ if ($HAVE_PARTITION) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; eval $CHILD2_1_SELECT_TABLES2; --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -501,20 +501,20 @@ if ($HAVE_PARTITION) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; eval $CHILD2_1_SELECT_TABLES2; --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_3 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_3_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -723,20 +723,20 @@ if ($HAVE_PARTITION) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; eval $CHILD2_1_SELECT_TABLES2; --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_3 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_3_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -809,19 +809,19 @@ if ($HAVE_PARTITION) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_3 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_3_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -933,20 +933,20 @@ if ($HAVE_PARTITION) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; eval $CHILD2_1_SELECT_TABLES2; --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_3 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_3_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/oracle2/t/spider3_fixes.test b/storage/spider/mysql-test/spider/oracle2/t/spider3_fixes.test index 13fa6f5fa39..962abbad19f 100644 --- a/storage/spider/mysql-test/spider/oracle2/t/spider3_fixes.test +++ b/storage/spider/mysql-test/spider/oracle2/t/spider3_fixes.test @@ -241,7 +241,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_INCREMENT_TABLES1; if ($OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/oracle2/t/spider3_fixes_part.test b/storage/spider/mysql-test/spider/oracle2/t/spider3_fixes_part.test index 3288c490a46..c609108ca9e 100644 --- a/storage/spider/mysql-test/spider/oracle2/t/spider3_fixes_part.test +++ b/storage/spider/mysql-test/spider/oracle2/t/spider3_fixes_part.test @@ -275,7 +275,7 @@ if ($HAVE_PARTITION) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_INCREMENT_TABLES1; if ($OUTPUT_CHILD_GROUP2) @@ -293,7 +293,7 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_2_SELECT_INCREMENT_TABLES1; if ($OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/oracle2/t/spider_fixes.test b/storage/spider/mysql-test/spider/oracle2/t/spider_fixes.test index 04e806fb612..d0158c7dc0b 100644 --- a/storage/spider/mysql-test/spider/oracle2/t/spider_fixes.test +++ b/storage/spider/mysql-test/spider/oracle2/t/spider_fixes.test @@ -164,7 +164,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -206,7 +206,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -248,7 +248,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -337,7 +337,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -359,7 +359,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -381,7 +381,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -403,7 +403,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -425,7 +425,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -447,7 +447,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -469,7 +469,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -491,7 +491,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -513,7 +513,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -535,7 +535,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -557,7 +557,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -579,7 +579,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -676,7 +676,7 @@ if ($HAVE_TRIGGER) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_TABLES4; if (!$OUTPUT_CHILD_GROUP2) @@ -722,7 +722,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -812,7 +812,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -899,8 +899,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%update %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -1139,7 +1139,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_INCREMENT_TABLES1; if ($OUTPUT_CHILD_GROUP2) @@ -1324,7 +1324,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TEXT_PK_TABLES1; if (!$OUTPUT_CHILD_GROUP2) @@ -1380,7 +1380,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TEXT_PK_TABLES1; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/oracle2/t/spider_fixes_part.test b/storage/spider/mysql-test/spider/oracle2/t/spider_fixes_part.test index ef5a8026c02..3053b0008e7 100644 --- a/storage/spider/mysql-test/spider/oracle2/t/spider_fixes_part.test +++ b/storage/spider/mysql-test/spider/oracle2/t/spider_fixes_part.test @@ -176,13 +176,13 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES2; if (!$OUTPUT_CHILD_GROUP2) @@ -281,19 +281,19 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%delete %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%delete %'; } eval $CHILD2_1_SELECT_TABLES2; if (!$OUTPUT_CHILD_GROUP2) @@ -404,12 +404,12 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -575,7 +575,7 @@ if ($HAVE_PARTITION) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_INCREMENT_TABLES1; if ($OUTPUT_CHILD_GROUP2) @@ -593,7 +593,7 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_2_SELECT_INCREMENT_TABLES1; if ($OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/oracle2/t/vp_fixes.test b/storage/spider/mysql-test/spider/oracle2/t/vp_fixes.test index 90380227040..2c3e1523611 100644 --- a/storage/spider/mysql-test/spider/oracle2/t/vp_fixes.test +++ b/storage/spider/mysql-test/spider/oracle2/t/vp_fixes.test @@ -206,7 +206,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_TABLES5; if (!$OUTPUT_CHILD_GROUP2) @@ -303,7 +303,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_TABLES5; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/r/auto_increment.result b/storage/spider/mysql-test/spider/r/auto_increment.result index d968d58e657..6d621cc0841 100644 --- a/storage/spider/mysql-test/spider/r/auto_increment.result +++ b/storage/spider/mysql-test/spider/r/auto_increment.result @@ -152,10 +152,10 @@ col_a col_b col_c 7 def 10 8 def 10 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select t0.`col_a` `col_a`,t0.`col_b` `col_b`,t0.`col_c` `col_c` from `auto_test_remote`.`tbl_a` t0 -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT col_a, col_b, col_c FROM tbl_a ORDER BY col_a; col_a col_b col_c 1 def 10 diff --git a/storage/spider/mysql-test/spider/r/checksum_table_with_quick_mode_3.result b/storage/spider/mysql-test/spider/r/checksum_table_with_quick_mode_3.result index 2fe86099bc2..ff6b968ca99 100644 --- a/storage/spider/mysql-test/spider/r/checksum_table_with_quick_mode_3.result +++ b/storage/spider/mysql-test/spider/r/checksum_table_with_quick_mode_3.result @@ -45,10 +45,10 @@ CHECKSUM TABLE tbl_a EXTENDED; Table Checksum auto_test_local.tbl_a 1061386331 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%checksum %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%checksum %'; argument checksum table `auto_test_remote`.`tbl_a` extended -SELECT argument FROM mysql.general_log WHERE argument LIKE '%checksum %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%checksum %' SELECT pkey FROM tbl_a ORDER BY pkey; pkey 0 diff --git a/storage/spider/mysql-test/spider/r/direct_join.result b/storage/spider/mysql-test/spider/r/direct_join.result index a90c3b58277..4f0db231079 100644 --- a/storage/spider/mysql-test/spider/r/direct_join.result +++ b/storage/spider/mysql-test/spider/r/direct_join.result @@ -74,10 +74,10 @@ a b c 4 40 400 3 30 300 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select t0.`b` `b`,t0.`a` `a`,t2.`b` `b`,t2.`c` `c` from `auto_test_remote`.`ta_r` t0,`auto_test_remote`.`ta_r_3` t1,`auto_test_remote`.`ta_r_int` t2 where ((t0.`a` = t1.`a`) and (t2.`a` = t1.`a`)) order by t0.`b` desc limit 1,2 -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r ORDER BY a; a b date_format(c, '%Y-%m-%d %H:%i:%s') 1 a 2000-01-01 00:00:00 @@ -164,11 +164,11 @@ SELECT count(0) FROM tbl_person tp INNER JOIN tbl_ncd_cm_person tncp ON tp.id = count(0) 1 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `id`,`hr_status`,`region_code`,`region` from `auto_test_remote`.`tbl_person` where `id` = '24FC3F0A5119432BAE13DD65AABAA39C' and `region` = 510411 select count(0) `count(0)` from `auto_test_remote`.`tbl_ncd_cm_person` t0 where ((t0.`person_id` = '24FC3F0A5119432BAE13DD65AABAA39C') and (t0.`diseaseKind_id` = '52A0328740914BCE86ED10A4D2521816')) -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT * FROM tbl_person; id hr_status region_code region 123456789012345678901234567890AB 1 123-51041110620301-321 510411 diff --git a/storage/spider/mysql-test/spider/r/direct_join_using.result b/storage/spider/mysql-test/spider/r/direct_join_using.result index 66ae1503f9f..1bb1b4c1cd2 100644 --- a/storage/spider/mysql-test/spider/r/direct_join_using.result +++ b/storage/spider/mysql-test/spider/r/direct_join_using.result @@ -77,10 +77,10 @@ a b c 2 20 200 1 10 100 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select t0.`b` `b`,t0.`a` `a`,t2.`b` `b`,t2.`c` `c` from `auto_test_remote`.`ta_r` t0,`auto_test_remote`.`ta_r_3` t1,`auto_test_remote`.`ta_r_int` t2 where ((t0.`a` = t1.`a`) and (t2.`a` = t1.`a`)) order by t0.`b` desc -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r ORDER BY a; a b date_format(c, '%Y-%m-%d %H:%i:%s') 1 a 2000-01-01 00:00:00 diff --git a/storage/spider/mysql-test/spider/r/direct_left_join.result b/storage/spider/mysql-test/spider/r/direct_left_join.result index b63f0661b2e..1af1a661cae 100644 --- a/storage/spider/mysql-test/spider/r/direct_left_join.result +++ b/storage/spider/mysql-test/spider/r/direct_left_join.result @@ -77,10 +77,10 @@ a b c 2 20 200 1 10 100 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select t0.`b` `b`,t0.`a` `a`,t2.`b` `b`,t2.`c` `c` from `auto_test_remote`.`ta_r` t0 left join `auto_test_remote`.`ta_r_3` t1 on (t1.`a` = t0.`a`) left join `auto_test_remote`.`ta_r_int` t2 on (t2.`a` = t0.`a`) where 1 order by t0.`b` desc -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r ORDER BY a; a b date_format(c, '%Y-%m-%d %H:%i:%s') 1 a 2000-01-01 00:00:00 diff --git a/storage/spider/mysql-test/spider/r/direct_left_join_nullable.result b/storage/spider/mysql-test/spider/r/direct_left_join_nullable.result index 194a6b31cba..4adfb1bd76a 100644 --- a/storage/spider/mysql-test/spider/r/direct_left_join_nullable.result +++ b/storage/spider/mysql-test/spider/r/direct_left_join_nullable.result @@ -85,10 +85,10 @@ a b c a 2 b 2000-01-02 00:00:00 2 1 a 2000-01-01 00:00:00 1 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select t0.`a` `a`,t2.`b` `b`,t2.`c` `c`,t3.`a` `a` from `auto_test_remote`.`ta_r_no_idx` t0 left join `auto_test_remote`.`ta_r_auto_inc` t1 on (t1.`a` = t0.`a`) left join `auto_test_remote`.`ta_r_3` t2 on (t2.`c` = t1.`c`) left join `auto_test_remote`.`ta_r` t3 on (t3.`b` = t2.`b`) where 1 order by t0.`a` desc -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r ORDER BY a; a b date_format(c, '%Y-%m-%d %H:%i:%s') 1 a 2000-01-01 00:00:00 diff --git a/storage/spider/mysql-test/spider/r/direct_left_right_join_nullable.result b/storage/spider/mysql-test/spider/r/direct_left_right_join_nullable.result index e6720c1113f..a6bd3a7c1a1 100644 --- a/storage/spider/mysql-test/spider/r/direct_left_right_join_nullable.result +++ b/storage/spider/mysql-test/spider/r/direct_left_right_join_nullable.result @@ -85,10 +85,10 @@ NULL NULL NULL 3 2 b 2000-01-02 00:00:00 2 1 a 2000-01-01 00:00:00 1 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select t0.`a` `a`,t2.`b` `b`,t2.`c` `c`,t3.`a` `a` from `auto_test_remote`.`ta_r_no_idx` t3 left join (`auto_test_remote`.`ta_r_auto_inc` t2 join `auto_test_remote`.`ta_r_3` t1 join `auto_test_remote`.`ta_r` t0) on ((t2.`b` = t3.`b`) and (t2.`c` = t1.`c`) and (t0.`a` = t1.`a`) and (t1.`a` is not null)) where 1 order by t3.`a` desc -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r ORDER BY a; a b date_format(c, '%Y-%m-%d %H:%i:%s') 1 a 2000-01-01 00:00:00 diff --git a/storage/spider/mysql-test/spider/r/direct_left_right_left_join_nullable.result b/storage/spider/mysql-test/spider/r/direct_left_right_left_join_nullable.result index 88205fb0f65..8fab6d24b9a 100644 --- a/storage/spider/mysql-test/spider/r/direct_left_right_left_join_nullable.result +++ b/storage/spider/mysql-test/spider/r/direct_left_right_left_join_nullable.result @@ -84,10 +84,10 @@ NULL c 2000-01-03 00:00:00 3 2 b 2000-01-02 00:00:00 2 1 a 2000-01-01 00:00:00 1 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select t0.`a` `a`,t2.`b` `b`,t2.`c` `c`,t3.`a` `a` from `auto_test_remote`.`ta_r_auto_inc` t2 left join (`auto_test_remote`.`ta_r_3` t1 join `auto_test_remote`.`ta_r` t0) on ((t1.`c` = t2.`c`) and (t0.`a` = t1.`a`) and (t1.`a` is not null)) left join `auto_test_remote`.`ta_r_no_idx` t3 on (t3.`b` = t2.`b`) where 1 order by t3.`a` desc -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r ORDER BY a; a b date_format(c, '%Y-%m-%d %H:%i:%s') 1 a 2000-01-01 00:00:00 diff --git a/storage/spider/mysql-test/spider/r/direct_right_join.result b/storage/spider/mysql-test/spider/r/direct_right_join.result index 8edfb682292..d7780b94284 100644 --- a/storage/spider/mysql-test/spider/r/direct_right_join.result +++ b/storage/spider/mysql-test/spider/r/direct_right_join.result @@ -77,10 +77,10 @@ a b c 2 20 200 1 10 100 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select t0.`b` `b`,t0.`a` `a`,t2.`b` `b`,t2.`c` `c` from `auto_test_remote`.`ta_r_int` t2 left join (`auto_test_remote`.`ta_r` t0 join `auto_test_remote`.`ta_r_3` t1) on ((t0.`a` = t2.`a`) and (t1.`a` = t2.`a`)) where 1 order by t0.`b` desc -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r ORDER BY a; a b date_format(c, '%Y-%m-%d %H:%i:%s') 1 a 2000-01-01 00:00:00 diff --git a/storage/spider/mysql-test/spider/r/direct_right_join_nullable.result b/storage/spider/mysql-test/spider/r/direct_right_join_nullable.result index a0b44c95cee..5101ea5036a 100644 --- a/storage/spider/mysql-test/spider/r/direct_right_join_nullable.result +++ b/storage/spider/mysql-test/spider/r/direct_right_join_nullable.result @@ -85,10 +85,10 @@ NULL c 2000-01-03 00:00:00 3 2 b 2000-01-02 00:00:00 2 1 a 2000-01-01 00:00:00 1 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select t0.`a` `a`,t2.`b` `b`,t2.`c` `c`,t3.`a` `a` from `auto_test_remote`.`ta_r_no_idx` t3 left join `auto_test_remote`.`ta_r_auto_inc` t2 on (t2.`b` = t3.`b`) left join `auto_test_remote`.`ta_r_3` t1 on (t1.`c` = t2.`c`) left join `auto_test_remote`.`ta_r` t0 on ((t0.`a` = t1.`a`) and (t1.`a` is not null)) where 1 order by t3.`a` desc -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r ORDER BY a; a b date_format(c, '%Y-%m-%d %H:%i:%s') 1 a 2000-01-01 00:00:00 diff --git a/storage/spider/mysql-test/spider/r/direct_right_left_join_nullable.result b/storage/spider/mysql-test/spider/r/direct_right_left_join_nullable.result index 25e0913ba06..c90fe3abf97 100644 --- a/storage/spider/mysql-test/spider/r/direct_right_left_join_nullable.result +++ b/storage/spider/mysql-test/spider/r/direct_right_left_join_nullable.result @@ -84,10 +84,10 @@ NULL c 2000-01-03 00:00:00 3 2 b 2000-01-02 00:00:00 2 1 a 2000-01-01 00:00:00 1 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select t0.`a` `a`,t2.`b` `b`,t2.`c` `c`,t3.`a` `a` from `auto_test_remote`.`ta_r_auto_inc` t2 left join `auto_test_remote`.`ta_r_3` t1 on (t1.`c` = t2.`c`) left join `auto_test_remote`.`ta_r` t0 on ((t0.`a` = t1.`a`) and (t1.`a` is not null)) left join `auto_test_remote`.`ta_r_no_idx` t3 on (t3.`b` = t2.`b`) where 1 order by t3.`a` desc -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r ORDER BY a; a b date_format(c, '%Y-%m-%d %H:%i:%s') 1 a 2000-01-01 00:00:00 diff --git a/storage/spider/mysql-test/spider/r/direct_right_left_right_join_nullable.result b/storage/spider/mysql-test/spider/r/direct_right_left_right_join_nullable.result index 0ee74cae7a3..f6c808be973 100644 --- a/storage/spider/mysql-test/spider/r/direct_right_left_right_join_nullable.result +++ b/storage/spider/mysql-test/spider/r/direct_right_left_right_join_nullable.result @@ -85,10 +85,10 @@ NULL c 2000-01-03 00:00:00 3 2 b 2000-01-02 00:00:00 2 1 a 2000-01-01 00:00:00 1 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select t0.`a` `a`,t2.`b` `b`,t2.`c` `c`,t3.`a` `a` from `auto_test_remote`.`ta_r_no_idx` t3 left join (`auto_test_remote`.`ta_r_auto_inc` t2 join `auto_test_remote`.`ta_r_3` t1 left join `auto_test_remote`.`ta_r` t0 on ((t0.`a` = t1.`a`) and (t1.`a` is not null))) on ((t2.`b` = t3.`b`) and (t2.`c` = t1.`c`)) where 1 order by t3.`a` desc -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT a, b, date_format(c, '%Y-%m-%d %H:%i:%s') FROM ta_r ORDER BY a; a b date_format(c, '%Y-%m-%d %H:%i:%s') 1 a 2000-01-01 00:00:00 diff --git a/storage/spider/mysql-test/spider/r/partition_cond_push.result b/storage/spider/mysql-test/spider/r/partition_cond_push.result index ce26416b9f8..dd91e4b706e 100644 --- a/storage/spider/mysql-test/spider/r/partition_cond_push.result +++ b/storage/spider/mysql-test/spider/r/partition_cond_push.result @@ -92,10 +92,10 @@ value 26 27 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `value` from `auto_test_remote`.`tbl_a` where (`value` < 100) -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT value FROM tbl_a ORDER BY value; value 4 @@ -109,10 +109,10 @@ value 28 29 connection child2_2; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `value` from `auto_test_remote2`.`tbl_a` where (`value` < 100) -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT value FROM tbl_a ORDER BY value; value 0 @@ -126,10 +126,10 @@ value 24 25 connection child2_3; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `value` from `auto_test_remote3`.`tbl_a` where (`value` < 100) -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT value FROM tbl_a ORDER BY value; value 2 diff --git a/storage/spider/mysql-test/spider/r/partition_fulltext.result b/storage/spider/mysql-test/spider/r/partition_fulltext.result index 6c001d25444..581c731b2eb 100644 --- a/storage/spider/mysql-test/spider/r/partition_fulltext.result +++ b/storage/spider/mysql-test/spider/r/partition_fulltext.result @@ -69,19 +69,19 @@ SELECT pkey, words FROM tbl_a WHERE match(words) against('+ghi' in boolean mode) pkey words 2 ghi connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select match(`words`)against('+ghi' in boolean mode),`pkey`,`words` from `auto_test_remote`.`tbl_a` where match(`words`)against('+ghi' in boolean mode) and (match(`words`)against(_latin1'+ghi' in boolean mode)) -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_a ORDER BY pkey; pkey 4 5 connection child2_2; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select match(`words`)against('+ghi' in boolean mode),`pkey`,`words` from `auto_test_remote2`.`tbl_a` where match(`words`)against('+ghi' in boolean mode) and (match(`words`)against(_latin1'+ghi' in boolean mode)) -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_a ORDER BY pkey; pkey 0 @@ -89,10 +89,10 @@ pkey 6 7 connection child2_3; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select match(`words`)against('+ghi' in boolean mode),`pkey`,`words` from `auto_test_remote3`.`tbl_a` where match(`words`)against('+ghi' in boolean mode) and (match(`words`)against(_latin1'+ghi' in boolean mode)) -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_a ORDER BY pkey; pkey 2 diff --git a/storage/spider/mysql-test/spider/r/partition_join_pushdown_for_single_partition.result b/storage/spider/mysql-test/spider/r/partition_join_pushdown_for_single_partition.result index 899788ae1c1..3eed8df28bf 100644 --- a/storage/spider/mysql-test/spider/r/partition_join_pushdown_for_single_partition.result +++ b/storage/spider/mysql-test/spider/r/partition_join_pushdown_for_single_partition.result @@ -72,9 +72,9 @@ SELECT sum(a.value), count(b.value2) FROM tbl_a a, tbl_b b WHERE a.value = 5 and sum(a.value) count(b.value2) 5 1 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT value FROM tbl_a ORDER BY value; value 1 @@ -82,13 +82,13 @@ value 3 4 connection child2_2; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `value` from `auto_test_remote2`.`tbl_a` where `value` = 5 select `value2` from `auto_test_remote2`.`tbl_b` where `value2` = 5 select `value` from `auto_test_remote2`.`tbl_a` where `value` = 5 select `value2` from `auto_test_remote2`.`tbl_b` where `value2` = 5 -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT value FROM tbl_a ORDER BY value; value 5 @@ -97,9 +97,9 @@ value 8 9 connection child2_3; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT value FROM tbl_a ORDER BY value; value 10 diff --git a/storage/spider/mysql-test/spider/r/partition_mrr.result b/storage/spider/mysql-test/spider/r/partition_mrr.result index 2335e8933a4..c7e17698421 100644 --- a/storage/spider/mysql-test/spider/r/partition_mrr.result +++ b/storage/spider/mysql-test/spider/r/partition_mrr.result @@ -105,11 +105,11 @@ pkey 26 27 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `pkey` from `auto_test_remote`.`tbl_a` order by `pkey` select a.id,b.`pkey` from auto_test_remote.tmp_spider_bka_xxxx a,`auto_test_remote`.`tbl_b` b where a.c0 <=> b.`pkey` -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_a ORDER BY pkey ; SELECT pkey FROM tbl_b ORDER BY pkey; pkey @@ -135,11 +135,11 @@ pkey 26 27 connection child2_2; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `pkey` from `auto_test_remote2`.`tbl_a` order by `pkey` select a.id,b.`pkey` from auto_test_remote2.tmp_spider_bka_xxxx a,`auto_test_remote2`.`tbl_b` b where a.c0 <=> b.`pkey` -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_a ORDER BY pkey ; SELECT pkey FROM tbl_b ORDER BY pkey; pkey @@ -165,11 +165,11 @@ pkey 28 29 connection child2_3; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `pkey` from `auto_test_remote3`.`tbl_a` order by `pkey` select a.id,b.`pkey` from auto_test_remote3.tmp_spider_bka_xxxx a,`auto_test_remote3`.`tbl_b` b where a.c0 <=> b.`pkey` -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_a ORDER BY pkey ; SELECT pkey FROM tbl_b ORDER BY pkey; pkey diff --git a/storage/spider/mysql-test/spider/r/pushdown_not_like.result b/storage/spider/mysql-test/spider/r/pushdown_not_like.result index 0e007b094de..5c802c90c23 100644 --- a/storage/spider/mysql-test/spider/r/pushdown_not_like.result +++ b/storage/spider/mysql-test/spider/r/pushdown_not_like.result @@ -39,10 +39,10 @@ a b c 2 b 2015-06-30 23:59:59 3 c 2013-11-01 01:01:01 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select%'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select%'; argument select t0.`a` `a`,t0.`b` `b`,t0.`c` `c` from `auto_test_remote`.`ta_r` t0 where (t0.`b` not like 'a%') -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select%' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select%' deinit connection master_1; diff --git a/storage/spider/mysql-test/spider/r/quick_mode_0.result b/storage/spider/mysql-test/spider/r/quick_mode_0.result index 239c3ee1175..04c8231bc36 100644 --- a/storage/spider/mysql-test/spider/r/quick_mode_0.result +++ b/storage/spider/mysql-test/spider/r/quick_mode_0.result @@ -91,10 +91,10 @@ pkey 28 29 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `pkey` from `auto_test_remote`.`tbl_a` order by `pkey` -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_a ORDER BY pkey; pkey 0 @@ -128,7 +128,7 @@ pkey 28 29 connection child2_2; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 0 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 1 @@ -160,7 +160,7 @@ select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 26 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 27 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 28 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 29 -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_b ORDER BY pkey; pkey 0 @@ -235,10 +235,10 @@ pkey 28 29 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `pkey` from `auto_test_remote`.`tbl_a` order by `pkey` -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_a ORDER BY pkey; pkey 0 @@ -272,7 +272,7 @@ pkey 28 29 connection child2_2; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 0 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 1 @@ -304,7 +304,7 @@ select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 26 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 27 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 28 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 29 -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_b ORDER BY pkey; pkey 0 @@ -379,10 +379,10 @@ pkey 28 29 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `pkey` from `auto_test_remote`.`tbl_a` order by `pkey` -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_a ORDER BY pkey; pkey 0 @@ -416,7 +416,7 @@ pkey 28 29 connection child2_2; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 0 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 1 @@ -448,7 +448,7 @@ select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 26 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 27 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 28 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 29 -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_b ORDER BY pkey; pkey 0 diff --git a/storage/spider/mysql-test/spider/r/quick_mode_1.result b/storage/spider/mysql-test/spider/r/quick_mode_1.result index d0db0729c39..820d791dd64 100644 --- a/storage/spider/mysql-test/spider/r/quick_mode_1.result +++ b/storage/spider/mysql-test/spider/r/quick_mode_1.result @@ -91,10 +91,10 @@ pkey 28 29 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `pkey` from `auto_test_remote`.`tbl_a` order by `pkey` -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_a ORDER BY pkey; pkey 0 @@ -128,7 +128,7 @@ pkey 28 29 connection child2_2; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 0 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 1 @@ -160,7 +160,7 @@ select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 26 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 27 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 28 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 29 -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_b ORDER BY pkey; pkey 0 @@ -235,10 +235,10 @@ pkey 28 29 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `pkey` from `auto_test_remote`.`tbl_a` order by `pkey` -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_a ORDER BY pkey; pkey 0 @@ -272,7 +272,7 @@ pkey 28 29 connection child2_2; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 0 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 1 @@ -304,7 +304,7 @@ select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 26 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 27 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 28 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 29 -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_b ORDER BY pkey; pkey 0 @@ -379,10 +379,10 @@ pkey 28 29 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `pkey` from `auto_test_remote`.`tbl_a` order by `pkey` -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_a ORDER BY pkey; pkey 0 @@ -416,7 +416,7 @@ pkey 28 29 connection child2_2; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 0 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 1 @@ -448,7 +448,7 @@ select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 26 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 27 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 28 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 29 -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_b ORDER BY pkey; pkey 0 diff --git a/storage/spider/mysql-test/spider/r/quick_mode_2.result b/storage/spider/mysql-test/spider/r/quick_mode_2.result index 538057e3cda..94c5c4cf1af 100644 --- a/storage/spider/mysql-test/spider/r/quick_mode_2.result +++ b/storage/spider/mysql-test/spider/r/quick_mode_2.result @@ -91,10 +91,10 @@ pkey 28 29 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `pkey` from `auto_test_remote`.`tbl_a` order by `pkey` -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_a ORDER BY pkey; pkey 0 @@ -128,7 +128,7 @@ pkey 28 29 connection child2_2; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 0 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 1 @@ -160,7 +160,7 @@ select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 26 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 27 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 28 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 29 -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_b ORDER BY pkey; pkey 0 @@ -235,10 +235,10 @@ pkey 28 29 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `pkey` from `auto_test_remote`.`tbl_a` order by `pkey` -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_a ORDER BY pkey; pkey 0 @@ -272,7 +272,7 @@ pkey 28 29 connection child2_2; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 0 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 1 @@ -304,7 +304,7 @@ select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 26 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 27 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 28 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 29 -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_b ORDER BY pkey; pkey 0 @@ -379,10 +379,10 @@ pkey 28 29 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `pkey` from `auto_test_remote`.`tbl_a` order by `pkey` -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_a ORDER BY pkey; pkey 0 @@ -416,7 +416,7 @@ pkey 28 29 connection child2_2; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 0 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 1 @@ -448,7 +448,7 @@ select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 26 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 27 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 28 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 29 -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_b ORDER BY pkey; pkey 0 diff --git a/storage/spider/mysql-test/spider/r/quick_mode_3.result b/storage/spider/mysql-test/spider/r/quick_mode_3.result index 9232dd152de..88a8914cf0a 100644 --- a/storage/spider/mysql-test/spider/r/quick_mode_3.result +++ b/storage/spider/mysql-test/spider/r/quick_mode_3.result @@ -91,10 +91,10 @@ pkey 28 29 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `pkey` from `auto_test_remote`.`tbl_a` order by `pkey` -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_a ORDER BY pkey; pkey 0 @@ -128,7 +128,7 @@ pkey 28 29 connection child2_2; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 0 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 1 @@ -160,7 +160,7 @@ select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 26 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 27 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 28 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 29 -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_b ORDER BY pkey; pkey 0 @@ -235,10 +235,10 @@ pkey 28 29 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `pkey` from `auto_test_remote`.`tbl_a` order by `pkey` -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_a ORDER BY pkey; pkey 0 @@ -272,7 +272,7 @@ pkey 28 29 connection child2_2; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 0 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 1 @@ -304,7 +304,7 @@ select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 26 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 27 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 28 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 29 -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_b ORDER BY pkey; pkey 0 @@ -379,10 +379,10 @@ pkey 28 29 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `pkey` from `auto_test_remote`.`tbl_a` order by `pkey` -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_a ORDER BY pkey; pkey 0 @@ -416,7 +416,7 @@ pkey 28 29 connection child2_2; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 0 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 1 @@ -448,7 +448,7 @@ select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 26 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 27 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 28 select `pkey` from `auto_test_remote2`.`tbl_b` where `pkey` = 29 -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey FROM tbl_b ORDER BY pkey; pkey 0 diff --git a/storage/spider/mysql-test/spider/r/slave_trx_isolation.result b/storage/spider/mysql-test/spider/r/slave_trx_isolation.result index 2698761cca4..28aaf74fa3d 100644 --- a/storage/spider/mysql-test/spider/r/slave_trx_isolation.result +++ b/storage/spider/mysql-test/spider/r/slave_trx_isolation.result @@ -49,12 +49,12 @@ connection slave1_1; connection master_1; SET SESSION sql_log_bin= 0; connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%set %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%set %'; argument set session time_zone = '+00:00';set @`spider_lc_./auto_test_remote/tbl_a` = '-xxxxxxxxxxxx-xxxxx-./auto_test_local/tbl_a-' SET NAMES utf8mb3 set session transaction isolation level read committed;set session autocommit = 1;set session wait_timeout = 604800;set session sql_mode = 'strict_trans_tables,error_for_division_by_zero,no_auto_create_user,no_engine_substitution';start transaction -SELECT argument FROM mysql.general_log WHERE argument LIKE '%set %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%set %' SELECT pkey FROM tbl_a ORDER BY pkey; pkey 0 diff --git a/storage/spider/mysql-test/spider/r/timestamp.result b/storage/spider/mysql-test/spider/r/timestamp.result index 2993c08c5db..1041566d4d3 100644 --- a/storage/spider/mysql-test/spider/r/timestamp.result +++ b/storage/spider/mysql-test/spider/r/timestamp.result @@ -112,10 +112,10 @@ col_a col_dt col_ts unix_timestamp(col_ts) 5 2018-10-28 02:30:00 2018-10-28 02:30:00 1540690200 6 2038-01-19 04:14:07 2038-01-19 04:14:07 2147483647 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT col_a, col_dt, col_ts, unix_timestamp(col_ts) FROM tbl_a ORDER BY col_a; col_a col_dt col_ts unix_timestamp(col_ts) 1 1970-01-01 01:00:01 1970-01-01 01:00:01 1 @@ -138,10 +138,10 @@ col_a col_dt col_ts unix_timestamp(col_ts) 5 2018-10-28 02:30:00 2018-10-28 02:30:00 1540690200 6 2038-01-19 04:14:07 2038-01-19 04:14:07 2147483647 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT col_a, col_dt, col_ts, unix_timestamp(col_ts) FROM tbl_a ORDER BY col_a; col_a col_dt col_ts unix_timestamp(col_ts) 2 2018-03-25 02:00:00 2018-03-25 03:00:00 1521939600 @@ -164,10 +164,10 @@ col_a col_dt col_ts unix_timestamp(col_ts) 5 2018-10-28 02:30:00 2018-10-28 02:30:00 1540690200 6 2038-01-19 04:14:07 2038-01-19 04:14:07 2147483647 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT col_a, col_dt, col_ts, unix_timestamp(col_ts) FROM tbl_a ORDER BY col_a; col_a col_dt col_ts unix_timestamp(col_ts) 1 1970-01-01 01:00:01 1970-01-01 01:00:01 1 @@ -191,11 +191,11 @@ col_a col_dt col_ts unix_timestamp(col_ts) 5 2018-10-28 02:30:00 2018-10-28 02:30:00 1540690200 6 2038-01-19 04:14:07 2038-01-19 04:14:07 2147483647 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select `col_a`,`col_dt`,`col_ts` from `ts_test_remote`.`tbl_a` for update select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT col_a, col_dt, col_ts, unix_timestamp(col_ts) FROM tbl_a ORDER BY col_a; col_a col_dt col_ts unix_timestamp(col_ts) 1 1970-01-01 01:00:01 1970-01-01 01:00:01 1 @@ -250,7 +250,7 @@ col_a col_dt col_ts unix_timestamp(col_ts) 5 2018-10-28 02:30:00 2018-10-28 02:30:00 1540690200 6 2038-01-19 04:14:07 2038-01-19 04:14:07 2147483647 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where (t0.`col_ts` > _latin1'2017-12-31 23:00:00') select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where (t0.`col_ts` < _latin1'2018-10-28 01:30:00') @@ -259,7 +259,7 @@ select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timest select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where ((t0.`col_ts` >= _latin1'2018-10-28 00:30:00') and (t0.`col_ts` <= _latin1'2018-10-28 01:30:00')) select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where (t0.`col_ts` > '2018-03-25 01:00:00') select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where (t0.`col_ts` > '1970-01-01 00:00:01') -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT col_a, col_dt, col_ts, unix_timestamp(col_ts) FROM tbl_a ORDER BY col_a; col_a col_dt col_ts unix_timestamp(col_ts) 1 1970-01-01 01:00:01 1970-01-01 01:00:01 1 @@ -337,7 +337,7 @@ col_a col_dt col_ts unix_timestamp(col_ts) 5 2018-10-28 02:30:00 2018-10-28 02:30:00 1540690200 6 2038-01-19 04:14:07 2038-01-19 04:14:07 2147483647 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where (t0.`col_ts` > _latin1'2017-12-31 23:00:00') select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where (t0.`col_ts` < _latin1'2018-10-28 01:30:00') @@ -346,7 +346,7 @@ select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timest select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where ((t0.`col_ts` >= _latin1'2018-10-28 00:30:00') and (t0.`col_ts` <= _latin1'2018-10-28 01:30:00')) select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where (t0.`col_ts` > '2018-03-25 01:00:00') select t0.`col_a` `col_a`,t0.`col_dt` `col_dt`,t0.`col_ts` `col_ts`,(unix_timestamp(t0.`col_ts`)) `unix_timestamp(col_ts)` from `ts_test_remote`.`tbl_a` t0 where (t0.`col_ts` > '1970-01-01 00:00:01') -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT col_a, col_dt, col_ts, unix_timestamp(col_ts) FROM tbl_a ORDER BY col_a; col_a col_dt col_ts unix_timestamp(col_ts) 1 1970-01-01 01:00:01 1970-01-01 01:00:01 1 @@ -390,14 +390,14 @@ TIMESTAMP('2018-06-25', '10:43:21') 2018-06-25 10:43:21 2018-06-25 10:43:21 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select t0.`col_d` `col_d`,t0.`col_t` `col_t` from `ts_test_remote`.`tbl_f` t0 select (timestamp(t0.`col_d` , t0.`col_t`)) `TIMESTAMP(col_d, col_t)` from `ts_test_remote`.`tbl_f` t0 select (timestamp('2018-06-25' , t0.`col_t`)) `TIMESTAMP('2018-06-25', col_t)` from `ts_test_remote`.`tbl_f` t0 select (timestamp(t0.`col_d` , '10:43:21')) `TIMESTAMP(col_d, '10:43:21')` from `ts_test_remote`.`tbl_f` t0 select 1 from `ts_test_remote`.`tbl_f` t0 -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT col_d, col_t FROM tbl_f; col_d col_t 2018-06-24 01:23:45 diff --git a/storage/spider/mysql-test/spider/regression/e1121/include/direct_join_by_pkey_key_init.inc b/storage/spider/mysql-test/spider/regression/e1121/include/direct_join_by_pkey_key_init.inc index 695d46101ae..b3d169871aa 100644 --- a/storage/spider/mysql-test/spider/regression/e1121/include/direct_join_by_pkey_key_init.inc +++ b/storage/spider/mysql-test/spider/regression/e1121/include/direct_join_by_pkey_key_init.inc @@ -32,5 +32,5 @@ let $CHILD2_1_SELECT_TABLES= SELECT akey, val FROM tbl_a ORDER BY akey $STR_SEMICOLON SELECT bkey, akey FROM tbl_b ORDER BY bkey; let $CHILD2_1_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%' $STR_SEMICOLON - SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_b`%'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%' $STR_SEMICOLON + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_b`%'; diff --git a/storage/spider/mysql-test/spider/regression/e1121/include/direct_join_by_pkey_pkey_init.inc b/storage/spider/mysql-test/spider/regression/e1121/include/direct_join_by_pkey_pkey_init.inc index e364489c05f..000b42e2b32 100644 --- a/storage/spider/mysql-test/spider/regression/e1121/include/direct_join_by_pkey_pkey_init.inc +++ b/storage/spider/mysql-test/spider/regression/e1121/include/direct_join_by_pkey_pkey_init.inc @@ -32,5 +32,5 @@ let $CHILD2_1_SELECT_TABLES= SELECT akey, val FROM tbl_a ORDER BY akey $STR_SEMICOLON SELECT bkey, akey FROM tbl_b ORDER BY bkey; let $CHILD2_1_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%' $STR_SEMICOLON - SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_b`%'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%' $STR_SEMICOLON + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_b`%'; diff --git a/storage/spider/mysql-test/spider/regression/e1121/include/load_data_init.inc b/storage/spider/mysql-test/spider/regression/e1121/include/load_data_init.inc index 5f4104382dc..96216e01e02 100644 --- a/storage/spider/mysql-test/spider/regression/e1121/include/load_data_init.inc +++ b/storage/spider/mysql-test/spider/regression/e1121/include/load_data_init.inc @@ -22,4 +22,4 @@ let $CHILD2_1_CREATE_TABLES= let $CHILD2_1_SELECT_TABLES= SELECT pkey, val FROM tbl_a ORDER BY pkey; let $CHILD2_1_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%'; diff --git a/storage/spider/mysql-test/spider/regression/e1121/r/direct_join_by_pkey_key.result b/storage/spider/mysql-test/spider/regression/e1121/r/direct_join_by_pkey_key.result index 4b04b71aee2..a5553304ae0 100644 --- a/storage/spider/mysql-test/spider/regression/e1121/r/direct_join_by_pkey_key.result +++ b/storage/spider/mysql-test/spider/regression/e1121/r/direct_join_by_pkey_key.result @@ -43,16 +43,16 @@ SELECT a.val, a.akey FROM tbl_a a, tbl_b b WHERE a.akey = b.akey AND b.bkey = 5; val akey 4 4 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%' ; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_b`%'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%' ; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_b`%'; argument select t0.`val` `val`,t0.`akey` `akey` from `auto_test_remote`.`tbl_a` t0 where (t0.`akey` = '4') -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%' ; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_b`%' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%' ; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_b`%' argument select `bkey`,`akey` from `auto_test_remote`.`tbl_b` where `bkey` = 5 -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%' ; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_b`%' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%' ; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_b`%' SELECT akey, val FROM tbl_a ORDER BY akey ; SELECT bkey, akey FROM tbl_b ORDER BY bkey; akey val diff --git a/storage/spider/mysql-test/spider/regression/e1121/r/direct_join_by_pkey_pkey.result b/storage/spider/mysql-test/spider/regression/e1121/r/direct_join_by_pkey_pkey.result index 9a75cc691fe..4ea23c8837c 100644 --- a/storage/spider/mysql-test/spider/regression/e1121/r/direct_join_by_pkey_pkey.result +++ b/storage/spider/mysql-test/spider/regression/e1121/r/direct_join_by_pkey_pkey.result @@ -43,16 +43,16 @@ SELECT a.val, a.akey FROM tbl_a a, tbl_b b WHERE a.akey = b.akey AND b.bkey = 5; val akey 4 4 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%' ; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_b`%'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%' ; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_b`%'; argument select `akey`,`val` from `auto_test_remote`.`tbl_a` where `akey` = 4 -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%' ; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_b`%' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%' ; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_b`%' argument select `bkey`,`akey` from `auto_test_remote`.`tbl_b` where `bkey` = 5 -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%' ; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_b`%' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%' ; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_b`%' SELECT akey, val FROM tbl_a ORDER BY akey ; SELECT bkey, akey FROM tbl_b ORDER BY bkey; akey val diff --git a/storage/spider/mysql-test/spider/regression/e1121/r/load_data_ddi0.result b/storage/spider/mysql-test/spider/regression/e1121/r/load_data_ddi0.result index 2244b176b31..9d30f61a489 100644 --- a/storage/spider/mysql-test/spider/regression/e1121/r/load_data_ddi0.result +++ b/storage/spider/mysql-test/spider/regression/e1121/r/load_data_ddi0.result @@ -40,10 +40,10 @@ TRUNCATE TABLE mysql.general_log; connection master_1; LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/spider_outfile.tsv' INTO TABLE tbl_a; connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%'; argument insert high_priority into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(0,0),(1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9) -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%' SELECT pkey, val FROM tbl_a ORDER BY pkey; pkey val 0 0 diff --git a/storage/spider/mysql-test/spider/regression/e1121/r/load_data_ddi1.result b/storage/spider/mysql-test/spider/regression/e1121/r/load_data_ddi1.result index 6d0d29cd4bd..594016e164b 100644 --- a/storage/spider/mysql-test/spider/regression/e1121/r/load_data_ddi1.result +++ b/storage/spider/mysql-test/spider/regression/e1121/r/load_data_ddi1.result @@ -40,10 +40,10 @@ TRUNCATE TABLE mysql.general_log; connection master_1; LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/spider_outfile.tsv' INTO TABLE tbl_a; connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%'; argument insert high_priority into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(0,0),(1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9) -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%' SELECT pkey, val FROM tbl_a ORDER BY pkey; pkey val 0 0 diff --git a/storage/spider/mysql-test/spider/regression/e1121/r/load_data_ignore_ddi0.result b/storage/spider/mysql-test/spider/regression/e1121/r/load_data_ignore_ddi0.result index 1bdd1470faa..e1ba54709bc 100644 --- a/storage/spider/mysql-test/spider/regression/e1121/r/load_data_ignore_ddi0.result +++ b/storage/spider/mysql-test/spider/regression/e1121/r/load_data_ignore_ddi0.result @@ -51,7 +51,7 @@ Warning 1062 Duplicate entry '7' for key 'PRIMARY' Warning 1062 Duplicate entry '8' for key 'PRIMARY' Warning 1062 Duplicate entry '9' for key 'PRIMARY' connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%'; argument insert high_priority into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(0,0) insert high_priority into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(1,1) @@ -63,7 +63,7 @@ insert high_priority into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(6,6) insert high_priority into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(7,7) insert high_priority into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(8,8) insert high_priority into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(9,9) -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%' SELECT pkey, val FROM tbl_a ORDER BY pkey; pkey val 0 1 diff --git a/storage/spider/mysql-test/spider/regression/e1121/r/load_data_ignore_ddi1.result b/storage/spider/mysql-test/spider/regression/e1121/r/load_data_ignore_ddi1.result index 4d64840e85d..af2bcc3d903 100644 --- a/storage/spider/mysql-test/spider/regression/e1121/r/load_data_ignore_ddi1.result +++ b/storage/spider/mysql-test/spider/regression/e1121/r/load_data_ignore_ddi1.result @@ -40,10 +40,10 @@ TRUNCATE TABLE mysql.general_log; connection master_1; LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/spider_outfile.tsv' IGNORE INTO TABLE tbl_a; connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%'; argument insert high_priority ignore into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(0,0),(1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9) -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%' SELECT pkey, val FROM tbl_a ORDER BY pkey; pkey val 0 1 diff --git a/storage/spider/mysql-test/spider/regression/e1121/r/load_data_local_ddi0.result b/storage/spider/mysql-test/spider/regression/e1121/r/load_data_local_ddi0.result index 9156c838e09..057d8386dc4 100644 --- a/storage/spider/mysql-test/spider/regression/e1121/r/load_data_local_ddi0.result +++ b/storage/spider/mysql-test/spider/regression/e1121/r/load_data_local_ddi0.result @@ -40,7 +40,7 @@ TRUNCATE TABLE mysql.general_log; connection master_1; LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/spider_outfile.tsv' INTO TABLE tbl_a; connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%'; argument insert high_priority into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(0,0) insert high_priority into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(1,1) @@ -52,7 +52,7 @@ insert high_priority into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(6,6) insert high_priority into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(7,7) insert high_priority into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(8,8) insert high_priority into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(9,9) -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%' SELECT pkey, val FROM tbl_a ORDER BY pkey; pkey val 0 0 diff --git a/storage/spider/mysql-test/spider/regression/e1121/r/load_data_local_ddi1.result b/storage/spider/mysql-test/spider/regression/e1121/r/load_data_local_ddi1.result index 761ce71dc02..ba643fa6436 100644 --- a/storage/spider/mysql-test/spider/regression/e1121/r/load_data_local_ddi1.result +++ b/storage/spider/mysql-test/spider/regression/e1121/r/load_data_local_ddi1.result @@ -40,10 +40,10 @@ TRUNCATE TABLE mysql.general_log; connection master_1; LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/spider_outfile.tsv' INTO TABLE tbl_a; connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%'; argument insert high_priority ignore into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(0,0),(1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9) -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%' SELECT pkey, val FROM tbl_a ORDER BY pkey; pkey val 0 0 diff --git a/storage/spider/mysql-test/spider/regression/e1121/r/load_data_local_ignore_ddi0.result b/storage/spider/mysql-test/spider/regression/e1121/r/load_data_local_ignore_ddi0.result index 81d0fdbf785..50248d5ace3 100644 --- a/storage/spider/mysql-test/spider/regression/e1121/r/load_data_local_ignore_ddi0.result +++ b/storage/spider/mysql-test/spider/regression/e1121/r/load_data_local_ignore_ddi0.result @@ -51,7 +51,7 @@ Warning 1062 Duplicate entry '7' for key 'PRIMARY' Warning 1062 Duplicate entry '8' for key 'PRIMARY' Warning 1062 Duplicate entry '9' for key 'PRIMARY' connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%'; argument insert high_priority into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(0,0) insert high_priority into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(1,1) @@ -63,7 +63,7 @@ insert high_priority into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(6,6) insert high_priority into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(7,7) insert high_priority into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(8,8) insert high_priority into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(9,9) -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%' SELECT pkey, val FROM tbl_a ORDER BY pkey; pkey val 0 1 diff --git a/storage/spider/mysql-test/spider/regression/e1121/r/load_data_local_ignore_ddi1.result b/storage/spider/mysql-test/spider/regression/e1121/r/load_data_local_ignore_ddi1.result index 737cccc42cb..bb4c6da7fb5 100644 --- a/storage/spider/mysql-test/spider/regression/e1121/r/load_data_local_ignore_ddi1.result +++ b/storage/spider/mysql-test/spider/regression/e1121/r/load_data_local_ignore_ddi1.result @@ -40,10 +40,10 @@ TRUNCATE TABLE mysql.general_log; connection master_1; LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/spider_outfile.tsv' IGNORE INTO TABLE tbl_a; connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%'; argument insert high_priority ignore into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(0,0),(1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9) -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%' SELECT pkey, val FROM tbl_a ORDER BY pkey; pkey val 0 1 diff --git a/storage/spider/mysql-test/spider/regression/e1121/r/load_data_local_replace_ddi0.result b/storage/spider/mysql-test/spider/regression/e1121/r/load_data_local_replace_ddi0.result index 7d8fb034544..324cdac2b4a 100644 --- a/storage/spider/mysql-test/spider/regression/e1121/r/load_data_local_replace_ddi0.result +++ b/storage/spider/mysql-test/spider/regression/e1121/r/load_data_local_replace_ddi0.result @@ -40,7 +40,7 @@ TRUNCATE TABLE mysql.general_log; connection master_1; LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/spider_outfile.tsv' REPLACE INTO TABLE tbl_a; connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%'; argument insert into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(0,0) select `pkey`,`val` from `auto_test_remote`.`tbl_a` where `pkey` = 0 for update @@ -72,7 +72,7 @@ update ignore `auto_test_remote`.`tbl_a` set `pkey` = 8,`val` = 8 where `pkey` = insert into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(9,9) select `pkey`,`val` from `auto_test_remote`.`tbl_a` where `pkey` = 9 for update update ignore `auto_test_remote`.`tbl_a` set `pkey` = 9,`val` = 9 where `pkey` = 9 and `val` = 10 limit 1 -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%' SELECT pkey, val FROM tbl_a ORDER BY pkey; pkey val 0 0 diff --git a/storage/spider/mysql-test/spider/regression/e1121/r/load_data_local_replace_ddi1.result b/storage/spider/mysql-test/spider/regression/e1121/r/load_data_local_replace_ddi1.result index f3e272c1cd1..e73b078de63 100644 --- a/storage/spider/mysql-test/spider/regression/e1121/r/load_data_local_replace_ddi1.result +++ b/storage/spider/mysql-test/spider/regression/e1121/r/load_data_local_replace_ddi1.result @@ -40,10 +40,10 @@ TRUNCATE TABLE mysql.general_log; connection master_1; LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/spider_outfile.tsv' REPLACE INTO TABLE tbl_a; connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%'; argument replace into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(0,0),(1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9) -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%' SELECT pkey, val FROM tbl_a ORDER BY pkey; pkey val 0 0 diff --git a/storage/spider/mysql-test/spider/regression/e1121/r/load_data_replace_ddi0.result b/storage/spider/mysql-test/spider/regression/e1121/r/load_data_replace_ddi0.result index 3ce058a9fc8..dd91e95d4cc 100644 --- a/storage/spider/mysql-test/spider/regression/e1121/r/load_data_replace_ddi0.result +++ b/storage/spider/mysql-test/spider/regression/e1121/r/load_data_replace_ddi0.result @@ -40,7 +40,7 @@ TRUNCATE TABLE mysql.general_log; connection master_1; LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/spider_outfile.tsv' REPLACE INTO TABLE tbl_a; connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%'; argument insert into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(0,0) select `pkey`,`val` from `auto_test_remote`.`tbl_a` where `pkey` = 0 for update @@ -72,7 +72,7 @@ update ignore `auto_test_remote`.`tbl_a` set `pkey` = 8,`val` = 8 where `pkey` = insert into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(9,9) select `pkey`,`val` from `auto_test_remote`.`tbl_a` where `pkey` = 9 for update update ignore `auto_test_remote`.`tbl_a` set `pkey` = 9,`val` = 9 where `pkey` = 9 and `val` = 10 limit 1 -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%' SELECT pkey, val FROM tbl_a ORDER BY pkey; pkey val 0 0 diff --git a/storage/spider/mysql-test/spider/regression/e1121/r/load_data_replace_ddi1.result b/storage/spider/mysql-test/spider/regression/e1121/r/load_data_replace_ddi1.result index 86124b9c5c6..974287ab900 100644 --- a/storage/spider/mysql-test/spider/regression/e1121/r/load_data_replace_ddi1.result +++ b/storage/spider/mysql-test/spider/regression/e1121/r/load_data_replace_ddi1.result @@ -40,10 +40,10 @@ TRUNCATE TABLE mysql.general_log; connection master_1; LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/spider_outfile.tsv' REPLACE INTO TABLE tbl_a; connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%'; argument replace into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(0,0),(1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9) -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%' SELECT pkey, val FROM tbl_a ORDER BY pkey; pkey val 0 0 diff --git a/storage/spider/mysql-test/spider/regression/e112122/include/group_by_order_by_limit_ok_init.inc b/storage/spider/mysql-test/spider/regression/e112122/include/group_by_order_by_limit_ok_init.inc index a6945218fab..48961d0d3f3 100644 --- a/storage/spider/mysql-test/spider/regression/e112122/include/group_by_order_by_limit_ok_init.inc +++ b/storage/spider/mysql-test/spider/regression/e112122/include/group_by_order_by_limit_ok_init.inc @@ -35,7 +35,7 @@ let $CHILD2_1_CREATE_TABLES= let $CHILD2_1_SELECT_TABLES= SELECT pkey, skey FROM tbl_a ORDER BY pkey; let $CHILD2_1_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; --let $CHILD2_2_DROP_TABLES_BACKUP= $CHILD2_2_DROP_TABLES let $CHILD2_2_DROP_TABLES= DROP TABLE IF EXISTS tbl_a; @@ -51,4 +51,4 @@ let $CHILD2_2_CREATE_TABLES= let $CHILD2_2_SELECT_TABLES= SELECT pkey, skey FROM tbl_a ORDER BY pkey; let $CHILD2_2_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; diff --git a/storage/spider/mysql-test/spider/regression/e112122/include/load_data_part_init.inc b/storage/spider/mysql-test/spider/regression/e112122/include/load_data_part_init.inc index 42a0ea72539..23126f77381 100644 --- a/storage/spider/mysql-test/spider/regression/e112122/include/load_data_part_init.inc +++ b/storage/spider/mysql-test/spider/regression/e112122/include/load_data_part_init.inc @@ -34,7 +34,7 @@ let $CHILD2_1_CREATE_TABLES= let $CHILD2_1_SELECT_TABLES= SELECT pkey, val FROM tbl_a ORDER BY pkey; let $CHILD2_1_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%'; --let $CHILD2_2_DROP_TABLES_BACKUP= $CHILD2_2_DROP_TABLES let $CHILD2_2_DROP_TABLES= DROP TABLE IF EXISTS tbl_a; @@ -49,4 +49,4 @@ let $CHILD2_2_CREATE_TABLES= let $CHILD2_2_SELECT_TABLES= SELECT pkey, val FROM tbl_a ORDER BY pkey; let $CHILD2_2_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%'; diff --git a/storage/spider/mysql-test/spider/regression/e112122/r/group_by_order_by_limit_ok.result b/storage/spider/mysql-test/spider/regression/e112122/r/group_by_order_by_limit_ok.result index 96746e09b8d..32d71ca9d6b 100644 --- a/storage/spider/mysql-test/spider/regression/e112122/r/group_by_order_by_limit_ok.result +++ b/storage/spider/mysql-test/spider/regression/e112122/r/group_by_order_by_limit_ok.result @@ -54,10 +54,10 @@ skey cnt 11 2 10 2 connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select count(0),`skey` from `auto_test_remote`.`tbl_a` group by `skey` order by count(0) desc,`skey` desc limit 5 -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey, skey FROM tbl_a ORDER BY pkey; pkey skey 1 1 @@ -76,10 +76,10 @@ pkey skey 26 11 28 13 connection child2_2; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; argument select count(0),`skey` from `auto_test_remote2`.`tbl_a` group by `skey` order by count(0) desc,`skey` desc limit 5 -SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %' SELECT pkey, skey FROM tbl_a ORDER BY pkey; pkey skey 0 0 diff --git a/storage/spider/mysql-test/spider/regression/e112122/r/load_data_part_ddi0.result b/storage/spider/mysql-test/spider/regression/e112122/r/load_data_part_ddi0.result index 23753239054..c32e8793bc1 100644 --- a/storage/spider/mysql-test/spider/regression/e112122/r/load_data_part_ddi0.result +++ b/storage/spider/mysql-test/spider/regression/e112122/r/load_data_part_ddi0.result @@ -50,10 +50,10 @@ TRUNCATE TABLE mysql.general_log; connection master_1; LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/spider_outfile.tsv' INTO TABLE tbl_a; connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%'; argument insert high_priority into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(1,1),(3,3),(5,5),(7,7),(9,9) -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%' SELECT pkey, val FROM tbl_a ORDER BY pkey; pkey val 1 1 @@ -62,10 +62,10 @@ pkey val 7 7 9 9 connection child2_2; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%'; argument insert high_priority into `auto_test_remote2`.`tbl_a`(`pkey`,`val`)values(0,0),(2,2),(4,4),(6,6),(8,8) -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%' SELECT pkey, val FROM tbl_a ORDER BY pkey; pkey val 0 0 diff --git a/storage/spider/mysql-test/spider/regression/e112122/r/load_data_part_ddi1.result b/storage/spider/mysql-test/spider/regression/e112122/r/load_data_part_ddi1.result index c30a5c037a7..dab51a3eab0 100644 --- a/storage/spider/mysql-test/spider/regression/e112122/r/load_data_part_ddi1.result +++ b/storage/spider/mysql-test/spider/regression/e112122/r/load_data_part_ddi1.result @@ -50,10 +50,10 @@ TRUNCATE TABLE mysql.general_log; connection master_1; LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/spider_outfile.tsv' INTO TABLE tbl_a; connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%'; argument insert high_priority into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(1,1),(3,3),(5,5),(7,7),(9,9) -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%' SELECT pkey, val FROM tbl_a ORDER BY pkey; pkey val 1 1 @@ -62,10 +62,10 @@ pkey val 7 7 9 9 connection child2_2; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%'; argument insert high_priority into `auto_test_remote2`.`tbl_a`(`pkey`,`val`)values(0,0),(2,2),(4,4),(6,6),(8,8) -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%' SELECT pkey, val FROM tbl_a ORDER BY pkey; pkey val 0 0 diff --git a/storage/spider/mysql-test/spider/regression/e112122/r/load_data_part_ignore_ddi0.result b/storage/spider/mysql-test/spider/regression/e112122/r/load_data_part_ignore_ddi0.result index 0071042cd58..7d99878b720 100644 --- a/storage/spider/mysql-test/spider/regression/e112122/r/load_data_part_ignore_ddi0.result +++ b/storage/spider/mysql-test/spider/regression/e112122/r/load_data_part_ignore_ddi0.result @@ -61,14 +61,14 @@ Warning 1062 Duplicate entry '7' for key 'PRIMARY' Warning 1062 Duplicate entry '8' for key 'PRIMARY' Warning 1062 Duplicate entry '9' for key 'PRIMARY' connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%'; argument insert high_priority into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(1,1) insert high_priority into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(3,3) insert high_priority into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(5,5) insert high_priority into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(7,7) insert high_priority into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(9,9) -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%' SELECT pkey, val FROM tbl_a ORDER BY pkey; pkey val 1 2 @@ -77,14 +77,14 @@ pkey val 7 8 9 10 connection child2_2; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%'; argument insert high_priority into `auto_test_remote2`.`tbl_a`(`pkey`,`val`)values(0,0) insert high_priority into `auto_test_remote2`.`tbl_a`(`pkey`,`val`)values(2,2) insert high_priority into `auto_test_remote2`.`tbl_a`(`pkey`,`val`)values(4,4) insert high_priority into `auto_test_remote2`.`tbl_a`(`pkey`,`val`)values(6,6) insert high_priority into `auto_test_remote2`.`tbl_a`(`pkey`,`val`)values(8,8) -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%' SELECT pkey, val FROM tbl_a ORDER BY pkey; pkey val 0 1 diff --git a/storage/spider/mysql-test/spider/regression/e112122/r/load_data_part_ignore_ddi1.result b/storage/spider/mysql-test/spider/regression/e112122/r/load_data_part_ignore_ddi1.result index 9f2e8dec535..0ae71b49ba6 100644 --- a/storage/spider/mysql-test/spider/regression/e112122/r/load_data_part_ignore_ddi1.result +++ b/storage/spider/mysql-test/spider/regression/e112122/r/load_data_part_ignore_ddi1.result @@ -50,10 +50,10 @@ TRUNCATE TABLE mysql.general_log; connection master_1; LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/spider_outfile.tsv' IGNORE INTO TABLE tbl_a; connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%'; argument insert high_priority ignore into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(1,1),(3,3),(5,5),(7,7),(9,9) -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%' SELECT pkey, val FROM tbl_a ORDER BY pkey; pkey val 1 2 @@ -62,10 +62,10 @@ pkey val 7 8 9 10 connection child2_2; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%'; argument insert high_priority ignore into `auto_test_remote2`.`tbl_a`(`pkey`,`val`)values(0,0),(2,2),(4,4),(6,6),(8,8) -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%' SELECT pkey, val FROM tbl_a ORDER BY pkey; pkey val 0 1 diff --git a/storage/spider/mysql-test/spider/regression/e112122/r/load_data_part_local_ddi0.result b/storage/spider/mysql-test/spider/regression/e112122/r/load_data_part_local_ddi0.result index 7ec2b5b0b9e..d2362e467e3 100644 --- a/storage/spider/mysql-test/spider/regression/e112122/r/load_data_part_local_ddi0.result +++ b/storage/spider/mysql-test/spider/regression/e112122/r/load_data_part_local_ddi0.result @@ -50,14 +50,14 @@ TRUNCATE TABLE mysql.general_log; connection master_1; LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/spider_outfile.tsv' INTO TABLE tbl_a; connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%'; argument insert high_priority into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(1,1) insert high_priority into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(3,3) insert high_priority into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(5,5) insert high_priority into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(7,7) insert high_priority into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(9,9) -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%' SELECT pkey, val FROM tbl_a ORDER BY pkey; pkey val 1 1 @@ -66,14 +66,14 @@ pkey val 7 7 9 9 connection child2_2; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%'; argument insert high_priority into `auto_test_remote2`.`tbl_a`(`pkey`,`val`)values(0,0) insert high_priority into `auto_test_remote2`.`tbl_a`(`pkey`,`val`)values(2,2) insert high_priority into `auto_test_remote2`.`tbl_a`(`pkey`,`val`)values(4,4) insert high_priority into `auto_test_remote2`.`tbl_a`(`pkey`,`val`)values(6,6) insert high_priority into `auto_test_remote2`.`tbl_a`(`pkey`,`val`)values(8,8) -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%' SELECT pkey, val FROM tbl_a ORDER BY pkey; pkey val 0 0 diff --git a/storage/spider/mysql-test/spider/regression/e112122/r/load_data_part_local_ddi1.result b/storage/spider/mysql-test/spider/regression/e112122/r/load_data_part_local_ddi1.result index f908ce1c1d5..c57dc96b91b 100644 --- a/storage/spider/mysql-test/spider/regression/e112122/r/load_data_part_local_ddi1.result +++ b/storage/spider/mysql-test/spider/regression/e112122/r/load_data_part_local_ddi1.result @@ -50,10 +50,10 @@ TRUNCATE TABLE mysql.general_log; connection master_1; LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/spider_outfile.tsv' INTO TABLE tbl_a; connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%'; argument insert high_priority ignore into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(1,1),(3,3),(5,5),(7,7),(9,9) -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%' SELECT pkey, val FROM tbl_a ORDER BY pkey; pkey val 1 1 @@ -62,10 +62,10 @@ pkey val 7 7 9 9 connection child2_2; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%'; argument insert high_priority ignore into `auto_test_remote2`.`tbl_a`(`pkey`,`val`)values(0,0),(2,2),(4,4),(6,6),(8,8) -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%' SELECT pkey, val FROM tbl_a ORDER BY pkey; pkey val 0 0 diff --git a/storage/spider/mysql-test/spider/regression/e112122/r/load_data_part_local_ignore_ddi0.result b/storage/spider/mysql-test/spider/regression/e112122/r/load_data_part_local_ignore_ddi0.result index c0a8f653fee..81005ac8c3f 100644 --- a/storage/spider/mysql-test/spider/regression/e112122/r/load_data_part_local_ignore_ddi0.result +++ b/storage/spider/mysql-test/spider/regression/e112122/r/load_data_part_local_ignore_ddi0.result @@ -61,14 +61,14 @@ Warning 1062 Duplicate entry '7' for key 'PRIMARY' Warning 1062 Duplicate entry '8' for key 'PRIMARY' Warning 1062 Duplicate entry '9' for key 'PRIMARY' connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%'; argument insert high_priority into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(1,1) insert high_priority into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(3,3) insert high_priority into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(5,5) insert high_priority into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(7,7) insert high_priority into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(9,9) -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%' SELECT pkey, val FROM tbl_a ORDER BY pkey; pkey val 1 2 @@ -77,14 +77,14 @@ pkey val 7 8 9 10 connection child2_2; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%'; argument insert high_priority into `auto_test_remote2`.`tbl_a`(`pkey`,`val`)values(0,0) insert high_priority into `auto_test_remote2`.`tbl_a`(`pkey`,`val`)values(2,2) insert high_priority into `auto_test_remote2`.`tbl_a`(`pkey`,`val`)values(4,4) insert high_priority into `auto_test_remote2`.`tbl_a`(`pkey`,`val`)values(6,6) insert high_priority into `auto_test_remote2`.`tbl_a`(`pkey`,`val`)values(8,8) -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%' SELECT pkey, val FROM tbl_a ORDER BY pkey; pkey val 0 1 diff --git a/storage/spider/mysql-test/spider/regression/e112122/r/load_data_part_local_ignore_ddi1.result b/storage/spider/mysql-test/spider/regression/e112122/r/load_data_part_local_ignore_ddi1.result index 619dd789d9a..d7cea9ed346 100644 --- a/storage/spider/mysql-test/spider/regression/e112122/r/load_data_part_local_ignore_ddi1.result +++ b/storage/spider/mysql-test/spider/regression/e112122/r/load_data_part_local_ignore_ddi1.result @@ -50,10 +50,10 @@ TRUNCATE TABLE mysql.general_log; connection master_1; LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/spider_outfile.tsv' IGNORE INTO TABLE tbl_a; connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%'; argument insert high_priority ignore into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(1,1),(3,3),(5,5),(7,7),(9,9) -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%' SELECT pkey, val FROM tbl_a ORDER BY pkey; pkey val 1 2 @@ -62,10 +62,10 @@ pkey val 7 8 9 10 connection child2_2; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%'; argument insert high_priority ignore into `auto_test_remote2`.`tbl_a`(`pkey`,`val`)values(0,0),(2,2),(4,4),(6,6),(8,8) -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%' SELECT pkey, val FROM tbl_a ORDER BY pkey; pkey val 0 1 diff --git a/storage/spider/mysql-test/spider/regression/e112122/r/load_data_part_local_replace_ddi0.result b/storage/spider/mysql-test/spider/regression/e112122/r/load_data_part_local_replace_ddi0.result index e12e380bb93..d6cd973f153 100644 --- a/storage/spider/mysql-test/spider/regression/e112122/r/load_data_part_local_replace_ddi0.result +++ b/storage/spider/mysql-test/spider/regression/e112122/r/load_data_part_local_replace_ddi0.result @@ -50,7 +50,7 @@ TRUNCATE TABLE mysql.general_log; connection master_1; LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/spider_outfile.tsv' REPLACE INTO TABLE tbl_a; connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%'; argument insert into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(1,1) select `pkey`,`val` from `auto_test_remote`.`tbl_a` where `pkey` = 1 for update @@ -67,7 +67,7 @@ update ignore `auto_test_remote`.`tbl_a` set `pkey` = 7,`val` = 7 where `pkey` = insert into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(9,9) select `pkey`,`val` from `auto_test_remote`.`tbl_a` where `pkey` = 9 for update update ignore `auto_test_remote`.`tbl_a` set `pkey` = 9,`val` = 9 where `pkey` = 9 and `val` = 10 limit 1 -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%' SELECT pkey, val FROM tbl_a ORDER BY pkey; pkey val 1 1 @@ -76,7 +76,7 @@ pkey val 7 7 9 9 connection child2_2; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%'; argument insert into `auto_test_remote2`.`tbl_a`(`pkey`,`val`)values(0,0) select `pkey`,`val` from `auto_test_remote2`.`tbl_a` where `pkey` = 0 for update @@ -93,7 +93,7 @@ update ignore `auto_test_remote2`.`tbl_a` set `pkey` = 6,`val` = 6 where `pkey` insert into `auto_test_remote2`.`tbl_a`(`pkey`,`val`)values(8,8) select `pkey`,`val` from `auto_test_remote2`.`tbl_a` where `pkey` = 8 for update update ignore `auto_test_remote2`.`tbl_a` set `pkey` = 8,`val` = 8 where `pkey` = 8 and `val` = 9 limit 1 -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%' SELECT pkey, val FROM tbl_a ORDER BY pkey; pkey val 0 0 diff --git a/storage/spider/mysql-test/spider/regression/e112122/r/load_data_part_local_replace_ddi1.result b/storage/spider/mysql-test/spider/regression/e112122/r/load_data_part_local_replace_ddi1.result index d367cbfd0ad..ac233777a6b 100644 --- a/storage/spider/mysql-test/spider/regression/e112122/r/load_data_part_local_replace_ddi1.result +++ b/storage/spider/mysql-test/spider/regression/e112122/r/load_data_part_local_replace_ddi1.result @@ -50,10 +50,10 @@ TRUNCATE TABLE mysql.general_log; connection master_1; LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/spider_outfile.tsv' REPLACE INTO TABLE tbl_a; connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%'; argument replace into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(1,1),(3,3),(5,5),(7,7),(9,9) -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%' SELECT pkey, val FROM tbl_a ORDER BY pkey; pkey val 1 1 @@ -62,10 +62,10 @@ pkey val 7 7 9 9 connection child2_2; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%'; argument replace into `auto_test_remote2`.`tbl_a`(`pkey`,`val`)values(0,0),(2,2),(4,4),(6,6),(8,8) -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%' SELECT pkey, val FROM tbl_a ORDER BY pkey; pkey val 0 0 diff --git a/storage/spider/mysql-test/spider/regression/e112122/r/load_data_part_replace_ddi0.result b/storage/spider/mysql-test/spider/regression/e112122/r/load_data_part_replace_ddi0.result index 039a8dd4fad..cd4bf6d70d5 100644 --- a/storage/spider/mysql-test/spider/regression/e112122/r/load_data_part_replace_ddi0.result +++ b/storage/spider/mysql-test/spider/regression/e112122/r/load_data_part_replace_ddi0.result @@ -50,7 +50,7 @@ TRUNCATE TABLE mysql.general_log; connection master_1; LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/spider_outfile.tsv' REPLACE INTO TABLE tbl_a; connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%'; argument insert into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(1,1) select `pkey`,`val` from `auto_test_remote`.`tbl_a` where `pkey` = 1 for update @@ -67,7 +67,7 @@ update ignore `auto_test_remote`.`tbl_a` set `pkey` = 7,`val` = 7 where `pkey` = insert into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(9,9) select `pkey`,`val` from `auto_test_remote`.`tbl_a` where `pkey` = 9 for update update ignore `auto_test_remote`.`tbl_a` set `pkey` = 9,`val` = 9 where `pkey` = 9 and `val` = 10 limit 1 -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%' SELECT pkey, val FROM tbl_a ORDER BY pkey; pkey val 1 1 @@ -76,7 +76,7 @@ pkey val 7 7 9 9 connection child2_2; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%'; argument insert into `auto_test_remote2`.`tbl_a`(`pkey`,`val`)values(0,0) select `pkey`,`val` from `auto_test_remote2`.`tbl_a` where `pkey` = 0 for update @@ -93,7 +93,7 @@ update ignore `auto_test_remote2`.`tbl_a` set `pkey` = 6,`val` = 6 where `pkey` insert into `auto_test_remote2`.`tbl_a`(`pkey`,`val`)values(8,8) select `pkey`,`val` from `auto_test_remote2`.`tbl_a` where `pkey` = 8 for update update ignore `auto_test_remote2`.`tbl_a` set `pkey` = 8,`val` = 8 where `pkey` = 8 and `val` = 9 limit 1 -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%' SELECT pkey, val FROM tbl_a ORDER BY pkey; pkey val 0 0 diff --git a/storage/spider/mysql-test/spider/regression/e112122/r/load_data_part_replace_ddi1.result b/storage/spider/mysql-test/spider/regression/e112122/r/load_data_part_replace_ddi1.result index c8155be9910..98c63603e27 100644 --- a/storage/spider/mysql-test/spider/regression/e112122/r/load_data_part_replace_ddi1.result +++ b/storage/spider/mysql-test/spider/regression/e112122/r/load_data_part_replace_ddi1.result @@ -50,10 +50,10 @@ TRUNCATE TABLE mysql.general_log; connection master_1; LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/spider_outfile.tsv' REPLACE INTO TABLE tbl_a; connection child2_1; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%'; argument replace into `auto_test_remote`.`tbl_a`(`pkey`,`val`)values(1,1),(3,3),(5,5),(7,7),(9,9) -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%' SELECT pkey, val FROM tbl_a ORDER BY pkey; pkey val 1 1 @@ -62,10 +62,10 @@ pkey val 7 7 9 9 connection child2_2; -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%'; +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%'; argument replace into `auto_test_remote2`.`tbl_a`(`pkey`,`val`)values(0,0),(2,2),(4,4),(6,6),(8,8) -SELECT argument FROM mysql.general_log WHERE argument LIKE '%`tbl_a`%' +SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%`tbl_a`%' SELECT pkey, val FROM tbl_a ORDER BY pkey; pkey val 0 0 diff --git a/storage/spider/mysql-test/spider/t/auto_increment_init.inc b/storage/spider/mysql-test/spider/t/auto_increment_init.inc index e4c1325072a..52245bdd02e 100644 --- a/storage/spider/mysql-test/spider/t/auto_increment_init.inc +++ b/storage/spider/mysql-test/spider/t/auto_increment_init.inc @@ -31,7 +31,7 @@ let $CHILD2_1_CREATE_TABLES= let $CHILD2_1_SELECT_TABLES= SELECT col_a, col_b, col_c FROM tbl_a ORDER BY col_a; let $CHILD2_1_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; --let $OUTPUT_CHILD_GROUP2_BACKUP= $OUTPUT_CHILD_GROUP2 --let $OUTPUT_CHILD_GROUP2= 1 --let $USE_GENERAL_LOG_BACKUP= $USE_GENERAL_LOG diff --git a/storage/spider/mysql-test/spider/t/basic_sql.test b/storage/spider/mysql-test/spider/t/basic_sql.test index a3184a14beb..5ba8c27d34e 100644 --- a/storage/spider/mysql-test/spider/t/basic_sql.test +++ b/storage/spider/mysql-test/spider/t/basic_sql.test @@ -146,7 +146,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -241,7 +241,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -315,7 +315,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%replace %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%replace %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -416,7 +416,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_TABLES3; if (!$OUTPUT_CHILD_GROUP2) @@ -460,7 +460,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -502,7 +502,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -544,7 +544,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -586,7 +586,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -628,7 +628,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -670,7 +670,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -712,7 +712,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -754,7 +754,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -796,7 +796,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -838,7 +838,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -880,7 +880,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -924,7 +924,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -966,7 +966,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -1007,7 +1007,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -1049,7 +1049,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -1091,7 +1091,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -1133,7 +1133,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -1176,7 +1176,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1222,7 +1222,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1269,7 +1269,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1315,7 +1315,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1362,7 +1362,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1406,7 +1406,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1453,10 +1453,10 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1501,10 +1501,10 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1551,10 +1551,10 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'replace %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'replace %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1598,10 +1598,10 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'replace %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'replace %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1646,10 +1646,10 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'replace %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'replace %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1694,10 +1694,10 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'replace %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'insert %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'replace %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1744,8 +1744,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1790,8 +1790,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1836,8 +1836,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1881,8 +1881,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1927,8 +1927,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -1972,8 +1972,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2017,8 +2017,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2062,8 +2062,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2107,8 +2107,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2159,8 +2159,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2204,8 +2204,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2256,8 +2256,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2308,8 +2308,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2360,8 +2360,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2412,8 +2412,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2464,8 +2464,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2516,8 +2516,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2568,8 +2568,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2620,8 +2620,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -2665,7 +2665,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE 'truncate %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'truncate %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/t/basic_sql_part.test b/storage/spider/mysql-test/spider/t/basic_sql_part.test index e1638642ab7..1bb18358d5d 100644 --- a/storage/spider/mysql-test/spider/t/basic_sql_part.test +++ b/storage/spider/mysql-test/spider/t/basic_sql_part.test @@ -176,13 +176,13 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_TABLES2; if (!$OUTPUT_CHILD_GROUP2) @@ -235,12 +235,12 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -290,12 +290,12 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -344,15 +344,15 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES2; if (!$OUTPUT_CHILD_GROUP2) @@ -404,15 +404,15 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'update %'; } eval $CHILD2_1_SELECT_TABLES2; if (!$OUTPUT_CHILD_GROUP2) @@ -466,15 +466,15 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES2; if (!$OUTPUT_CHILD_GROUP2) @@ -528,15 +528,15 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE 'delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE 'delete %'; } eval $CHILD2_1_SELECT_TABLES2; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/t/direct_aggregate.test b/storage/spider/mysql-test/spider/t/direct_aggregate.test index d65f4c5a624..5c0c37f483d 100644 --- a/storage/spider/mysql-test/spider/t/direct_aggregate.test +++ b/storage/spider/mysql-test/spider/t/direct_aggregate.test @@ -147,7 +147,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%handler %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/t/direct_aggregate_part.test b/storage/spider/mysql-test/spider/t/direct_aggregate_part.test index aebf210c745..cb0b55e9788 100644 --- a/storage/spider/mysql-test/spider/t/direct_aggregate_part.test +++ b/storage/spider/mysql-test/spider/t/direct_aggregate_part.test @@ -153,13 +153,13 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%handler %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%handler %'; } eval $CHILD2_1_SELECT_TABLES2; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/t/direct_update.test b/storage/spider/mysql-test/spider/t/direct_update.test index e0901062201..94f27e2859c 100644 --- a/storage/spider/mysql-test/spider/t/direct_update.test +++ b/storage/spider/mysql-test/spider/t/direct_update.test @@ -166,7 +166,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%handler %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/t/direct_update_part.test b/storage/spider/mysql-test/spider/t/direct_update_part.test index 95e2e2ab0d5..e8f1882594c 100644 --- a/storage/spider/mysql-test/spider/t/direct_update_part.test +++ b/storage/spider/mysql-test/spider/t/direct_update_part.test @@ -172,13 +172,13 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%handler %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%handler %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%handler %'; } eval $CHILD2_1_SELECT_TABLES2; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/t/function.test b/storage/spider/mysql-test/spider/t/function.test index ec2eeab9c94..2472e774782 100644 --- a/storage/spider/mysql-test/spider/t/function.test +++ b/storage/spider/mysql-test/spider/t/function.test @@ -125,7 +125,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TEXT_PK_TABLES1; if (!$OUTPUT_CHILD_GROUP2) @@ -219,7 +219,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%update %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/t/ha.test b/storage/spider/mysql-test/spider/t/ha.test index c12930e4aed..c36b7363a6d 100644 --- a/storage/spider/mysql-test/spider/t/ha.test +++ b/storage/spider/mysql-test/spider/t/ha.test @@ -233,13 +233,13 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -303,7 +303,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -435,13 +435,13 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -623,13 +623,13 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -693,7 +693,7 @@ if ($USE_CHILD_GROUP2) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -799,13 +799,13 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/t/ha_part.test b/storage/spider/mysql-test/spider/t/ha_part.test index 72ddcfd1f10..33fe9850b68 100644 --- a/storage/spider/mysql-test/spider/t/ha_part.test +++ b/storage/spider/mysql-test/spider/t/ha_part.test @@ -274,20 +274,20 @@ if ($HAVE_PARTITION) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; eval $CHILD2_1_SELECT_TABLES2; --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_3 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_3_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -356,14 +356,14 @@ if ($HAVE_PARTITION) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; eval $CHILD2_1_SELECT_TABLES2; --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -501,20 +501,20 @@ if ($HAVE_PARTITION) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; eval $CHILD2_1_SELECT_TABLES2; --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_3 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_3_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -723,20 +723,20 @@ if ($HAVE_PARTITION) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; eval $CHILD2_1_SELECT_TABLES2; --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_3 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_3_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -809,19 +809,19 @@ if ($HAVE_PARTITION) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_3 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_3_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) @@ -933,20 +933,20 @@ if ($HAVE_PARTITION) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES; eval $CHILD2_1_SELECT_TABLES2; --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_3 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_3_SELECT_TABLES; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/t/pushdown_not_like.test b/storage/spider/mysql-test/spider/t/pushdown_not_like.test index 95e4fa6eea8..a5fc3c0af68 100644 --- a/storage/spider/mysql-test/spider/t/pushdown_not_like.test +++ b/storage/spider/mysql-test/spider/t/pushdown_not_like.test @@ -110,7 +110,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select%'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select%'; } } diff --git a/storage/spider/mysql-test/spider/t/spider3_fixes.test b/storage/spider/mysql-test/spider/t/spider3_fixes.test index 13fa6f5fa39..64d3b657ae8 100644 --- a/storage/spider/mysql-test/spider/t/spider3_fixes.test +++ b/storage/spider/mysql-test/spider/t/spider3_fixes.test @@ -129,8 +129,10 @@ eval CREATE TABLE t2 ( id int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (id) ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_1; +--disable_ps_protocol eval $MASTER_1_AUTO_INCREMENT_INCREMENT2; eval $MASTER_1_AUTO_INCREMENT_OFFSET2; +--enable_ps_protocol if ($USE_REPLICATION) { SET SESSION sql_log_bin= 1; @@ -241,7 +243,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_INCREMENT_TABLES1; if ($OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/t/spider3_fixes_part.test b/storage/spider/mysql-test/spider/t/spider3_fixes_part.test index 3288c490a46..bcd85f42b81 100644 --- a/storage/spider/mysql-test/spider/t/spider3_fixes_part.test +++ b/storage/spider/mysql-test/spider/t/spider3_fixes_part.test @@ -163,8 +163,10 @@ if ($HAVE_PARTITION) id int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (id) ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_P_1; + --disable_ps_protocol eval $MASTER_1_AUTO_INCREMENT_INCREMENT2; eval $MASTER_1_AUTO_INCREMENT_OFFSET2; + --enable_ps_protocol if ($USE_REPLICATION) { SET SESSION sql_log_bin= 1; @@ -275,7 +277,7 @@ if ($HAVE_PARTITION) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_INCREMENT_TABLES1; if ($OUTPUT_CHILD_GROUP2) @@ -293,7 +295,7 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_2_SELECT_INCREMENT_TABLES1; if ($OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/t/spider_fixes.test b/storage/spider/mysql-test/spider/t/spider_fixes.test index 04e806fb612..9f7ada052ed 100644 --- a/storage/spider/mysql-test/spider/t/spider_fixes.test +++ b/storage/spider/mysql-test/spider/t/spider_fixes.test @@ -164,7 +164,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -206,7 +206,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -248,7 +248,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -337,7 +337,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -359,7 +359,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -381,7 +381,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -403,7 +403,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -425,7 +425,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -447,7 +447,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -469,7 +469,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -491,7 +491,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -513,7 +513,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -535,7 +535,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -557,7 +557,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; TRUNCATE TABLE mysql.general_log; } if (!$OUTPUT_CHILD_GROUP2) @@ -579,7 +579,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -676,7 +676,7 @@ if ($HAVE_TRIGGER) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_TABLES4; if (!$OUTPUT_CHILD_GROUP2) @@ -722,7 +722,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -812,7 +812,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -899,8 +899,8 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%update %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -1073,8 +1073,10 @@ eval CREATE TABLE t1 ( id int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (id) ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_1; +--disable_ps_protocol eval $MASTER_1_AUTO_INCREMENT_INCREMENT2; eval $MASTER_1_AUTO_INCREMENT_OFFSET2; +--enable_ps_protocol if ($USE_REPLICATION) { SET SESSION sql_log_bin= 1; @@ -1139,7 +1141,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_INCREMENT_TABLES1; if ($OUTPUT_CHILD_GROUP2) @@ -1324,7 +1326,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TEXT_PK_TABLES1; if (!$OUTPUT_CHILD_GROUP2) @@ -1380,7 +1382,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TEXT_PK_TABLES1; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/t/spider_fixes_part.test b/storage/spider/mysql-test/spider/t/spider_fixes_part.test index b0b9ce86588..0732ca0d2bf 100644 --- a/storage/spider/mysql-test/spider/t/spider_fixes_part.test +++ b/storage/spider/mysql-test/spider/t/spider_fixes_part.test @@ -176,13 +176,13 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES2; if (!$OUTPUT_CHILD_GROUP2) @@ -281,19 +281,19 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%delete %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%update %'; - SELECT argument FROM mysql.general_log WHERE argument LIKE '%delete %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%update %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%delete %'; } eval $CHILD2_1_SELECT_TABLES2; if (!$OUTPUT_CHILD_GROUP2) @@ -404,12 +404,12 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } if (!$OUTPUT_CHILD_GROUP2) { @@ -509,8 +509,10 @@ if ($HAVE_PARTITION) id int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (id) ) $MASTER_1_ENGINE $MASTER_1_CHARSET $MASTER_1_COMMENT_INCREMENT1_P_1; + --disable_ps_protocol eval $MASTER_1_AUTO_INCREMENT_INCREMENT2; eval $MASTER_1_AUTO_INCREMENT_OFFSET2; + --enable_ps_protocol if ($USE_REPLICATION) { SET SESSION sql_log_bin= 1; @@ -575,7 +577,7 @@ if ($HAVE_PARTITION) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_INCREMENT_TABLES1; if ($OUTPUT_CHILD_GROUP2) @@ -593,7 +595,7 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_2_SELECT_INCREMENT_TABLES1; if ($OUTPUT_CHILD_GROUP2) @@ -715,7 +717,7 @@ if ($HAVE_PARTITION) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES7; if (!$OUTPUT_CHILD_GROUP2) @@ -819,13 +821,13 @@ if ($HAVE_PARTITION) --connection child2_2 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_2_SELECT_TABLES; --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; } eval $CHILD2_1_SELECT_TABLES2; if (!$OUTPUT_CHILD_GROUP2) diff --git a/storage/spider/mysql-test/spider/t/timestamp_init.inc b/storage/spider/mysql-test/spider/t/timestamp_init.inc index 811c34c9b9a..22587bcf65a 100644 --- a/storage/spider/mysql-test/spider/t/timestamp_init.inc +++ b/storage/spider/mysql-test/spider/t/timestamp_init.inc @@ -49,7 +49,7 @@ let $CHILD2_1_SELECT_TABLE= let $CHILD2_1_SELECT_TABLE_F= SELECT col_d, col_t FROM tbl_f; let $CHILD2_1_SELECT_ARGUMENT1= - SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%select %'; let $CHILD2_1_DROP_INDEX= DROP INDEX i_ts ON tbl_a; let $CHILD2_1_SHOW_CREATE_TABLE= diff --git a/storage/spider/mysql-test/spider/t/vp_fixes.test b/storage/spider/mysql-test/spider/t/vp_fixes.test index 90380227040..2c3e1523611 100644 --- a/storage/spider/mysql-test/spider/t/vp_fixes.test +++ b/storage/spider/mysql-test/spider/t/vp_fixes.test @@ -206,7 +206,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_TABLES5; if (!$OUTPUT_CHILD_GROUP2) @@ -303,7 +303,7 @@ if ($USE_CHILD_GROUP2) --connection child2_1 if ($USE_GENERAL_LOG) { - SELECT argument FROM mysql.general_log WHERE argument LIKE '%insert %'; + SELECT argument FROM mysql.general_log WHERE command_type != 'Execute' AND argument LIKE '%insert %'; } eval $CHILD2_1_SELECT_TABLES5; if (!$OUTPUT_CHILD_GROUP2) From 6fab256bc8539f848c77f9bff0c7b7e024f7943d Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 29 Jun 2021 20:12:00 +0200 Subject: [PATCH 207/251] disable spider/bugfix.wait_timeout --- storage/spider/mysql-test/spider/bugfix/disabled.def | 1 + 1 file changed, 1 insertion(+) create mode 100644 storage/spider/mysql-test/spider/bugfix/disabled.def diff --git a/storage/spider/mysql-test/spider/bugfix/disabled.def b/storage/spider/mysql-test/spider/bugfix/disabled.def new file mode 100644 index 00000000000..e19ea07b76b --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/disabled.def @@ -0,0 +1 @@ +wait_timeout : MDEV-26045 From 771f3cf995897069dd2170f7b507722f7172363d Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 28 Jun 2021 12:27:00 +0200 Subject: [PATCH 208/251] make --rr work with InnoDB again Since 420f8e24ab7 InnoDB uses O_DIRECT by default --- mysql-test/lib/My/Debugger.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/lib/My/Debugger.pm b/mysql-test/lib/My/Debugger.pm index 2a5c9c63d96..a115da92e7e 100644 --- a/mysql-test/lib/My/Debugger.pm +++ b/mysql-test/lib/My/Debugger.pm @@ -77,7 +77,7 @@ my %debuggers = ( options => '-f -o {log} {exe} {args}', }, rr => { - options => '_RR_TRACE_DIR={log} rr record {exe} {args} --loose-skip-innodb-use-native-aio', + options => '_RR_TRACE_DIR={log} rr record {exe} {args} --loose-skip-innodb-use-native-aio --loose-innodb-flush-method=fsync', run => 'env', pre => sub { ::mtr_error('rr requires kernel.perf_event_paranoid <= 1') From c8fb911e9cab909ccfbf2a75cb90af501c819f5b Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 28 Jun 2021 22:08:52 +0200 Subject: [PATCH 209/251] fix main.lock_kill crashes in --ps --embed when checking whether thd wasn't killed before this emb_advanced_command(), take into account that it could've been killed before the *previous* emb_advanced_command(). That is, the previous one has already set thd to NULL and this one only wanted a COM_STMT_RESET after a failure. --- libmysqld/lib_sql.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc index 5374c420fac..a8f554326cd 100644 --- a/libmysqld/lib_sql.cc +++ b/libmysqld/lib_sql.cc @@ -115,7 +115,7 @@ emb_advanced_command(MYSQL *mysql, enum enum_server_command command, NET *net= &mysql->net; my_bool stmt_skip= stmt ? stmt->state != MYSQL_STMT_INIT_DONE : FALSE; - if (thd->killed != NOT_KILLED) + if (thd && thd->killed != NOT_KILLED) { if (thd->killed < KILL_CONNECTION) thd->killed= NOT_KILLED; From 8711adb7863b10fd868cc2b1c84c3416e715b539 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 30 Jun 2021 01:00:50 +0200 Subject: [PATCH 210/251] fix JSON_ARRAYAGG not to over-quote json in joins use metadata (in particular is_json() property) of the original argument item, even if the actual argument was later replaced with an Item_temptable_field --- mysql-test/main/func_json.result | 6 +++--- sql/item_jsonfunc.cc | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/mysql-test/main/func_json.result b/mysql-test/main/func_json.result index 0c242a886b7..a889cb228b7 100644 --- a/mysql-test/main/func_json.result +++ b/mysql-test/main/func_json.result @@ -1376,9 +1376,9 @@ SELECT t1.id, JSON_ARRAYAGG(JSON_OBJECT('id',t2.id)) as materials from t1 LEFT JOIN t2 on t1.id = t2.owner_id GROUP BY t1.id ORDER BY id; id materials -1 ["{\"id\": 1}","{\"id\": 2}"] -2 ["{\"id\": 3}"] -3 ["{\"id\": 4}"] +1 [{"id": 1},{"id": 2}] +2 [{"id": 3}] +3 [{"id": 4}] DROP TABLE t1; DROP TABLE t2; # diff --git a/sql/item_jsonfunc.cc b/sql/item_jsonfunc.cc index 4b63b119a83..60c0e4cc2fe 100644 --- a/sql/item_jsonfunc.cc +++ b/sql/item_jsonfunc.cc @@ -3723,12 +3723,12 @@ String *Item_func_json_arrayagg::get_str_from_item(Item *i, String *tmp) } -String *Item_func_json_arrayagg::get_str_from_field(Item *i,Field *f, +String *Item_func_json_arrayagg::get_str_from_field(Item *, Field *f, String *tmp, const uchar *key, size_t offset) { m_tmp_json.length(0); - if (append_json_value_from_field(&m_tmp_json, i, f, key, offset, tmp)) + if (append_json_value_from_field(&m_tmp_json, *orig_args, f, key, offset, tmp)) return NULL; return &m_tmp_json; From 83684fc9a4d81f15fee1888123cc7f7a4e298c4f Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 30 Jun 2021 01:03:49 +0200 Subject: [PATCH 211/251] MDEV-23004 When using GROUP BY with JSON_ARRAYAGG with joint table, the square brackets are not included make test results stable followup for 98c7916f0f2 --- mysql-test/main/func_json.result | 2 +- mysql-test/main/func_json.test | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/main/func_json.result b/mysql-test/main/func_json.result index a889cb228b7..d9a797477ae 100644 --- a/mysql-test/main/func_json.result +++ b/mysql-test/main/func_json.result @@ -1372,7 +1372,7 @@ CREATE TABLE t1(id int primary key, name varchar(50)); CREATE TABLE t2(id int, owner_id int); INSERT INTO t1 VALUES (1, "name1"), (2, "name2"), (3, "name3"); INSERT INTO t2 VALUES (1, 1), (2, 1), (3, 2), (4, 3); -SELECT t1.id, JSON_ARRAYAGG(JSON_OBJECT('id',t2.id)) as materials +SELECT t1.id, JSON_ARRAYAGG(JSON_OBJECT('id',t2.id) ORDER BY t2.id) as materials from t1 LEFT JOIN t2 on t1.id = t2.owner_id GROUP BY t1.id ORDER BY id; id materials diff --git a/mysql-test/main/func_json.test b/mysql-test/main/func_json.test index f08a72a5bce..d598809adf5 100644 --- a/mysql-test/main/func_json.test +++ b/mysql-test/main/func_json.test @@ -866,7 +866,7 @@ CREATE TABLE t2(id int, owner_id int); INSERT INTO t1 VALUES (1, "name1"), (2, "name2"), (3, "name3"); INSERT INTO t2 VALUES (1, 1), (2, 1), (3, 2), (4, 3); -SELECT t1.id, JSON_ARRAYAGG(JSON_OBJECT('id',t2.id)) as materials +SELECT t1.id, JSON_ARRAYAGG(JSON_OBJECT('id',t2.id) ORDER BY t2.id) as materials from t1 LEFT JOIN t2 on t1.id = t2.owner_id GROUP BY t1.id ORDER BY id; From a1e2ca057dda4dc434f057ce9391aa7afd9b5583 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Wed, 30 Jun 2021 10:38:44 +0300 Subject: [PATCH 212/251] MDEV-26030 : Warning: Memory not freed: 32 on setting wsrep_sst_auth Call to wsrep_sst_auth_free() was missing from normal shutdown. --- sql/mysqld.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index a5a3f650990..23ec3592073 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1900,6 +1900,7 @@ static void mysqld_exit(int exit_code) wait_for_signal_thread_to_end(); #ifdef WITH_WSREP wsrep_deinit_server(); + wsrep_sst_auth_free(); #endif /* WITH_WSREP */ mysql_audit_finalize(); clean_up_mutexes(); From eb20c91b55e4b51be533314994b36bf9b24016f3 Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Tue, 29 Jun 2021 16:31:28 +0300 Subject: [PATCH 213/251] MDEV-25969: Condition pushdown into derived table doesn't work if select list uses SP Consider a query of the form: select ... from (select item2 as COL1) as T where COL1=123 Condition pushdown into derived table will try to push "COL1=123" condition down into table T. The process of pushdown involves "substituting" the item, that is, replacing Item_field("T.COL1") with its "producing item" item2. In order to use item2, one needs to clone it (call Item::build_clone). If the item is not cloneable (e.g. Item_func_sp is not), the pushdown process will fail and nothing at all will be pushed. Fixed by introducing transform_condition_or_part() which will try to apply the transformation for as many parts of condition as possible. The parts of condition that couldn't be transformed are dropped. --- mysql-test/r/derived_cond_pushdown.result | 146 ++++++++++++++++++++++ mysql-test/t/derived_cond_pushdown.test | 70 +++++++++++ sql/sql_derived.cc | 79 +++++++++++- 3 files changed, 289 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/derived_cond_pushdown.result b/mysql-test/r/derived_cond_pushdown.result index 28532ae88a4..f5ef3c3a84d 100644 --- a/mysql-test/r/derived_cond_pushdown.result +++ b/mysql-test/r/derived_cond_pushdown.result @@ -10673,4 +10673,150 @@ Warnings: Note 1003 select `v2`.`a` AS `a`,`v2`.`f` AS `f`,`v2`.`g` AS `g` from `test`.`v2` where `v2`.`f` = `v2`.`a` and `v2`.`g` = `v2`.`a` drop view v1,v2; drop table t1; +# +# MDEV-25969: Condition pushdown into derived table doesn't work if select list uses SP +# +create function f1(a int) returns int DETERMINISTIC return (a+1); +create table t1 ( +pk int primary key, +a int, +b int, +key(a) +); +create table t2(a int); +insert into t2 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t3(a int); +insert into t3 select A.a + B.a* 10 + C.a * 100 from t2 A, t2 B, t2 C; +insert into t1 select a,a,a from t3; +create view v1 as +select +t1.a as col1, +f1(t1.b) as col2 +from +t1; +create view v2 as +select +t1.a as col1, +f1(t1.b) as col2 +from +t1; +create view v3 as +select col2, col1 from v1 +union all +select col2, col1 from v2; +explain select * from v3 where col1=123; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY ALL NULL NULL NULL NULL 2 Using where +2 DERIVED t1 ref a a 5 const 1 +3 UNION t1 ref a a 5 const 1 +# This must use ref accesses for reading table t1, not full scans: +explain format=json +select * from v3 where col1=123 and col2=321; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "table_name": "", + "access_type": "ALL", + "rows": 2, + "filtered": 100, + "attached_condition": "v3.col1 = 123 and v3.col2 = 321", + "materialized": { + "query_block": { + "union_result": { + "table_name": "", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "table": { + "table_name": "t1", + "access_type": "ref", + "possible_keys": ["a"], + "key": "a", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["const"], + "rows": 1, + "filtered": 100 + } + } + }, + { + "query_block": { + "select_id": 3, + "table": { + "table_name": "t1", + "access_type": "ref", + "possible_keys": ["a"], + "key": "a", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["const"], + "rows": 1, + "filtered": 100 + } + } + } + ] + } + } + } + } + } +} +drop function f1; +drop view v1,v2,v3; +drop table t1, t2,t3; +# +# Another testcase, with pushdown through GROUP BY +# +create table t1 (a int, b int); +insert into t1 values (1,1),(2,2),(3,3); +create function f1(a int) returns int DETERMINISTIC return (a+1); +create view v2(a, a2, s) as +select a, f1(a), sum(b) from t1 group by a, f1(a); +# Here, +# "(s+1) > 10" will be pushed into HAVING +# "a > 1" will be pushed all the way to the table scan on t1 +# "a2>123" will be pushed into HAVING (as it refers to an SP call which +# prevents pushing it to the WHERE) +explain format=json +select * from v2 where (s+1) > 10 AND a > 1 and a2>123; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "table_name": "", + "access_type": "ALL", + "rows": 3, + "filtered": 100, + "attached_condition": "v2.s + 1 > 10 and v2.a > 1 and v2.a2 > 123", + "materialized": { + "query_block": { + "select_id": 2, + "having_condition": "s + 1 > 10 and a2 > 123", + "filesort": { + "sort_key": "t1.a, f1(t1.a)", + "temporary_table": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 3, + "filtered": 100, + "attached_condition": "t1.a > 1" + } + } + } + } + } + } + } +} +drop view v2; +drop function f1; +drop table t1; # End of 10.2 tests diff --git a/mysql-test/t/derived_cond_pushdown.test b/mysql-test/t/derived_cond_pushdown.test index 58f38ac1e5a..9b7658a725e 100644 --- a/mysql-test/t/derived_cond_pushdown.test +++ b/mysql-test/t/derived_cond_pushdown.test @@ -2237,4 +2237,74 @@ eval explain extended $q2; drop view v1,v2; drop table t1; +--echo # +--echo # MDEV-25969: Condition pushdown into derived table doesn't work if select list uses SP +--echo # +create function f1(a int) returns int DETERMINISTIC return (a+1); + +create table t1 ( + pk int primary key, + a int, + b int, + key(a) +); + +create table t2(a int); +insert into t2 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); + +create table t3(a int); +insert into t3 select A.a + B.a* 10 + C.a * 100 from t2 A, t2 B, t2 C; + +insert into t1 select a,a,a from t3; + +create view v1 as +select + t1.a as col1, + f1(t1.b) as col2 +from + t1; + +create view v2 as +select + t1.a as col1, + f1(t1.b) as col2 +from + t1; +create view v3 as +select col2, col1 from v1 +union all +select col2, col1 from v2; + +explain select * from v3 where col1=123; + +--echo # This must use ref accesses for reading table t1, not full scans: +explain format=json +select * from v3 where col1=123 and col2=321; + +drop function f1; +drop view v1,v2,v3; +drop table t1, t2,t3; + +--echo # +--echo # Another testcase, with pushdown through GROUP BY +--echo # +create table t1 (a int, b int); +insert into t1 values (1,1),(2,2),(3,3); + +create function f1(a int) returns int DETERMINISTIC return (a+1); + +create view v2(a, a2, s) as +select a, f1(a), sum(b) from t1 group by a, f1(a); + +--echo # Here, +--echo # "(s+1) > 10" will be pushed into HAVING +--echo # "a > 1" will be pushed all the way to the table scan on t1 +--echo # "a2>123" will be pushed into HAVING (as it refers to an SP call which +--echo # prevents pushing it to the WHERE) +explain format=json +select * from v2 where (s+1) > 10 AND a > 1 and a2>123; + +drop view v2; +drop function f1; +drop table t1; --echo # End of 10.2 tests diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index 632baf4bc5b..30bffeb7581 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -1192,6 +1192,68 @@ bool mysql_derived_reinit(THD *thd, LEX *lex, TABLE_LIST *derived) } +/* + @brief + Given condition cond and transformer+argument, try transforming as many + conjuncts as possible. + + @detail + The motivation of this function is to convert the condition that's being + pushed into a WHERE clause with derived_field_transformer_for_where or + with derived_grouping_field_transformer_for_where. + The transformer may fail for some sub-condition, in this case we want to + convert the most restrictive part of the condition that can be pushed. + + This function only does it for top-level AND: conjuncts that could not be + converted are dropped. + + @return + Converted condition, or NULL if nothing could be converted +*/ + +static +Item *transform_condition_or_part(THD *thd, + Item *cond, + Item_transformer transformer, + uchar *arg) +{ + if (cond->type() != Item::COND_ITEM || + ((Item_cond*) cond)->functype() != Item_func::COND_AND_FUNC) + { + Item *new_item= cond->transform(thd, transformer, arg); + // Indicate that the condition is not pushable + if (!new_item) + cond->clear_extraction_flag(); + return new_item; + } + + List_iterator li(*((Item_cond*) cond)->argument_list()); + Item *item; + while ((item=li++)) + { + Item *new_item= item->transform(thd, transformer, arg); + if (!new_item) + { + // Indicate that the condition is not pushable + item->clear_extraction_flag(); + li.remove(); + } + else + li.replace(new_item); + } + + switch (((Item_cond*) cond)->argument_list()->elements) + { + case 0: + return NULL; + case 1: + return ((Item_cond*) cond)->argument_list()->head(); + default: + return cond; + } +} + + /** @brief Extract the condition depended on derived table/view and pushed it there @@ -1287,9 +1349,11 @@ bool pushdown_cond_for_derived(THD *thd, Item *cond, TABLE_LIST *derived) if (!sl->join->group_list && !sl->with_sum_func) { /* extracted_cond_copy is pushed into where of sl */ - extracted_cond_copy= extracted_cond_copy->transform(thd, - &Item::derived_field_transformer_for_where, - (uchar*) sl); + extracted_cond_copy= + transform_condition_or_part(thd, + extracted_cond_copy, + &Item::derived_field_transformer_for_where, + (uchar*)sl); if (extracted_cond_copy) { extracted_cond_copy->walk( @@ -1316,9 +1380,12 @@ bool pushdown_cond_for_derived(THD *thd, Item *cond, TABLE_LIST *derived) pushed into the where clause of sl to make them usable in the new context */ if (cond_over_grouping_fields) - cond_over_grouping_fields= cond_over_grouping_fields->transform(thd, - &Item::derived_grouping_field_transformer_for_where, - (uchar*) sl); + { + cond_over_grouping_fields= + transform_condition_or_part(thd, cond_over_grouping_fields, + &Item::derived_grouping_field_transformer_for_where, + (uchar*) sl); + } if (cond_over_grouping_fields) { From 4a6e2d343745c11086c05f0041a8267591bb073c Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Wed, 30 Jun 2021 16:43:43 +0300 Subject: [PATCH 214/251] Post-merge fix: update derived_cond_pushdown.result --- mysql-test/main/derived_cond_pushdown.result | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/main/derived_cond_pushdown.result b/mysql-test/main/derived_cond_pushdown.result index b886db20eed..d2c116913f4 100644 --- a/mysql-test/main/derived_cond_pushdown.result +++ b/mysql-test/main/derived_cond_pushdown.result @@ -10764,6 +10764,7 @@ EXPLAIN { "query_block": { "select_id": 3, + "operation": "UNION", "table": { "table_name": "t1", "access_type": "ref", From b62672af720560e40336c86fbe63151e1095f421 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 30 Jun 2021 21:17:57 +0200 Subject: [PATCH 215/251] MDEV-26054 Server crashes in Item_func_json_arrayagg::get_str_from_field Revert "fix JSON_ARRAYAGG not to over-quote json in joins" This removes 8711adb7863 but keeps the test case. A different fix is coming up. Because args can be Item_field's that are later replaced by Item_direct_view_ref to the actual field. While Item_field preserved in orig_args will stay unfixed with item->field==NULL and no metadata --- mysql-test/main/func_json.result | 11 +++++++++++ mysql-test/main/func_json.test | 11 +++++++++++ sql/item_jsonfunc.cc | 4 ++-- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/mysql-test/main/func_json.result b/mysql-test/main/func_json.result index d9a797477ae..cfe15eafa10 100644 --- a/mysql-test/main/func_json.result +++ b/mysql-test/main/func_json.result @@ -1382,5 +1382,16 @@ id materials DROP TABLE t1; DROP TABLE t2; # +# MDEV-26054 Server crashes in Item_func_json_arrayagg::get_str_from_field +# +CREATE TABLE t (a VARCHAR(8)); +CREATE VIEW v AS SELECT * FROM t; +INSERT INTO t VALUES ('foo'),('bar'); +SELECT JSON_ARRAYAGG(a) AS f FROM v; +f +["foo","bar"] +DROP VIEW v; +DROP TABLE t; +# # End of 10.5 tests # diff --git a/mysql-test/main/func_json.test b/mysql-test/main/func_json.test index d598809adf5..f96f2be1dea 100644 --- a/mysql-test/main/func_json.test +++ b/mysql-test/main/func_json.test @@ -873,6 +873,17 @@ SELECT t1.id, JSON_ARRAYAGG(JSON_OBJECT('id',t2.id) ORDER BY t2.id) as materials DROP TABLE t1; DROP TABLE t2; +--echo # +--echo # MDEV-26054 Server crashes in Item_func_json_arrayagg::get_str_from_field +--echo # + +CREATE TABLE t (a VARCHAR(8)); +CREATE VIEW v AS SELECT * FROM t; +INSERT INTO t VALUES ('foo'),('bar'); +SELECT JSON_ARRAYAGG(a) AS f FROM v; +DROP VIEW v; +DROP TABLE t; + --echo # --echo # End of 10.5 tests --echo # diff --git a/sql/item_jsonfunc.cc b/sql/item_jsonfunc.cc index 60c0e4cc2fe..4b63b119a83 100644 --- a/sql/item_jsonfunc.cc +++ b/sql/item_jsonfunc.cc @@ -3723,12 +3723,12 @@ String *Item_func_json_arrayagg::get_str_from_item(Item *i, String *tmp) } -String *Item_func_json_arrayagg::get_str_from_field(Item *, Field *f, +String *Item_func_json_arrayagg::get_str_from_field(Item *i,Field *f, String *tmp, const uchar *key, size_t offset) { m_tmp_json.length(0); - if (append_json_value_from_field(&m_tmp_json, *orig_args, f, key, offset, tmp)) + if (append_json_value_from_field(&m_tmp_json, i, f, key, offset, tmp)) return NULL; return &m_tmp_json; From add782a13e58c027c14d548fa705f48fc25cc3e1 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 30 Jun 2021 21:28:07 +0200 Subject: [PATCH 216/251] fix JSON_ARRAYAGG not to over-quote json in joins This replaces 8711adb7863 if a temptable field is created for some json expression (is_json_type() returns true), make this temptable field a proper json field. A field is a json field (see Item_field::is_json_type()) if it has a CHECK constraint of JSON_VALID(field). Note that it will never be actually checked for temptable fields, so it won't cause a run-time slowdown. --- sql/sql_select.cc | 22 ++++++++++++++++++++++ sql/table.cc | 21 +++++++++++++-------- sql/table.h | 2 ++ 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 50a42ff8410..5a02218bb4a 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -18412,6 +18412,25 @@ Field *Item_func_sp::create_tmp_field_ex(MEM_ROOT *root, TABLE *table, return result; } + +static bool make_json_valid_expr(TABLE *table, Field *field) +{ + THD *thd= table->in_use; + Query_arena backup_arena; + Item *expr, *item_field; + + if (!table->expr_arena && table->init_expr_arena(thd->mem_root)) + return NULL; + + thd->set_n_backup_active_arena(table->expr_arena, &backup_arena); + if ((item_field= new (thd->mem_root) Item_field(thd, field)) && + (expr= new (thd->mem_root) Item_func_json_valid(thd, item_field))) + field->check_constraint= add_virtual_expression(thd, expr); + thd->restore_active_arena(table->expr_arena, &backup_arena); + return field->check_constraint == NULL; +} + + /** Create field for temporary table. @@ -18457,6 +18476,9 @@ Field *create_tmp_field(TABLE *table, Item *item, make_copy_field); Field *result= item->create_tmp_field_ex(table->in_use->mem_root, table, &src, &prm); + if (item->is_json_type() && make_json_valid_expr(table, result)) + result= NULL; + *from_field= src.field(); *default_field= src.default_field(); if (src.item_result_field()) diff --git a/sql/table.cc b/sql/table.cc index c9420892160..73d701e0b2b 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -61,6 +61,17 @@ public: } }; +bool TABLE::init_expr_arena(MEM_ROOT *mem_root) +{ + /* + We need to use CONVENTIONAL_EXECUTION here to ensure that + any new items created by fix_fields() are not reverted. + */ + expr_arena= new (alloc_root(mem_root, sizeof(Table_arena))) + Table_arena(mem_root, Query_arena::STMT_CONVENTIONAL_EXECUTION); + return expr_arena == NULL; +} + struct extra2_fields { LEX_CUSTRING version; @@ -1155,14 +1166,8 @@ bool parse_vcol_defs(THD *thd, MEM_ROOT *mem_root, TABLE *table, table->s->table_check_constraints * sizeof(Virtual_column_info*)); DBUG_ASSERT(table->expr_arena == NULL); - /* - We need to use CONVENTIONAL_EXECUTION here to ensure that - any new items created by fix_fields() are not reverted. - */ - table->expr_arena= new (alloc_root(mem_root, sizeof(Table_arena))) - Table_arena(mem_root, - Query_arena::STMT_CONVENTIONAL_EXECUTION); - if (!table->expr_arena) + + if (table->init_expr_arena(mem_root)) DBUG_RETURN(1); thd->set_n_backup_active_arena(table->expr_arena, &backup_arena); diff --git a/sql/table.h b/sql/table.h index 183ade8f1d9..2e074abcea0 100644 --- a/sql/table.h +++ b/sql/table.h @@ -1612,6 +1612,8 @@ public: m_needs_reopen= value; } + bool init_expr_arena(MEM_ROOT *mem_root); + bool alloc_keys(uint key_count); bool check_tmp_key(uint key, uint key_parts, uint (*next_field_no) (uchar *), uchar *arg); From c7443a0911a98dccfc9c5bda4c2f4d9052516d8f Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Thu, 1 Jul 2021 01:08:28 +0300 Subject: [PATCH 217/251] MDEV-25969: Condition pushdown into derived table doesn't work if select list uses SP Post-merge fix in 10.4: add a testcase for pushdown into IN subquery --- mysql-test/main/derived_cond_pushdown.result | 57 +++++++++++++++++++- mysql-test/main/derived_cond_pushdown.test | 19 ++++++- 2 files changed, 74 insertions(+), 2 deletions(-) diff --git a/mysql-test/main/derived_cond_pushdown.result b/mysql-test/main/derived_cond_pushdown.result index 76918d975cc..01a863ccb8b 100644 --- a/mysql-test/main/derived_cond_pushdown.result +++ b/mysql-test/main/derived_cond_pushdown.result @@ -10814,9 +10814,64 @@ EXPLAIN } } } +# Extra test for 10.4+: Check that this works for pushdown into IN +# subqueries: +create table t4 (a int, b int, c decimal); +insert into t4 select a,a,a from t1; +# The subquery must be materialized and must have +# "attached_condition": "t1.a + 1 > 10", +# "having_condition": "`f1(a)` > 1 and `sum(b)` > 123", +explain format=json +select * +from t4 +where +(a,b,c) in (select a, f1(a), sum(b) from t1 group by a, f1(a)) +and +(a+1) > 10 AND b > 1 and c>123; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "table": { + "table_name": "t4", + "access_type": "ALL", + "rows": 3, + "filtered": 100, + "attached_condition": "t4.a + 1 > 10 and t4.b > 1 and t4.c > 123 and t4.a is not null and t4.b is not null and t4.c is not null" + }, + "table": { + "table_name": "", + "access_type": "eq_ref", + "possible_keys": ["distinct_key"], + "key": "distinct_key", + "key_length": "23", + "used_key_parts": ["a", "f1(a)", "sum(b)"], + "ref": ["test.t4.a", "test.t4.b", "test.t4.c"], + "rows": 1, + "filtered": 100, + "attached_condition": "t4.c = ``.`sum(b)`", + "materialized": { + "unique": 1, + "query_block": { + "select_id": 2, + "having_condition": "`f1(a)` > 1 and `sum(b)` > 123", + "temporary_table": { + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 3, + "filtered": 100, + "attached_condition": "t1.a + 1 > 10" + } + } + } + } + } + } +} drop view v2; drop function f1; -drop table t1; +drop table t1, t4; # End of 10.2 tests # # MDEV-14579: pushdown conditions into materialized views/derived tables diff --git a/mysql-test/main/derived_cond_pushdown.test b/mysql-test/main/derived_cond_pushdown.test index bc5034621b4..9544ad34572 100644 --- a/mysql-test/main/derived_cond_pushdown.test +++ b/mysql-test/main/derived_cond_pushdown.test @@ -2305,9 +2305,26 @@ select a, f1(a), sum(b) from t1 group by a, f1(a); explain format=json select * from v2 where (s+1) > 10 AND a > 1 and a2>123; +--echo # Extra test for 10.4+: Check that this works for pushdown into IN +--echo # subqueries: + +create table t4 (a int, b int, c decimal); +insert into t4 select a,a,a from t1; + +--echo # The subquery must be materialized and must have +--echo # "attached_condition": "t1.a + 1 > 10", +--echo # "having_condition": "`f1(a)` > 1 and `sum(b)` > 123", +explain format=json +select * +from t4 +where + (a,b,c) in (select a, f1(a), sum(b) from t1 group by a, f1(a)) + and + (a+1) > 10 AND b > 1 and c>123; + drop view v2; drop function f1; -drop table t1; +drop table t1, t4; --echo # End of 10.2 tests --echo # From ce1c957ab1021aabef4adbb22d1b7a155e4232ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 1 Jul 2021 10:04:47 +0300 Subject: [PATCH 218/251] Speed up the test innodb.lock_insert_into_empty Let us use innodb_lock_wait_timeout=0 for an immediate timeout. Also, do not override the timeout in the default connection, so that further tests will use the default setting. --- .../suite/innodb/r/lock_insert_into_empty.result | 13 ++++++++----- .../suite/innodb/t/lock_insert_into_empty.test | 13 ++++++++----- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/mysql-test/suite/innodb/r/lock_insert_into_empty.result b/mysql-test/suite/innodb/r/lock_insert_into_empty.result index b5e7ecf6311..c1dea2fc9af 100644 --- a/mysql-test/suite/innodb/r/lock_insert_into_empty.result +++ b/mysql-test/suite/innodb/r/lock_insert_into_empty.result @@ -5,17 +5,20 @@ BEGIN; DELETE FROM t1; INSERT INTO t2 VALUES(1),(1); ERROR 23000: Duplicate entry '1' for key 'PRIMARY' -connect con1,localhost,root,,; BEGIN; SELECT * FROM t2 LOCK IN SHARE MODE; a -connection default; -SET innodb_lock_wait_timeout=1; +connect con1,localhost,root,,; +SET innodb_lock_wait_timeout=0; INSERT INTO t2 VALUES(2); ERROR HY000: Lock wait timeout exceeded; try restarting transaction -disconnect con1; +connection default; +ROLLBACK; +connection con1; INSERT INTO t2 VALUES(3); COMMIT; +disconnect con1; +connection default; SELECT * FROM t1; a SELECT * FROM t2; @@ -45,7 +48,7 @@ INSERT INTO t1 SET k=1; START TRANSACTION; INSERT INTO t1 SET k=2; connect con1,localhost,root,,test; -SET innodb_lock_wait_timeout= 1; +SET innodb_lock_wait_timeout=0; CREATE TABLE t2 (pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=InnoDB AS SELECT k FROM t1; ERROR HY000: Lock wait timeout exceeded; try restarting transaction diff --git a/mysql-test/suite/innodb/t/lock_insert_into_empty.test b/mysql-test/suite/innodb/t/lock_insert_into_empty.test index cc2b169a52e..91d2bcdd3ba 100644 --- a/mysql-test/suite/innodb/t/lock_insert_into_empty.test +++ b/mysql-test/suite/innodb/t/lock_insert_into_empty.test @@ -9,17 +9,20 @@ DELETE FROM t1; --error ER_DUP_ENTRY INSERT INTO t2 VALUES(1),(1); -connect (con1,localhost,root,,); BEGIN; SELECT * FROM t2 LOCK IN SHARE MODE; -connection default; -SET innodb_lock_wait_timeout=1; +connect (con1,localhost,root,,); +SET innodb_lock_wait_timeout=0; --error ER_LOCK_WAIT_TIMEOUT INSERT INTO t2 VALUES(2); -disconnect con1; +connection default; +ROLLBACK; +connection con1; INSERT INTO t2 VALUES(3); COMMIT; +disconnect con1; +connection default; SELECT * FROM t1; SELECT * FROM t2; @@ -50,7 +53,7 @@ START TRANSACTION; INSERT INTO t1 SET k=2; --connect (con1,localhost,root,,test) -SET innodb_lock_wait_timeout= 1; +SET innodb_lock_wait_timeout=0; --error ER_LOCK_WAIT_TIMEOUT CREATE TABLE t2 (pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=InnoDB AS SELECT k FROM t1; From 8c5c3a4594101d46f431b0e5eef343ed1fd0ce38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 1 Jul 2021 10:31:08 +0300 Subject: [PATCH 219/251] MDEV-26067 innodb_lock_wait_timeout values above 100,000,000 are useless The practical maximum value of the parameter innodb_lock_wait_timeout is 100,000,000. Any value larger than that specifies an infinite timeout. Therefore, we should make 100,000,000 the maximum value of the parameter. --- .../r/innodb_lock_wait_timeout_basic.result | 28 +++++++++++-------- .../sys_vars/r/sysvars_innodb,32bit.rdiff | 9 ------ .../suite/sys_vars/r/sysvars_innodb.result | 6 ++-- mysql-test/suite/versioning/r/update.result | 2 +- mysql-test/suite/versioning/t/update.test | 2 +- storage/innobase/handler/ha_innodb.cc | 8 +++--- storage/innobase/include/ha_prototypes.h | 2 +- 7 files changed, 26 insertions(+), 31 deletions(-) diff --git a/mysql-test/suite/sys_vars/r/innodb_lock_wait_timeout_basic.result b/mysql-test/suite/sys_vars/r/innodb_lock_wait_timeout_basic.result index 3218c096c2b..fc60f89d72f 100644 --- a/mysql-test/suite/sys_vars/r/innodb_lock_wait_timeout_basic.result +++ b/mysql-test/suite/sys_vars/r/innodb_lock_wait_timeout_basic.result @@ -74,9 +74,11 @@ SELECT @@global.innodb_lock_wait_timeout; @@global.innodb_lock_wait_timeout 1024 SET @@global.innodb_lock_wait_timeout=1073741824; +Warnings: +Warning 1292 Truncated incorrect innodb_lock_wait_timeout value: '1073741824' SELECT @@global.innodb_lock_wait_timeout; @@global.innodb_lock_wait_timeout -1073741824 +100000000 SET @@session.innodb_lock_wait_timeout=1; SELECT @@session.innodb_lock_wait_timeout; @@session.innodb_lock_wait_timeout @@ -86,14 +88,16 @@ SELECT @@session.innodb_lock_wait_timeout; @@session.innodb_lock_wait_timeout 1024 SET @@session.innodb_lock_wait_timeout=1073741824; +Warnings: +Warning 1292 Truncated incorrect innodb_lock_wait_timeout value: '1073741824' SELECT @@session.innodb_lock_wait_timeout; @@session.innodb_lock_wait_timeout -1073741824 +100000000 SET @@global.innodb_lock_wait_timeout="t"; ERROR 42000: Incorrect argument type to variable 'innodb_lock_wait_timeout' SELECT @@global.innodb_lock_wait_timeout; @@global.innodb_lock_wait_timeout -1073741824 +100000000 SET @@global.innodb_lock_wait_timeout=-1024; Warnings: Warning 1292 Truncated incorrect innodb_lock_wait_timeout value: '-1024' @@ -105,27 +109,27 @@ Warnings: Warning 1292 Truncated incorrect innodb_lock_wait_timeout value: '1073741825' SELECT @@global.innodb_lock_wait_timeout; @@global.innodb_lock_wait_timeout -1073741824 +100000000 SET @@global.innodb_lock_wait_timeout=" "; ERROR 42000: Incorrect argument type to variable 'innodb_lock_wait_timeout' SELECT @@global.innodb_lock_wait_timeout; @@global.innodb_lock_wait_timeout -1073741824 +100000000 SET @@global.innodb_lock_wait_timeout=' '; ERROR 42000: Incorrect argument type to variable 'innodb_lock_wait_timeout' SELECT @@global.innodb_lock_wait_timeout; @@global.innodb_lock_wait_timeout -1073741824 +100000000 SET @@global.innodb_lock_wait_timeout=1.1; ERROR 42000: Incorrect argument type to variable 'innodb_lock_wait_timeout' SELECT @@global.innodb_lock_wait_timeout; @@global.innodb_lock_wait_timeout -1073741824 +100000000 SET @@session.innodb_lock_wait_timeout="T"; ERROR 42000: Incorrect argument type to variable 'innodb_lock_wait_timeout' SELECT @@session.innodb_lock_wait_timeout; @@session.innodb_lock_wait_timeout -1073741824 +100000000 SET @@session.innodb_lock_wait_timeout=-1024; Warnings: Warning 1292 Truncated incorrect innodb_lock_wait_timeout value: '-1024' @@ -137,22 +141,22 @@ Warnings: Warning 1292 Truncated incorrect innodb_lock_wait_timeout value: '1073999999' SELECT @@session.innodb_lock_wait_timeout; @@session.innodb_lock_wait_timeout -1073741824 +100000000 SET @@session.innodb_lock_wait_timeout=' '; ERROR 42000: Incorrect argument type to variable 'innodb_lock_wait_timeout' SELECT @@session.innodb_lock_wait_timeout; @@session.innodb_lock_wait_timeout -1073741824 +100000000 SET @@session.innodb_lock_wait_timeout=" "; ERROR 42000: Incorrect argument type to variable 'innodb_lock_wait_timeout' SELECT @@session.innodb_lock_wait_timeout; @@session.innodb_lock_wait_timeout -1073741824 +100000000 SET @@session.innodb_lock_wait_timeout=1.1; ERROR 42000: Incorrect argument type to variable 'innodb_lock_wait_timeout' SELECT @@session.innodb_lock_wait_timeout; @@session.innodb_lock_wait_timeout -1073741824 +100000000 SET @@global.innodb_lock_wait_timeout = @start_global_value; SELECT @@global.innodb_lock_wait_timeout; @@global.innodb_lock_wait_timeout diff --git a/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit.rdiff b/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit.rdiff index 23f82f513e3..b0f0b46ded7 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit.rdiff +++ b/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit.rdiff @@ -207,15 +207,6 @@ NUMERIC_BLOCK_SIZE 0 ENUM_VALUE_LIST NULL READ_ONLY NO -@@ -1021,7 +1021,7 @@ - SESSION_VALUE 50 - DEFAULT_VALUE 50 - VARIABLE_SCOPE SESSION --VARIABLE_TYPE BIGINT UNSIGNED -+VARIABLE_TYPE INT UNSIGNED - VARIABLE_COMMENT Timeout in seconds an InnoDB transaction may wait for a lock before being rolled back. Values above 100000000 disable the timeout. - NUMERIC_MIN_VALUE 0 - NUMERIC_MAX_VALUE 1073741824 @@ -1033,10 +1033,10 @@ SESSION_VALUE NULL DEFAULT_VALUE 16777216 diff --git a/mysql-test/suite/sys_vars/r/sysvars_innodb.result b/mysql-test/suite/sys_vars/r/sysvars_innodb.result index bba60290863..33df36dfb3b 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_innodb.result +++ b/mysql-test/suite/sys_vars/r/sysvars_innodb.result @@ -1009,10 +1009,10 @@ VARIABLE_NAME INNODB_LOCK_WAIT_TIMEOUT SESSION_VALUE 50 DEFAULT_VALUE 50 VARIABLE_SCOPE SESSION -VARIABLE_TYPE BIGINT UNSIGNED -VARIABLE_COMMENT Timeout in seconds an InnoDB transaction may wait for a lock before being rolled back. Values above 100000000 disable the timeout. +VARIABLE_TYPE INT UNSIGNED +VARIABLE_COMMENT Timeout in seconds an InnoDB transaction may wait for a lock before being rolled back. The value 100000000 is infinite timeout. NUMERIC_MIN_VALUE 0 -NUMERIC_MAX_VALUE 1073741824 +NUMERIC_MAX_VALUE 100000000 NUMERIC_BLOCK_SIZE 0 ENUM_VALUE_LIST NULL READ_ONLY NO diff --git a/mysql-test/suite/versioning/r/update.result b/mysql-test/suite/versioning/r/update.result index da893432749..9e5e28b09a1 100644 --- a/mysql-test/suite/versioning/r/update.result +++ b/mysql-test/suite/versioning/r/update.result @@ -270,7 +270,7 @@ replace t1 values (1,2),(1,3),(2,4); # MDEV-14829 Assertion `0' failed in Protocol::end_statement upon concurrent UPDATE # set @old_lock_wait_timeout= @@innodb_lock_wait_timeout; -set @@innodb_lock_wait_timeout= 1073741824; +set @@innodb_lock_wait_timeout= 100000000; create or replace table t1 (pk int, a char(3), b char(3), primary key(pk)) engine=innodb with system versioning; insert into t1 (pk) values (1); diff --git a/mysql-test/suite/versioning/t/update.test b/mysql-test/suite/versioning/t/update.test index 47a56a71bd3..a3252c9f8e3 100644 --- a/mysql-test/suite/versioning/t/update.test +++ b/mysql-test/suite/versioning/t/update.test @@ -173,7 +173,7 @@ replace t1 values (1,2),(1,3),(2,4); --echo # MDEV-14829 Assertion `0' failed in Protocol::end_statement upon concurrent UPDATE --echo # set @old_lock_wait_timeout= @@innodb_lock_wait_timeout; -set @@innodb_lock_wait_timeout= 1073741824; +set @@innodb_lock_wait_timeout= 100000000; create or replace table t1 (pk int, a char(3), b char(3), primary key(pk)) engine=innodb with system versioning; diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 8b97bf07c33..1acb8ef5e20 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -869,9 +869,9 @@ static MYSQL_THDVAR_BOOL(ft_enable_stopword, PLUGIN_VAR_OPCMDARG, NULL, NULL, /* default */ TRUE); -static MYSQL_THDVAR_ULONG(lock_wait_timeout, PLUGIN_VAR_RQCMDARG, - "Timeout in seconds an InnoDB transaction may wait for a lock before being rolled back. Values above 100000000 disable the timeout.", - NULL, NULL, 50, 0, 1024 * 1024 * 1024, 0); +static MYSQL_THDVAR_UINT(lock_wait_timeout, PLUGIN_VAR_RQCMDARG, + "Timeout in seconds an InnoDB transaction may wait for a lock before being rolled back. The value 100000000 is infinite timeout.", + NULL, NULL, 50, 0, 100000000, 0); static MYSQL_THDVAR_STR(ft_user_stopword_table, PLUGIN_VAR_OPCMDARG|PLUGIN_VAR_MEMALLOC, @@ -1857,7 +1857,7 @@ thd_has_edited_nontrans_tables( /******************************************************************//** Returns the lock wait timeout for the current connection. @return the lock wait timeout, in seconds */ -ulong +uint thd_lock_wait_timeout( /*==================*/ THD* thd) /*!< in: thread handle, or NULL to query diff --git a/storage/innobase/include/ha_prototypes.h b/storage/innobase/include/ha_prototypes.h index b65a874177c..9a2786f9e69 100644 --- a/storage/innobase/include/ha_prototypes.h +++ b/storage/innobase/include/ha_prototypes.h @@ -242,7 +242,7 @@ const char *thd_innodb_tmpdir(THD *thd); /******************************************************************//** Returns the lock wait timeout for the current connection. @return the lock wait timeout, in seconds */ -ulong +uint thd_lock_wait_timeout( /*==================*/ THD* thd); /*!< in: thread handle, or NULL to query From 161e4bfafd261aa5204827086637d4d7dcceb949 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 1 Jul 2021 10:35:32 +0300 Subject: [PATCH 220/251] MDEV-25902 Unexpected ER_LOCK_WAIT_TIMEOUT and result trans_rollback_to_savepoint(): Only release metadata locks (MDL) if the storage engines agree, after the changes were already rolled back. Ever since commit 3792693f311a90cf195ec6d2f9b3762255a249c7 and mysql/mysql-server@55ceedbc3feb911505dcba6cee8080d55ce86dda we used to cheat here and always release MDL if the binlog is disabled. MDL are supposed to prevent race conditions between DML and DDL also when no replication is in use. MDL are supposed to be a superset of InnoDB table locks: InnoDB table lock may only exist if the thread also holds MDL on the table name. In the included test case, ROLLBACK TO SAVEPOINT would wrongly release the MDL on both tables and let ALTER TABLE proceed, even though the DML transaction is actually holding locks on the table. Until commit 1bd681c8b3c5213ce1f7976940a7dc38b48a0d39 (MDEV-25506) InnoDB worked around the locking violation in a blatantly non-ACID way: If locks exist on a table that is being dropped (in this case, actually a partition of a table that is being rebuilt by ALTER TABLE), InnoDB would move the table (or partition) into a queue, to be dropped after the locks and references had been released. The scenario of commit 3792693f311a90cf195ec6d2f9b3762255a249c7 is unaffected by this fix, because mariadb-dump (a.k.a. mysqldump) would use non-locking reads, and the transaction would not be holding any InnoDB locks during the execution of ROLLBACK TO SAVEPOINT. MVCC reads inside InnoDB are only covered by MDL and page latches, not by any table or record locks. FIXME: It would be nice if storage engines were specifically asked which MDL can be released, instead of only offering a choice between all or nothing. InnoDB should be able to release any locks for tables that are no longer in trx_t::mod_tables, except if another transaction had converted some implicit record locks to explicit ones, before the ROLLBACK TO SAVEPOINT had been completed. Reviewed by: Sergei Golubchik --- .../suite/innodb/r/alter_partitioned.result | 30 ++++++++++++++ .../suite/innodb/t/alter_partitioned.test | 33 ++++++++++++++++ sql/transaction.cc | 39 +++++-------------- 3 files changed, 73 insertions(+), 29 deletions(-) diff --git a/mysql-test/suite/innodb/r/alter_partitioned.result b/mysql-test/suite/innodb/r/alter_partitioned.result index cbdfab36499..ad6dd8b3e8c 100644 --- a/mysql-test/suite/innodb/r/alter_partitioned.result +++ b/mysql-test/suite/innodb/r/alter_partitioned.result @@ -16,3 +16,33 @@ CREATE TABLE t1 (id INT PRIMARY KEY, a INT, va INT AS (a) VIRTUAL) ENGINE=InnoDB PARTITION BY HASH(id) PARTITIONS 2; ALTER TABLE t1 ADD b INT, ALGORITHM=INSTANT; DROP TABLE t1; +# +# MDEV-25902 Unexpected ER_LOCK_WAIT_TIMEOUT and result, +# assertion failure err != DB_DUPLICATE_KEY +CREATE TABLE t1 (pk INT PRIMARY KEY) ENGINE=InnoDB; +CREATE TABLE t2 (pk INT PRIMARY KEY) ENGINE=InnoDB; +connect con1,localhost,root,,test; +START TRANSACTION; +INSERT INTO t2 (pk) VALUES (1); +SAVEPOINT sp; +INSERT INTO t1 (pk) VALUES (1); +ROLLBACK TO SAVEPOINT sp; +connection default; +SET lock_wait_timeout=0; +SET innodb_lock_wait_timeout=0; +ALTER TABLE t1 PARTITION BY HASH(pk); +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `pk` int(11) NOT NULL, + PRIMARY KEY (`pk`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +connection con1; +COMMIT; +connection default; +ALTER TABLE t2 PARTITION BY HASH(pk); +disconnect con1; +connection default; +DROP TABLE t1, t2; +# End of 10.6 tests diff --git a/mysql-test/suite/innodb/t/alter_partitioned.test b/mysql-test/suite/innodb/t/alter_partitioned.test index e443f92bc8c..056791c6a0c 100644 --- a/mysql-test/suite/innodb/t/alter_partitioned.test +++ b/mysql-test/suite/innodb/t/alter_partitioned.test @@ -22,3 +22,36 @@ CREATE TABLE t1 (id INT PRIMARY KEY, a INT, va INT AS (a) VIRTUAL) ENGINE=InnoDB PARTITION BY HASH(id) PARTITIONS 2; ALTER TABLE t1 ADD b INT, ALGORITHM=INSTANT; DROP TABLE t1; + +--echo # +--echo # MDEV-25902 Unexpected ER_LOCK_WAIT_TIMEOUT and result, +--echo # assertion failure err != DB_DUPLICATE_KEY + +CREATE TABLE t1 (pk INT PRIMARY KEY) ENGINE=InnoDB; +CREATE TABLE t2 (pk INT PRIMARY KEY) ENGINE=InnoDB; + +--connect (con1,localhost,root,,test) + +START TRANSACTION; +INSERT INTO t2 (pk) VALUES (1); +SAVEPOINT sp; +INSERT INTO t1 (pk) VALUES (1); +ROLLBACK TO SAVEPOINT sp; + +--connection default +SET lock_wait_timeout=0; +SET innodb_lock_wait_timeout=0; +--error ER_LOCK_WAIT_TIMEOUT +ALTER TABLE t1 PARTITION BY HASH(pk); + +SHOW CREATE TABLE t1; +--connection con1 +COMMIT; +--connection default +ALTER TABLE t2 PARTITION BY HASH(pk); +# Cleanup +--disconnect con1 +--connection default +DROP TABLE t1, t2; + +--echo # End of 10.6 tests diff --git a/sql/transaction.cc b/sql/transaction.cc index 8bd58419ec9..958abebfc47 100644 --- a/sql/transaction.cc +++ b/sql/transaction.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. - Copyright (c) 2009, 2020, MariaDB Corporation. + Copyright (c) 2009, 2021, 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 @@ -667,33 +667,6 @@ bool trans_rollback_to_savepoint(THD *thd, LEX_CSTRING name) if (thd->transaction->xid_state.check_has_uncommitted_xa()) DBUG_RETURN(TRUE); - /** - Checking whether it is safe to release metadata locks acquired after - savepoint, if rollback to savepoint is successful. - - Whether it is safe to release MDL after rollback to savepoint depends - on storage engines participating in transaction: - - - InnoDB doesn't release any row-locks on rollback to savepoint so it - is probably a bad idea to release MDL as well. - - Binary log implementation in some cases (e.g when non-transactional - tables involved) may choose not to remove events added after savepoint - from transactional cache, but instead will write them to binary - log accompanied with ROLLBACK TO SAVEPOINT statement. Since the real - write happens at the end of transaction releasing MDL on tables - mentioned in these events (i.e. acquired after savepoint and before - rollback ot it) can break replication, as concurrent DROP TABLES - statements will be able to drop these tables before events will get - into binary log, - - For backward-compatibility reasons we always release MDL if binary - logging is off. - */ - bool mdl_can_safely_rollback_to_savepoint= - (!((WSREP_EMULATE_BINLOG_NNULL(thd) || mysql_bin_log.is_open()) - && thd->variables.sql_log_bin) || - ha_rollback_to_savepoint_can_release_mdl(thd)); - if (ha_rollback_to_savepoint(thd, sv)) res= TRUE; else if (((thd->variables.option_bits & OPTION_KEEP_LOG) || @@ -705,7 +678,15 @@ bool trans_rollback_to_savepoint(THD *thd, LEX_CSTRING name) thd->transaction->savepoints= sv; - if (!res && mdl_can_safely_rollback_to_savepoint) + if (res) + /* An error occurred during rollback; we cannot release any MDL */; + else if (thd->variables.sql_log_bin && + (WSREP_EMULATE_BINLOG_NNULL(thd) || mysql_bin_log.is_open())) + /* In some cases (such as with non-transactional tables) we may + choose to preserve events that were added after the SAVEPOINT, + delimiting them by SAVEPOINT and ROLLBACK TO SAVEPOINT statements. + Prematurely releasing MDL on such objects would break replication. */; + else if (ha_rollback_to_savepoint_can_release_mdl(thd)) thd->mdl_context.rollback_to_savepoint(sv->mdl_savepoint); DBUG_RETURN(MY_TEST(res)); From 83234719f11b45d1d826f84cc7c758d939cd636d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 1 Jul 2021 16:37:01 +0300 Subject: [PATCH 221/251] MDEV-24671 fixup: Fix an off-by-one error In commit e71e6133535da8d5eab86e504f0b116a03680780 we accidentally made innodb_lock_wait_timeout=100000000 a "literal" value, not the smallest special value that would mean "infinite" timeout. --- storage/innobase/lock/lock0lock.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc index e455c6ac4af..017ea939f08 100644 --- a/storage/innobase/lock/lock0lock.cc +++ b/storage/innobase/lock/lock0lock.cc @@ -1701,7 +1701,7 @@ dberr_t lock_wait(que_thr_t *thr) /* InnoDB system transactions may use the global value of innodb_lock_wait_timeout, because trx->mysql_thd == NULL. */ const ulong innodb_lock_wait_timeout= trx_lock_wait_timeout_get(trx); - const bool no_timeout= innodb_lock_wait_timeout > 100000000; + const bool no_timeout= innodb_lock_wait_timeout >= 100000000; const my_hrtime_t suspend_time= my_hrtime_coarse(); ut_ad(!trx->dict_operation_lock_mode || trx->dict_operation_lock_mode == RW_S_LATCH); From 0a67b15a9d3348d10f6df0caae6f2f973295a43a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 1 Jul 2021 16:38:24 +0300 Subject: [PATCH 222/251] Cleanup: Remove pointer indirection for trx_t::xid The trx_t::xid is always allocated, so we might as well allocate it directly in the trx_t object to improve the locality of reference. --- storage/innobase/handler/ha_innodb.cc | 15 ++++++++------- storage/innobase/include/trx0trx.h | 2 +- storage/innobase/trx/trx0purge.cc | 4 ++-- storage/innobase/trx/trx0trx.cc | 17 +++++++---------- storage/innobase/trx/trx0undo.cc | 6 +++--- 5 files changed, 21 insertions(+), 23 deletions(-) diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 1acb8ef5e20..87c59e758b4 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -4357,7 +4357,7 @@ innobase_commit_ordered_2( /* If the transaction is not run in 2pc, we must assign wsrep XID here in order to get it written in rollback segment. */ if (trx->is_wsrep()) { - thd_get_xid(thd, (MYSQL_XID*)trx->xid); + thd_get_xid(thd, &reinterpret_cast(trx->xid)); } #endif /* WITH_WSREP */ @@ -4552,8 +4552,9 @@ innobase_rollback( trx is being rolled back due to BF abort, clear XID in order to avoid writing it to rollback segment out of order. The XID will be reassigned when the transaction is replayed. */ - if (trx->state != TRX_STATE_NOT_STARTED && wsrep_is_wsrep_xid(trx->xid)) { - trx->xid->null(); + if (trx->state != TRX_STATE_NOT_STARTED + && wsrep_is_wsrep_xid(&trx->xid)) { + trx->xid.null(); } #endif /* WITH_WSREP */ if (rollback_trx @@ -16683,7 +16684,7 @@ innobase_xa_prepare( DBUG_ASSERT(hton == innodb_hton_ptr); - thd_get_xid(thd, (MYSQL_XID*) trx->xid); + thd_get_xid(thd, &reinterpret_cast(trx->xid)); if (!trx_is_registered_for_2pc(trx) && trx_is_started(trx)) { @@ -16815,8 +16816,8 @@ int innobase_rollback_by_xid(handlerton* hton, XID* xid) /* If a wsrep transaction is being rolled back during the recovery, we must clear the xid in order to avoid writing serialisation history for rolled back transaction. */ - if (wsrep_is_wsrep_xid(trx->xid)) { - trx->xid->null(); + if (wsrep_is_wsrep_xid(&trx->xid)) { + trx->xid.null(); } #endif /* WITH_WSREP */ int ret = innobase_rollback_trx(trx); @@ -18312,7 +18313,7 @@ void lock_wait_wsrep_kill(trx_t *bf_trx, ulong thd_id, trx_id_t trx_id) default: break; case TRX_STATE_PREPARED: - if (!wsrep_is_wsrep_xid(vtrx->xid)) + if (!wsrep_is_wsrep_xid(&vtrx->xid)) break; /* fall through */ case TRX_STATE_ACTIVE: diff --git a/storage/innobase/include/trx0trx.h b/storage/innobase/include/trx0trx.h index 1ed256eed23..b06c37e734e 100644 --- a/storage/innobase/include/trx0trx.h +++ b/storage/innobase/include/trx0trx.h @@ -859,7 +859,7 @@ public: const char* start_file; /*!< Filename where it was started */ #endif /* UNIV_DEBUG */ - XID* xid; /*!< X/Open XA transaction + XID xid; /*!< X/Open XA transaction identification to identify a transaction branch */ trx_mod_tables_t mod_tables; /*!< List of tables that were modified diff --git a/storage/innobase/trx/trx0purge.cc b/storage/innobase/trx/trx0purge.cc index 2584e534fbc..87284a5d90a 100644 --- a/storage/innobase/trx/trx0purge.cc +++ b/storage/innobase/trx/trx0purge.cc @@ -284,8 +284,8 @@ trx_purge_add_undo_to_history(const trx_t* trx, trx_undo_t*& undo, mtr_t* mtr) && srv_fast_shutdown)); #ifdef WITH_WSREP - if (wsrep_is_wsrep_xid(trx->xid)) { - trx_rseg_update_wsrep_checkpoint(rseg_header, trx->xid, mtr); + if (wsrep_is_wsrep_xid(&trx->xid)) { + trx_rseg_update_wsrep_checkpoint(rseg_header, &trx->xid, mtr); } #endif diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc index dc7a719d5b0..b9e95b37d2f 100644 --- a/storage/innobase/trx/trx0trx.cc +++ b/storage/innobase/trx/trx0trx.cc @@ -178,8 +178,6 @@ struct TrxFactory { trx->dict_operation_lock_mode = 0; - trx->xid = UT_NEW_NOKEY(xid_t()); - trx->detailed_error = reinterpret_cast( ut_zalloc_nokey(MAX_DETAILED_ERROR_LEN)); @@ -231,7 +229,6 @@ struct TrxFactory { ut_a(UT_LIST_GET_LEN(trx->lock.trx_locks) == 0); ut_ad(UT_LIST_GET_LEN(trx->lock.evicted_tables) == 0); - UT_DELETE(trx->xid); ut_free(trx->detailed_error); trx->mutex_destroy(); @@ -675,7 +672,7 @@ static void trx_resurrect(trx_undo_t *undo, trx_rseg_t *rseg, this trx_ref_count w/o mutex protection. */ trx->rsegs.m_redo.rseg->acquire(); - *trx->xid= undo->xid; + trx->xid= undo->xid; trx->id= undo->trx_id; trx->is_recovered= true; trx->start_time= start_time; @@ -913,7 +910,7 @@ trx_start_low( } #ifdef WITH_WSREP - trx->xid->null(); + trx->xid.null(); #endif /* WITH_WSREP */ ut_a(ib_vector_is_empty(trx->autoinc_locks)); @@ -1347,7 +1344,7 @@ inline void trx_t::commit_in_memory(const mtr_t *mtr) serialize all commits and prevent a group of transactions from gathering. */ - commit_lsn= undo_no || !xid->is_null() ? mtr->commit_lsn() : 0; + commit_lsn= undo_no || !xid.is_null() ? mtr->commit_lsn() : 0; if (!commit_lsn) /* Nothing to be done. */; else if (flush_log_later) @@ -1922,7 +1919,7 @@ static my_bool trx_recover_for_mysql_callback(rw_trx_hash_element_t *element, << " in prepared state after recovery"; ib::info() << "Transaction contains changes to " << trx->undo_no << " rows"; - xid= *trx->xid; + xid= trx->xid; } } } @@ -1997,16 +1994,16 @@ static my_bool trx_get_trx_by_xid_callback(rw_trx_hash_element_t *element, if (trx->is_recovered && (trx_state_eq(trx, TRX_STATE_PREPARED) || trx_state_eq(trx, TRX_STATE_PREPARED_RECOVERED)) && - arg->xid->eq(reinterpret_cast(trx->xid))) + arg->xid->eq(&trx->xid)) { #ifdef WITH_WSREP /* The commit of a prepared recovered Galera transaction needs a valid trx->xid for invoking trx_sys_update_wsrep_checkpoint(). */ - if (!wsrep_is_wsrep_xid(trx->xid)) + if (!wsrep_is_wsrep_xid(&trx->xid)) #endif /* WITH_WSREP */ /* Invalidate the XID, so that subsequent calls will not find it. */ - trx->xid->null(); + trx->xid.null(); arg->trx= trx; found= 1; } diff --git a/storage/innobase/trx/trx0undo.cc b/storage/innobase/trx/trx0undo.cc index 8b84cf36258..da3f6b592fa 100644 --- a/storage/innobase/trx/trx0undo.cc +++ b/storage/innobase/trx/trx0undo.cc @@ -1051,7 +1051,7 @@ trx_undo_create(trx_t* trx, trx_rseg_t* rseg, trx_undo_t** undo, uint16_t offset = trx_undo_header_create(block, trx->id, mtr); - *undo = trx_undo_mem_create(rseg, id, trx->id, trx->xid, + *undo = trx_undo_mem_create(rseg, id, trx->id, &trx->xid, block->page.id().page_no(), offset); if (*undo == NULL) { *err = DB_OUT_OF_MEMORY; @@ -1109,7 +1109,7 @@ trx_undo_reuse_cached(trx_t* trx, trx_rseg_t* rseg, trx_undo_t** pundo, uint16_t offset = trx_undo_header_create(block, trx->id, mtr); - trx_undo_mem_init_for_reuse(undo, trx->id, trx->xid, offset); + trx_undo_mem_init_for_reuse(undo, trx->id, &trx->xid, offset); if (rseg != trx->rsegs.m_redo.rseg) { return block; @@ -1277,7 +1277,7 @@ void trx_undo_set_state_at_prepare(trx_t *trx, trx_undo_t *undo, bool rollback, /*------------------------------*/ ut_ad(undo->state == TRX_UNDO_ACTIVE); undo->state = TRX_UNDO_PREPARED; - undo->xid = *trx->xid; + undo->xid = trx->xid; /*------------------------------*/ mtr->write<2>(*block, TRX_UNDO_SEG_HDR + TRX_UNDO_STATE + block->frame, From ed6b23074481668af5d09179d870a06443e08386 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 1 Jul 2021 17:51:55 +0300 Subject: [PATCH 223/251] MDEV-25919 preparation: Remove trx_t::internal With commit 1bd681c8b3c5213ce1f7976940a7dc38b48a0d39 (MDEV-25506) it no longer is necessary to run DDL and DML operations in separate transactions. Let us remove the flag trx_t::internal. Dictionary transactions will be distinguished by trx_t::dict_operation. --- storage/innobase/dict/dict0stats.cc | 12 ++----- storage/innobase/fts/fts0fts.cc | 20 ++++++------ storage/innobase/handler/ha_innodb.cc | 6 ++-- storage/innobase/include/trx0trx.h | 38 ++++------------------ storage/innobase/row/row0ins.cc | 2 +- storage/innobase/trx/trx0purge.cc | 3 +- storage/innobase/trx/trx0trx.cc | 46 ++++++--------------------- 7 files changed, 33 insertions(+), 94 deletions(-) diff --git a/storage/innobase/dict/dict0stats.cc b/storage/innobase/dict/dict0stats.cc index d8ae7106cdc..eb2f06ab31e 100644 --- a/storage/innobase/dict/dict0stats.cc +++ b/storage/innobase/dict/dict0stats.cc @@ -542,10 +542,7 @@ dberr_t dict_stats_exec_sql(pars_info_t *pinfo, const char* sql, trx_t *trx) return que_eval_sql(pinfo, sql, FALSE, trx); trx= trx_create(); - if (srv_read_only_mode) - trx_start_internal_read_only(trx); - else - trx_start_internal(trx); + trx_start_internal(trx); trx->dict_operation_lock_mode= RW_X_LATCH; dberr_t err= que_eval_sql(pinfo, sql, FALSE, trx); @@ -2589,7 +2586,6 @@ dict_stats_save_index_stat( char db_utf8[MAX_DB_UTF8_LEN]; char table_utf8[MAX_TABLE_UTF8_LEN]; - ut_ad(!trx || trx->internal || trx->mysql_thd); ut_d(dict_sys.assert_locked()); dict_fs2utf8(index->table->name.m_name, db_utf8, sizeof(db_utf8), @@ -3247,11 +3243,7 @@ dict_stats_fetch_from_ps( trx->isolation_level = TRX_ISO_READ_UNCOMMITTED; - if (srv_read_only_mode) { - trx_start_internal_read_only(trx); - } else { - trx_start_internal(trx); - } + trx_start_internal(trx); dict_fs2utf8(table->name.m_name, db_utf8, sizeof(db_utf8), table_utf8, sizeof(table_utf8)); diff --git a/storage/innobase/fts/fts0fts.cc b/storage/innobase/fts/fts0fts.cc index be9a4cc25c3..21a3567f33a 100644 --- a/storage/innobase/fts/fts0fts.cc +++ b/storage/innobase/fts/fts0fts.cc @@ -2550,6 +2550,10 @@ fts_cmp_set_sync_doc_id( to the one stored in CONFIG table */ { + if (srv_read_only_mode) { + return DB_READ_ONLY; + } + trx_t* trx; pars_info_t* info; dberr_t error; @@ -2566,11 +2570,7 @@ retry: fts_table.table = table; trx = trx_create(); - if (srv_read_only_mode) { - trx_start_internal_read_only(trx); - } else { - trx_start_internal(trx); - } + trx_start_internal(trx); trx->op_info = "update the next FTS document id"; @@ -5788,11 +5788,11 @@ fts_load_stopword( if (!trx) { trx = trx_create(); - if (srv_read_only_mode) { - trx_start_internal_read_only(trx); - } else { - trx_start_internal(trx); - } +#ifdef UNIV_DEBUG + trx->start_line = __LINE__; + trx->start_file = __FILE__; +#endif + trx_start_internal_low(trx, !high_level_read_only); trx->op_info = "upload FTS stopword"; new_trx = TRUE; } diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 87c59e758b4..63a679c0317 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -11363,8 +11363,9 @@ innobase_fts_load_stopword( mysql_mutex_unlock(&LOCK_global_system_variables); } - return fts_load_stopword(table, trx, stopword_table, - THDVAR(thd, ft_enable_stopword), false); + return !high_level_read_only && + fts_load_stopword(table, trx, stopword_table, + THDVAR(thd, ft_enable_stopword), false); } /** Parse the table name into normal name and remote path if needed. @@ -13387,7 +13388,6 @@ int ha_innobase::delete_table(const char *name) ut_ad(trx->will_lock); ut_ad(trx->state == TRX_STATE_ACTIVE); trx->dict_operation= true; - trx->internal= true; } else { diff --git a/storage/innobase/include/trx0trx.h b/storage/innobase/include/trx0trx.h index b06c37e734e..96289f2aa39 100644 --- a/storage/innobase/include/trx0trx.h +++ b/storage/innobase/include/trx0trx.h @@ -95,18 +95,11 @@ trx_start_if_not_started_low( trx_t* trx, /*!< in/out: transaction */ bool read_write); /*!< in: true if read write transaction */ -/*************************************************************//** -Starts a transaction for internal processing. */ -void -trx_start_internal_low( -/*===================*/ - trx_t* trx); /*!< in/out: transaction */ - -/** Starts a read-only transaction for internal processing. -@param[in,out] trx transaction to be started */ -void -trx_start_internal_read_only_low( - trx_t* trx); +/** +Start a transaction for internal processing. +@param trx transaction +@param read_write whether writes may be performed */ +void trx_start_internal_low(trx_t *trx, bool read_write); #ifdef UNIV_DEBUG #define trx_start_if_not_started_xa(t, rw) \ @@ -127,24 +120,13 @@ trx_start_internal_read_only_low( do { \ (t)->start_line = __LINE__; \ (t)->start_file = __FILE__; \ - trx_start_internal_low((t)); \ - } while (false) - -#define trx_start_internal_read_only(t) \ - do { \ - (t)->start_line = __LINE__; \ - (t)->start_file = __FILE__; \ - trx_start_internal_read_only_low(t); \ + trx_start_internal_low(t, true); \ } while (false) #else #define trx_start_if_not_started(t, rw) \ trx_start_if_not_started_low((t), rw) -#define trx_start_internal(t) \ - trx_start_internal_low((t)) - -#define trx_start_internal_read_only(t) \ - trx_start_internal_read_only_low(t) +#define trx_start_internal(t) trx_start_internal_low(t, true) #define trx_start_if_not_started_xa(t, rw) \ trx_start_if_not_started_xa_low((t), (rw)) @@ -848,12 +830,6 @@ public: count of tables being flushed. */ /*------------------------------*/ - bool internal; /*!< true if it is a system/internal - transaction background task. This - includes DDL transactions too. Such - transactions are always treated as - read-write. */ - /*------------------------------*/ #ifdef UNIV_DEBUG unsigned start_line; /*!< Track where it was started from */ const char* start_file; /*!< Filename where it was started */ diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc index 08bc40a5da2..dace6a43587 100644 --- a/storage/innobase/row/row0ins.cc +++ b/storage/innobase/row/row0ins.cc @@ -2635,7 +2635,7 @@ commit_exit: && page_is_empty(block->frame) && !entry->is_metadata() && !trx->duplicates && !trx->check_unique_secondary && !trx->check_foreigns - && !trx->dict_operation && !trx->internal + && !trx->dict_operation && block->page.id().page_no() == index->page && !index->table->skip_alter_undo && !index->table->n_rec_locks diff --git a/storage/innobase/trx/trx0purge.cc b/storage/innobase/trx/trx0purge.cc index 87284a5d90a..40fa8172e6f 100644 --- a/storage/innobase/trx/trx0purge.cc +++ b/storage/innobase/trx/trx0purge.cc @@ -280,8 +280,7 @@ trx_purge_add_undo_to_history(const trx_t* trx, trx_undo_t*& undo, mtr_t* mtr) && (srv_is_being_started || trx_rollback_is_active || srv_force_recovery >= SRV_FORCE_NO_BACKGROUND)) - || ((trx->mysql_thd || trx->internal) - && srv_fast_shutdown)); + || srv_fast_shutdown); #ifdef WITH_WSREP if (wsrep_is_wsrep_xid(&trx->xid)) { diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc index b9e95b37d2f..3ff09395d36 100644 --- a/storage/innobase/trx/trx0trx.cc +++ b/storage/innobase/trx/trx0trx.cc @@ -131,8 +131,6 @@ trx_init( trx->will_lock = false; - trx->internal = false; - trx->bulk_insert = false; ut_d(trx->start_file = 0); @@ -369,7 +367,6 @@ void trx_t::free() ut_ad(!n_mysql_tables_in_use); ut_ad(!mysql_log_file_name); ut_ad(!mysql_n_tables_locked); - ut_ad(!internal); ut_ad(!will_lock); ut_ad(error_state == DB_SUCCESS); ut_ad(magic_n == TRX_MAGIC_N); @@ -440,7 +437,6 @@ void trx_t::free() MEM_NOACCESS(&fts_trx, sizeof fts_trx); MEM_NOACCESS(&fts_next_doc_id, sizeof fts_next_doc_id); MEM_NOACCESS(&flush_tables, sizeof flush_tables); - MEM_NOACCESS(&internal, sizeof internal); #ifdef UNIV_DEBUG MEM_NOACCESS(&start_line, sizeof start_line); MEM_NOACCESS(&start_file, sizeof start_file); @@ -900,7 +896,7 @@ trx_start_low( trx->auto_commit = thd_trx_is_auto_commit(trx->mysql_thd); trx->read_only = srv_read_only_mode - || (!trx->dict_operation && !trx->internal + || (!trx->dict_operation && thd_trx_is_read_only(trx->mysql_thd)); if (!trx->auto_commit) { @@ -2090,48 +2086,24 @@ trx_start_if_not_started_low( ut_error; } -/*************************************************************//** -Starts a transaction for internal processing. */ -void -trx_start_internal_low( -/*===================*/ - trx_t* trx) /*!< in/out: transaction */ +/** +Start a transaction for internal processing. +@param trx transaction +@param read_write whether writes may be performed */ +void trx_start_internal_low(trx_t *trx, bool read_write) { - /* Ensure it is not flagged as an auto-commit-non-locking - transaction. */ - - trx->will_lock = true; - - trx->internal = true; - - trx_start_low(trx, true); -} - -/** Starts a read-only transaction for internal processing. -@param[in,out] trx transaction to be started */ -void -trx_start_internal_read_only_low( - trx_t* trx) -{ - /* Ensure it is not flagged as an auto-commit-non-locking - transaction. */ - - trx->will_lock = true; - - trx->internal = true; - - trx_start_low(trx, false); + trx->will_lock= true; + trx_start_low(trx, read_write); } /** Start a transaction for a DDL operation. @param trx transaction */ void trx_start_for_ddl_low(trx_t *trx) { - ut_a(trx->state == TRX_STATE_NOT_STARTED); /* Flag this transaction as a dictionary operation, so that the data dictionary will be locked in crash recovery. */ trx->dict_operation= true; - trx_start_internal_low(trx); + trx_start_internal_low(trx, true); } /*************************************************************//** From 315380a4d16ddb16461d906a23be341e354c30ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 1 Jul 2021 19:06:53 +0300 Subject: [PATCH 224/251] MDEV-26052 Assertion prebuilt->trx_id < table->def_trx_id failed ha_innobase::truncate(): If the operation fails, preserve also dict_table_t::def_trx_id. This fixes a regression that had been introduced in commit 1bd681c8b3c5213ce1f7976940a7dc38b48a0d39 (MDEV-25506). --- .../suite/innodb/r/truncate_foreign.result | 18 ++++++++++++++++++ .../suite/innodb/t/truncate_foreign.test | 19 +++++++++++++++++++ storage/innobase/handler/ha_innodb.cc | 2 ++ 3 files changed, 39 insertions(+) diff --git a/mysql-test/suite/innodb/r/truncate_foreign.result b/mysql-test/suite/innodb/r/truncate_foreign.result index 12a41860708..f9a7bcf562c 100644 --- a/mysql-test/suite/innodb/r/truncate_foreign.result +++ b/mysql-test/suite/innodb/r/truncate_foreign.result @@ -68,3 +68,21 @@ TRUNCATE TABLE t1; ALTER TABLE t1 ADD c INT; UNLOCK TABLES; DROP TABLE t1; +# +# MDEV-26052 Assertion prebuilt->trx_id < table->def_trx_id failed +# +call mtr.add_suppression("InnoDB: In ALTER TABLE `test`\\.`t1` has or is"); +CREATE TABLE t1 (pk INT, a INT, PRIMARY KEY (pk), KEY (a)) ENGINE=InnoDB; +SET FOREIGN_KEY_CHECKS=0; +ALTER TABLE t1 ADD FOREIGN KEY (a) REFERENCES t1 (a), ALGORITHM=COPY; +INSERT INTO t1 VALUES (1,1); +LOCK TABLES t1 WRITE; +TRUNCATE t1; +ERROR HY000: Cannot add foreign key constraint for `t1` +INSERT INTO t1 VALUES (2,2); +SELECT * FROM t1; +pk a +1 1 +2 2 +DROP TABLE t1; +# End of 10.6 tests diff --git a/mysql-test/suite/innodb/t/truncate_foreign.test b/mysql-test/suite/innodb/t/truncate_foreign.test index 1c150e5db40..7a0bc57d5cd 100644 --- a/mysql-test/suite/innodb/t/truncate_foreign.test +++ b/mysql-test/suite/innodb/t/truncate_foreign.test @@ -80,3 +80,22 @@ TRUNCATE TABLE t1; ALTER TABLE t1 ADD c INT; UNLOCK TABLES; DROP TABLE t1; + +--echo # +--echo # MDEV-26052 Assertion prebuilt->trx_id < table->def_trx_id failed +--echo # + +call mtr.add_suppression("InnoDB: In ALTER TABLE `test`\\.`t1` has or is"); + +CREATE TABLE t1 (pk INT, a INT, PRIMARY KEY (pk), KEY (a)) ENGINE=InnoDB; +SET FOREIGN_KEY_CHECKS=0; +ALTER TABLE t1 ADD FOREIGN KEY (a) REFERENCES t1 (a), ALGORITHM=COPY; +INSERT INTO t1 VALUES (1,1); +LOCK TABLES t1 WRITE; +--error ER_CANNOT_ADD_FOREIGN +TRUNCATE t1; +INSERT INTO t1 VALUES (2,2); +SELECT * FROM t1; +DROP TABLE t1; + +--echo # End of 10.6 tests diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 63a679c0317..2a91106ba22 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -13707,6 +13707,7 @@ int ha_innobase::truncate() } else { const auto update_time = ib_table->update_time; const auto stored_lock = m_prebuilt->stored_select_lock_type; + const auto def_trx_id = ib_table->def_trx_id; ib_table->release(); m_prebuilt->table = nullptr; @@ -13721,6 +13722,7 @@ int ha_innobase::truncate() reload: m_prebuilt->table = dict_table_open_on_name( name, false, false, DICT_ERR_IGNORE_NONE); + m_prebuilt->table->def_trx_id = def_trx_id; } else { row_prebuilt_t* prebuilt = m_prebuilt; uchar* upd_buf = m_upd_buf; From 3f2c4758b07227ed6658f0ccc491b747dfd7aa54 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Fri, 11 Jun 2021 17:13:19 +1000 Subject: [PATCH 225/251] MDEV-25894: support AIX as a platform in mtr Parital backport of 48938c57c7f75b2a7627212b01cd65cfd6830261 so platform dependent AIX tests can be done. --- mysql-test/include/platform.combinations | 2 ++ mysql-test/lib/My/Platform.pm | 11 ++++++++++- mysql-test/main/mysqld--help,aix.rdiff | 0 mysql-test/suite.pm | 8 +++++++- 4 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 mysql-test/main/mysqld--help,aix.rdiff diff --git a/mysql-test/include/platform.combinations b/mysql-test/include/platform.combinations index 4681ac05314..4f0660b7a40 100644 --- a/mysql-test/include/platform.combinations +++ b/mysql-test/include/platform.combinations @@ -1,4 +1,6 @@ [win] +[aix] + [unix] diff --git a/mysql-test/lib/My/Platform.pm b/mysql-test/lib/My/Platform.pm index db1206f187e..b8bc9f8ec84 100644 --- a/mysql-test/lib/My/Platform.pm +++ b/mysql-test/lib/My/Platform.pm @@ -22,7 +22,7 @@ use File::Basename; use File::Path; use base qw(Exporter); -our @EXPORT= qw(IS_CYGWIN IS_WINDOWS IS_WIN32PERL +our @EXPORT= qw(IS_CYGWIN IS_WINDOWS IS_WIN32PERL IS_AIX native_path posix_path mixed_path check_socket_path_length process_alive open_for_append); @@ -54,6 +54,15 @@ BEGIN { } } +BEGIN { + if ($^O eq "aix") { + eval 'sub IS_AIX { 1 }'; + } + else { + eval 'sub IS_AIX { 0 }'; + } +} + # # native_path diff --git a/mysql-test/main/mysqld--help,aix.rdiff b/mysql-test/main/mysqld--help,aix.rdiff new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mysql-test/suite.pm b/mysql-test/suite.pm index 2617f95d989..b76a50716cc 100644 --- a/mysql-test/suite.pm +++ b/mysql-test/suite.pm @@ -17,7 +17,13 @@ sub skip_combinations { unless $ENV{DEBUG_KEY_MANAGEMENT_SO}; # don't run tests for the wrong platform - $skip{'include/platform.combinations'} = [ (IS_WINDOWS) ? 'unix' : 'win' ]; + if (IS_WINDOWS) { + $skip{'include/platform.combinations'} = [ 'aix', 'unix' ]; + } elsif (IS_AIX) { + $skip{'include/platform.combinations'} = [ 'win', 'unix' ]; + } else { + $skip{'include/platform.combinations'} = [ 'aix', 'win' ]; + } $skip{'include/maybe_debug.combinations'} = [ defined $::mysqld_variables{'debug-dbug'} ? 'release' : 'debug' ]; From 0a9487b62b5f4126c63a191a1867367c845ddfbe Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Fri, 2 Jul 2021 13:00:34 +1000 Subject: [PATCH 226/251] mtr: aix - no pool of threads --- mysql-test/include/not_aix.inc | 4 ++++ mysql-test/main/mdev-21101.test | 1 + mysql-test/suite.pm | 1 + 3 files changed, 6 insertions(+) create mode 100644 mysql-test/include/not_aix.inc diff --git a/mysql-test/include/not_aix.inc b/mysql-test/include/not_aix.inc new file mode 100644 index 00000000000..ecdb3b97a6e --- /dev/null +++ b/mysql-test/include/not_aix.inc @@ -0,0 +1,4 @@ +# +# suite.pm will make sure that all tests including this file +# will be skipped if run under AIX +# diff --git a/mysql-test/main/mdev-21101.test b/mysql-test/main/mdev-21101.test index 627e86462a1..543b587c5e6 100644 --- a/mysql-test/main/mdev-21101.test +++ b/mysql-test/main/mdev-21101.test @@ -1,4 +1,5 @@ --source include/not_embedded.inc +--source include/not_aix.inc # Test that wait_timeout does not cause connection to be closed, when connection is delayed due to # threadpool internal problems, e.g misconfiguration - too few threads and queueing. # So if client did not cause wait_timeout, do not report it either. diff --git a/mysql-test/suite.pm b/mysql-test/suite.pm index b76a50716cc..2428f3156b9 100644 --- a/mysql-test/suite.pm +++ b/mysql-test/suite.pm @@ -53,6 +53,7 @@ sub skip_combinations { unless $ENV{HA_EXAMPLE_SO}; $skip{'include/not_windows.inc'} = 'Requires not Windows' if IS_WINDOWS; + $skip{'include/not_aix.inc'} = 'Requires not AIX' if IS_AIX; $skip{'main/plugin_loaderr.test'} = 'needs compiled-in innodb' unless $::mysqld_variables{'innodb'} eq "ON"; From c22f7f2323d6f823c9340d0a85a2b7ad0239f16f Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Fri, 2 Jul 2021 15:57:50 +1000 Subject: [PATCH 227/251] MDEV-25129 postfix for windows C:\projects\server\sql\sql_show.cc(7913): error C2220: warning treated as error - no 'object' file generated [C:\projects\server\win_build\sql\sql.vcxproj] C:\projects\server\sql\sql_show.cc(7913): warning C4267: 'initializing': conversion from 'size_t' to 'uint', possible loss of data [C:\projects\server\win_build\sql\sql.vcxproj] caused by 768c51880a5aa6d25d4c0fe7de7a88561ff46422 --- sql/sql_show.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_show.cc b/sql/sql_show.cc index f8f784bbbad..721bb053343 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -7572,7 +7572,7 @@ int fill_variables(THD *thd, TABLE_LIST *tables, COND *cond) int add_symbol_to_table(const char* name, TABLE* table){ DBUG_ENTER("add_symbol_to_table"); - uint length= strlen(name); + size_t length= strlen(name); // If you've added a new SQL keyword longer than KEYWORD_SIZE, // please increase the defined max length From 7ce5984d6df1bb4f843bec244411ec5514c46105 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Fri, 2 Jul 2021 15:50:21 +1000 Subject: [PATCH 228/251] mtr: fix tests funcs_1.is_tables_is & sql_sequence.rebuild --- mysql-test/suite/funcs_1/r/is_tables_is.result | 8 ++++++++ mysql-test/suite/sql_sequence/rebuild.result | 2 ++ 2 files changed, 10 insertions(+) diff --git a/mysql-test/suite/funcs_1/r/is_tables_is.result b/mysql-test/suite/funcs_1/r/is_tables_is.result index 70564ab6af8..338f445c2d4 100644 --- a/mysql-test/suite/funcs_1/r/is_tables_is.result +++ b/mysql-test/suite/funcs_1/r/is_tables_is.result @@ -458,6 +458,8 @@ TABLE_COLLATION utf8_general_ci CHECKSUM NULL CREATE_OPTIONS #CO# TABLE_COMMENT #TC# +MAX_INDEX_LENGTH #MIL# +TEMPORARY Y user_comment Separator ----------------------------------------------------- TABLE_CATALOG def @@ -806,6 +808,8 @@ TABLE_COLLATION utf8_general_ci CHECKSUM NULL CREATE_OPTIONS #CO# TABLE_COMMENT #TC# +MAX_INDEX_LENGTH #MIL# +TEMPORARY Y user_comment Separator ----------------------------------------------------- TABLE_CATALOG def @@ -1545,6 +1549,8 @@ TABLE_COLLATION utf8_general_ci CHECKSUM NULL CREATE_OPTIONS #CO# TABLE_COMMENT #TC# +MAX_INDEX_LENGTH #MIL# +TEMPORARY Y user_comment Separator ----------------------------------------------------- TABLE_CATALOG def @@ -1893,6 +1899,8 @@ TABLE_COLLATION utf8_general_ci CHECKSUM NULL CREATE_OPTIONS #CO# TABLE_COMMENT #TC# +MAX_INDEX_LENGTH #MIL# +TEMPORARY Y user_comment Separator ----------------------------------------------------- TABLE_CATALOG def diff --git a/mysql-test/suite/sql_sequence/rebuild.result b/mysql-test/suite/sql_sequence/rebuild.result index c8dc47ad8fa..a7f231d5253 100644 --- a/mysql-test/suite/sql_sequence/rebuild.result +++ b/mysql-test/suite/sql_sequence/rebuild.result @@ -45,6 +45,7 @@ INNODB_SYS_INDEXES INNODB_SYS_TABLES INNODB_SYS_VIRTUAL INNODB_TRX +KEYWORDS KEY_CACHES KEY_COLUMN_USAGE PARAMETERS @@ -59,6 +60,7 @@ SCHEMA_PRIVILEGES SESSION_STATUS SESSION_VARIABLES SPATIAL_REF_SYS +SQL_FUNCTIONS STATISTICS SYSTEM_VARIABLES TABLES From 2301093f8f9ed1ea1d72b81bf1c5fa35da5c8a36 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Fri, 11 Jun 2021 17:13:19 +1000 Subject: [PATCH 229/251] MDEV-25894: support AIX as a platform in mtr Parital backport of 48938c57c7f75b2a7627212b01cd65cfd6830261 so platform dependent AIX tests can be done. --- mysql-test/include/platform.combinations | 2 ++ mysql-test/lib/My/Platform.pm | 11 ++++++++++- mysql-test/main/mysqld--help,aix.rdiff | 0 mysql-test/suite.pm | 8 +++++++- 4 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 mysql-test/main/mysqld--help,aix.rdiff diff --git a/mysql-test/include/platform.combinations b/mysql-test/include/platform.combinations index 4681ac05314..4f0660b7a40 100644 --- a/mysql-test/include/platform.combinations +++ b/mysql-test/include/platform.combinations @@ -1,4 +1,6 @@ [win] +[aix] + [unix] diff --git a/mysql-test/lib/My/Platform.pm b/mysql-test/lib/My/Platform.pm index db1206f187e..b8bc9f8ec84 100644 --- a/mysql-test/lib/My/Platform.pm +++ b/mysql-test/lib/My/Platform.pm @@ -22,7 +22,7 @@ use File::Basename; use File::Path; use base qw(Exporter); -our @EXPORT= qw(IS_CYGWIN IS_WINDOWS IS_WIN32PERL +our @EXPORT= qw(IS_CYGWIN IS_WINDOWS IS_WIN32PERL IS_AIX native_path posix_path mixed_path check_socket_path_length process_alive open_for_append); @@ -54,6 +54,15 @@ BEGIN { } } +BEGIN { + if ($^O eq "aix") { + eval 'sub IS_AIX { 1 }'; + } + else { + eval 'sub IS_AIX { 0 }'; + } +} + # # native_path diff --git a/mysql-test/main/mysqld--help,aix.rdiff b/mysql-test/main/mysqld--help,aix.rdiff new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mysql-test/suite.pm b/mysql-test/suite.pm index 905c3460d46..86f2d6c0c18 100644 --- a/mysql-test/suite.pm +++ b/mysql-test/suite.pm @@ -17,7 +17,13 @@ sub skip_combinations { unless $ENV{DEBUG_KEY_MANAGEMENT_SO}; # don't run tests for the wrong platform - $skip{'include/platform.combinations'} = [ (IS_WINDOWS) ? 'unix' : 'win' ]; + if (IS_WINDOWS) { + $skip{'include/platform.combinations'} = [ 'aix', 'unix' ]; + } elsif (IS_AIX) { + $skip{'include/platform.combinations'} = [ 'win', 'unix' ]; + } else { + $skip{'include/platform.combinations'} = [ 'aix', 'win' ]; + } $skip{'include/maybe_debug.combinations'} = [ defined $::mysqld_variables{'debug-dbug'} ? 'release' : 'debug' ]; From 6a3a0460133d0336d4774c006193b231daa6cc3b Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Fri, 2 Jul 2021 13:00:34 +1000 Subject: [PATCH 230/251] mtr: aix - no pool of threads --- mysql-test/include/not_aix.inc | 4 ++++ mysql-test/main/mdev-21101.test | 1 + mysql-test/suite.pm | 1 + 3 files changed, 6 insertions(+) create mode 100644 mysql-test/include/not_aix.inc diff --git a/mysql-test/include/not_aix.inc b/mysql-test/include/not_aix.inc new file mode 100644 index 00000000000..ecdb3b97a6e --- /dev/null +++ b/mysql-test/include/not_aix.inc @@ -0,0 +1,4 @@ +# +# suite.pm will make sure that all tests including this file +# will be skipped if run under AIX +# diff --git a/mysql-test/main/mdev-21101.test b/mysql-test/main/mdev-21101.test index 627e86462a1..543b587c5e6 100644 --- a/mysql-test/main/mdev-21101.test +++ b/mysql-test/main/mdev-21101.test @@ -1,4 +1,5 @@ --source include/not_embedded.inc +--source include/not_aix.inc # Test that wait_timeout does not cause connection to be closed, when connection is delayed due to # threadpool internal problems, e.g misconfiguration - too few threads and queueing. # So if client did not cause wait_timeout, do not report it either. diff --git a/mysql-test/suite.pm b/mysql-test/suite.pm index 86f2d6c0c18..5100b4137a2 100644 --- a/mysql-test/suite.pm +++ b/mysql-test/suite.pm @@ -49,6 +49,7 @@ sub skip_combinations { unless $ENV{HA_EXAMPLE_SO}; $skip{'include/not_windows.inc'} = 'Requires not Windows' if IS_WINDOWS; + $skip{'include/not_aix.inc'} = 'Requires not AIX' if IS_AIX; $skip{'main/plugin_loaderr.test'} = 'needs compiled-in innodb' unless $::mysqld_variables{'innodb'} eq "ON"; From fa8eb4de554152a673658fed7b3284c76009e208 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Fri, 2 Jul 2021 14:54:59 +1000 Subject: [PATCH 231/251] mtr: plugin.multiauth aix fix The error loading the client module is different --- mysql-test/suite/plugins/r/multiauth,aix.rdiff | 14 ++++++++++++++ mysql-test/suite/plugins/t/multiauth.test | 1 + 2 files changed, 15 insertions(+) create mode 100644 mysql-test/suite/plugins/r/multiauth,aix.rdiff diff --git a/mysql-test/suite/plugins/r/multiauth,aix.rdiff b/mysql-test/suite/plugins/r/multiauth,aix.rdiff new file mode 100644 index 00000000000..0a2570cbd89 --- /dev/null +++ b/mysql-test/suite/plugins/r/multiauth,aix.rdiff @@ -0,0 +1,14 @@ +diff --git a/mysql-test/suite/plugins/r/multiauth.result b/mysql-test/suite/plugins/r/multiauth.result +index aed46ac8964..24bb0a24f03 100644 +--- a/mysql-test/suite/plugins/r/multiauth.result ++++ b/mysql-test/suite/plugins/r/multiauth.result +@@ -181,7 +181,8 @@ show create user mysqltest1; + CREATE USER for mysqltest1@% + CREATE USER `mysqltest1`@`%` IDENTIFIED VIA ed25519 USING 'F4aF8bw7130VaRbdLCl4f/P/wkjDmgJXwWvpJ5gmsZc' + # no plugin = failure +-mysqltest: Could not open connection 'default': 1045 Plugin client_ed25519 could not be loaded: /no/client_ed25519.so: cannot open shared object file: No such file or directory ++mysqltest: Could not open connection 'default': 1045 Plugin client_ed25519 could not be loaded: Could not load module /no/client_ed25519.so. ++System error: No such file or directory + alter user mysqltest1 identified via ed25519 as password("good") OR mysql_native_password as password("works"); + show create user mysqltest1; + CREATE USER for mysqltest1@% diff --git a/mysql-test/suite/plugins/t/multiauth.test b/mysql-test/suite/plugins/t/multiauth.test index 253e8823d37..87970e2c781 100644 --- a/mysql-test/suite/plugins/t/multiauth.test +++ b/mysql-test/suite/plugins/t/multiauth.test @@ -1,4 +1,5 @@ --source include/not_ubsan.inc +--source include/platform.inc # # MDEV-11340 Allow multiple alternative authentication methods for the same user # From e34877ab63d127f6f8e536c82f5d65505e406a5e Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Thu, 1 Jul 2021 16:14:09 +0530 Subject: [PATCH 232/251] MDEV-25971 Instant ADD COLUMN fails to issue truncation warnings A table rebuild that would truncate the default value of a DATE column is expected to issue data truncation warnings. But, these warnings are not being issued if the ADD COLUMN is being executed with ALGORITHM=INSTANT. InnoDB sets the warning of the field while assigning the default value of the field during check_if_supported_inplace_alter(). --- mysql-test/suite/innodb/r/innodb-alter.result | 17 ++++++------- .../suite/innodb/r/instant_alter.result | 24 ++++++++++++++----- mysql-test/suite/innodb/t/innodb-alter.test | 7 ++---- sql/sql_table.cc | 9 ++++--- 4 files changed, 35 insertions(+), 22 deletions(-) diff --git a/mysql-test/suite/innodb/r/innodb-alter.result b/mysql-test/suite/innodb/r/innodb-alter.result index cce8a060b0e..749e242fce8 100644 --- a/mysql-test/suite/innodb/r/innodb-alter.result +++ b/mysql-test/suite/innodb/r/innodb-alter.result @@ -1049,13 +1049,12 @@ a 10 DROP TABLE t1; CREATE TABLE t1 (a INT NOT NULL DEFAULT 0) ENGINE=InnoDB; -SET @save_allowed = @@GLOBAL.innodb_instant_alter_column_allowed; -SET GLOBAL innodb_instant_alter_column_allowed=never; -iNSERT INTO t1 VALUES (10); -ALTER TABLE t1 ADD b DATE NOT NULL DEFAULT if(unix_timestamp()>1,TIMESTAMP'2001-01-01 10:20:30',0); -affected rows: 0 -info: Records: 0 Duplicates: 0 Warnings: 0 -SET GLOBAL innodb_instant_alter_column_allowed=@save_allowed; +INSERT INTO t1 VALUES (10); +ALTER TABLE t1 ADD b DATE NOT NULL DEFAULT if(unix_timestamp()>1,TIMESTAMP'2001-01-01 10:20:30',0), algorithm=copy; +affected rows: 1 +info: Records: 1 Duplicates: 0 Warnings: 1 +Warnings: +Note 1265 Data truncated for column 'b' at row 1 SELECT * FROM t1; a b 10 2001-01-01 @@ -1064,7 +1063,9 @@ CREATE TABLE t1 (a INT NOT NULL DEFAULT 0) ENGINE=InnoDB; iNSERT INTO t1 VALUES (10); ALTER TABLE t1 ADD b TIME NOT NULL DEFAULT if(unix_timestamp()>1,TIMESTAMP'2001-01-01 10:20:30',0); affected rows: 0 -info: Records: 0 Duplicates: 0 Warnings: 0 +info: Records: 0 Duplicates: 0 Warnings: 1 +Warnings: +Note 1265 Data truncated for column 'b' at row 1 SELECT * FROM t1; a b 10 10:20:30 diff --git a/mysql-test/suite/innodb/r/instant_alter.result b/mysql-test/suite/innodb/r/instant_alter.result index 1a818531756..5d76d648345 100644 --- a/mysql-test/suite/innodb/r/instant_alter.result +++ b/mysql-test/suite/innodb/r/instant_alter.result @@ -308,10 +308,14 @@ id c2 c3 c4 c5 c6 affected rows: 3 ALTER TABLE t3 ADD COLUMN c7 TIME NOT NULL DEFAULT current_timestamp(); affected rows: 0 -info: Records: 0 Duplicates: 0 Warnings: 0 +info: Records: 0 Duplicates: 0 Warnings: 1 +Warnings: +Note 1265 Data truncated for column 'c7' at row 1 ALTER TABLE t3 ADD COLUMN c8 DATE NOT NULL DEFAULT current_timestamp(); affected rows: 0 -info: Records: 0 Duplicates: 0 Warnings: 0 +info: Records: 0 Duplicates: 0 Warnings: 1 +Warnings: +Note 1265 Data truncated for column 'c8' at row 1 SELECT id, c2, ST_AsText(c3) c3, c4, c5, c6, c7, c8 FROM t3; id c2 c3 c4 c5 c6 c7 c8 1 1 POLYGON((1 1,2 2,3 3,1 1)) 1970-01-01 03:00:42 1970-01-01 03:00:42 NULL 03:00:42 1970-01-01 @@ -788,10 +792,14 @@ id c2 c3 c4 c5 c6 affected rows: 3 ALTER TABLE t3 ADD COLUMN c7 TIME NOT NULL DEFAULT current_timestamp(); affected rows: 0 -info: Records: 0 Duplicates: 0 Warnings: 0 +info: Records: 0 Duplicates: 0 Warnings: 1 +Warnings: +Note 1265 Data truncated for column 'c7' at row 1 ALTER TABLE t3 ADD COLUMN c8 DATE NOT NULL DEFAULT current_timestamp(); affected rows: 0 -info: Records: 0 Duplicates: 0 Warnings: 0 +info: Records: 0 Duplicates: 0 Warnings: 1 +Warnings: +Note 1265 Data truncated for column 'c8' at row 1 SELECT id, c2, ST_AsText(c3) c3, c4, c5, c6, c7, c8 FROM t3; id c2 c3 c4 c5 c6 c7 c8 1 1 POLYGON((1 1,2 2,3 3,1 1)) 1970-01-01 03:00:42 1970-01-01 03:00:42 NULL 03:00:42 1970-01-01 @@ -1268,10 +1276,14 @@ id c2 c3 c4 c5 c6 affected rows: 3 ALTER TABLE t3 ADD COLUMN c7 TIME NOT NULL DEFAULT current_timestamp(); affected rows: 0 -info: Records: 0 Duplicates: 0 Warnings: 0 +info: Records: 0 Duplicates: 0 Warnings: 1 +Warnings: +Note 1265 Data truncated for column 'c7' at row 1 ALTER TABLE t3 ADD COLUMN c8 DATE NOT NULL DEFAULT current_timestamp(); affected rows: 0 -info: Records: 0 Duplicates: 0 Warnings: 0 +info: Records: 0 Duplicates: 0 Warnings: 1 +Warnings: +Note 1265 Data truncated for column 'c8' at row 1 SELECT id, c2, ST_AsText(c3) c3, c4, c5, c6, c7, c8 FROM t3; id c2 c3 c4 c5 c6 c7 c8 1 1 POLYGON((1 1,2 2,3 3,1 1)) 1970-01-01 03:00:42 1970-01-01 03:00:42 NULL 03:00:42 1970-01-01 diff --git a/mysql-test/suite/innodb/t/innodb-alter.test b/mysql-test/suite/innodb/t/innodb-alter.test index e0ee5a04ac4..d1adc4c91c0 100644 --- a/mysql-test/suite/innodb/t/innodb-alter.test +++ b/mysql-test/suite/innodb/t/innodb-alter.test @@ -652,13 +652,10 @@ DROP TABLE t1; # DATETIME-to-DATE truncation is OK CREATE TABLE t1 (a INT NOT NULL DEFAULT 0) ENGINE=InnoDB; -SET @save_allowed = @@GLOBAL.innodb_instant_alter_column_allowed; -SET GLOBAL innodb_instant_alter_column_allowed=never; -iNSERT INTO t1 VALUES (10); +INSERT INTO t1 VALUES (10); --enable_info -ALTER TABLE t1 ADD b DATE NOT NULL DEFAULT if(unix_timestamp()>1,TIMESTAMP'2001-01-01 10:20:30',0); +ALTER TABLE t1 ADD b DATE NOT NULL DEFAULT if(unix_timestamp()>1,TIMESTAMP'2001-01-01 10:20:30',0), algorithm=copy; --disable_info -SET GLOBAL innodb_instant_alter_column_allowed=@save_allowed; SELECT * FROM t1; DROP TABLE t1; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index c70639d71db..9aae74a613d 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -10015,9 +10015,12 @@ do_continue:; if (alter_info->requested_lock == Alter_info::ALTER_TABLE_LOCK_NONE) ha_alter_info.online= true; // Ask storage engine whether to use copy or in-place - ha_alter_info.inplace_supported= - table->file->check_if_supported_inplace_alter(altered_table, - &ha_alter_info); + { + Check_level_instant_set check_level_save(thd, CHECK_FIELD_WARN); + ha_alter_info.inplace_supported= + table->file->check_if_supported_inplace_alter(altered_table, + &ha_alter_info); + } if (alter_info->supports_algorithm(thd, &ha_alter_info) || alter_info->supports_lock(thd, &ha_alter_info)) From 5a2b6258435fa050e23a411ceeeb5fac015e92d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 2 Jul 2021 11:08:48 +0300 Subject: [PATCH 233/251] MDEV-25129 fixup: Adjust test result Fixup for commit 768c51880a5aa6d25d4c0fe7de7a88561ff46422 --- mysql-test/r/information_schema-big.result | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mysql-test/r/information_schema-big.result b/mysql-test/r/information_schema-big.result index 0ed74d113ea..5c519014800 100644 --- a/mysql-test/r/information_schema-big.result +++ b/mysql-test/r/information_schema-big.result @@ -34,6 +34,7 @@ GEOMETRY_COLUMNS F_TABLE_SCHEMA GLOBAL_STATUS VARIABLE_NAME GLOBAL_VARIABLES VARIABLE_NAME INDEX_STATISTICS TABLE_SCHEMA +KEYWORDS WORD KEY_CACHES KEY_CACHE_NAME KEY_COLUMN_USAGE CONSTRAINT_SCHEMA PARAMETERS SPECIFIC_SCHEMA @@ -48,6 +49,7 @@ SCHEMA_PRIVILEGES TABLE_SCHEMA SESSION_STATUS VARIABLE_NAME SESSION_VARIABLES VARIABLE_NAME SPATIAL_REF_SYS SRID +SQL_FUNCTIONS FUNCTION STATISTICS TABLE_SCHEMA SYSTEM_VARIABLES VARIABLE_NAME TABLES TABLE_SCHEMA @@ -92,6 +94,7 @@ GEOMETRY_COLUMNS F_TABLE_SCHEMA GLOBAL_STATUS VARIABLE_NAME GLOBAL_VARIABLES VARIABLE_NAME INDEX_STATISTICS TABLE_SCHEMA +KEYWORDS WORD KEY_CACHES KEY_CACHE_NAME KEY_COLUMN_USAGE CONSTRAINT_SCHEMA PARAMETERS SPECIFIC_SCHEMA @@ -106,6 +109,7 @@ SCHEMA_PRIVILEGES TABLE_SCHEMA SESSION_STATUS VARIABLE_NAME SESSION_VARIABLES VARIABLE_NAME SPATIAL_REF_SYS SRID +SQL_FUNCTIONS FUNCTION STATISTICS TABLE_SCHEMA SYSTEM_VARIABLES VARIABLE_NAME TABLES TABLE_SCHEMA From 2bf6f2c054c2f453df3a5c2bf9254599d18162d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 2 Jul 2021 11:15:35 +0300 Subject: [PATCH 234/251] MDEV-26077 Assertion err != DB_DUPLICATE_KEY or unexpected ER_TABLE_EXISTS_ERROR This is a backport of 161e4bfafd261aa5204827086637d4d7dcceb949. trans_rollback_to_savepoint(): Only release metadata locks (MDL) if the storage engines agree, after the changes were already rolled back. Ever since commit 3792693f311a90cf195ec6d2f9b3762255a249c7 and mysql/mysql-server@55ceedbc3feb911505dcba6cee8080d55ce86dda we used to cheat here and always release MDL if the binlog is disabled. MDL are supposed to prevent race conditions between DML and DDL also when no replication is in use. MDL are supposed to be a superset of InnoDB table locks: InnoDB table lock may only exist if the thread also holds MDL on the table name. In the included test case, ROLLBACK TO SAVEPOINT would wrongly release the MDL on both tables and let ALTER TABLE proceed, even though the DML transaction is actually holding locks on the table. Until commit 1bd681c8b3c5213ce1f7976940a7dc38b48a0d39 (MDEV-25506) in MariaDB 10.6, InnoDB would often work around the locking violation in a blatantly non-ACID way: If locks exist on a table that is being dropped (in this case, actually a partition of a table that is being rebuilt by ALTER TABLE), InnoDB could move the table (or partition) into a queue, to be dropped after the locks and references had been released. If the lock is not released and the original copy of the table not dropped quickly enough, a name conflict could occur on a subsequent ALTER TABLE. The scenario of commit 3792693f311a90cf195ec6d2f9b3762255a249c7 is unaffected by this fix, because mysqldump would use non-locking reads, and the transaction would not be holding any InnoDB locks during the execution of ROLLBACK TO SAVEPOINT. MVCC reads inside InnoDB are only covered by MDL and page latches, not by any table or record locks. FIXME: It would be nice if storage engines were specifically asked which MDL can be released, instead of only offering a choice between all or nothing. InnoDB should be able to release any locks for tables that are no longer in trx_t::mod_tables, except if another transaction had converted some implicit record locks to explicit ones, before the ROLLBACK TO SAVEPOINT had been completed. Reviewed by: Sergei Golubchik --- .../suite/innodb/r/alter_partitioned.result | 35 ++++++++++++++++++ .../suite/innodb/t/alter_partitioned.test | 36 +++++++++++++++++++ sql/transaction.cc | 36 +++++-------------- 3 files changed, 80 insertions(+), 27 deletions(-) create mode 100644 mysql-test/suite/innodb/r/alter_partitioned.result create mode 100644 mysql-test/suite/innodb/t/alter_partitioned.test diff --git a/mysql-test/suite/innodb/r/alter_partitioned.result b/mysql-test/suite/innodb/r/alter_partitioned.result new file mode 100644 index 00000000000..285e9fd2c54 --- /dev/null +++ b/mysql-test/suite/innodb/r/alter_partitioned.result @@ -0,0 +1,35 @@ +# +# MDEV-26077 Assertion failure err != DB_DUPLICATE_KEY +# or unexpected ER_TABLE_EXISTS_ERROR +# +CREATE TABLE t1 (pk INT PRIMARY KEY) ENGINE=InnoDB; +CREATE TABLE t2 (pk INT PRIMARY KEY) ENGINE=InnoDB; +connect con1,localhost,root,,test; +START TRANSACTION; +INSERT INTO t2 (pk) VALUES (1); +SAVEPOINT sp; +INSERT INTO t1 (pk) VALUES (1); +ROLLBACK TO SAVEPOINT sp; +connection default; +SET lock_wait_timeout=0; +Warnings: +Warning 1292 Truncated incorrect lock_wait_timeout value: '0' +SET innodb_lock_wait_timeout=0; +Warnings: +Warning 1292 Truncated incorrect innodb_lock_wait_timeout value: '0' +ALTER TABLE t1 PARTITION BY HASH(pk); +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `pk` int(11) NOT NULL, + PRIMARY KEY (`pk`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +connection con1; +COMMIT; +connection default; +ALTER TABLE t2 PARTITION BY HASH(pk); +disconnect con1; +connection default; +DROP TABLE t1, t2; +# End of 10.2 tests diff --git a/mysql-test/suite/innodb/t/alter_partitioned.test b/mysql-test/suite/innodb/t/alter_partitioned.test new file mode 100644 index 00000000000..1ce50dbdd0b --- /dev/null +++ b/mysql-test/suite/innodb/t/alter_partitioned.test @@ -0,0 +1,36 @@ +--source include/have_innodb.inc +--source include/have_partition.inc + +--echo # +--echo # MDEV-26077 Assertion failure err != DB_DUPLICATE_KEY +--echo # or unexpected ER_TABLE_EXISTS_ERROR +--echo # + +CREATE TABLE t1 (pk INT PRIMARY KEY) ENGINE=InnoDB; +CREATE TABLE t2 (pk INT PRIMARY KEY) ENGINE=InnoDB; + +--connect (con1,localhost,root,,test) + +START TRANSACTION; +INSERT INTO t2 (pk) VALUES (1); +SAVEPOINT sp; +INSERT INTO t1 (pk) VALUES (1); +ROLLBACK TO SAVEPOINT sp; + +--connection default +SET lock_wait_timeout=0; +SET innodb_lock_wait_timeout=0; +--error ER_LOCK_WAIT_TIMEOUT +ALTER TABLE t1 PARTITION BY HASH(pk); + +SHOW CREATE TABLE t1; +--connection con1 +COMMIT; +--connection default +ALTER TABLE t2 PARTITION BY HASH(pk); +# Cleanup +--disconnect con1 +--connection default +DROP TABLE t1, t2; + +--echo # End of 10.2 tests diff --git a/sql/transaction.cc b/sql/transaction.cc index 543e0b7ad38..d9d0d402ec7 100644 --- a/sql/transaction.cc +++ b/sql/transaction.cc @@ -1,4 +1,5 @@ /* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2009, 2021, 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 @@ -696,32 +697,6 @@ bool trans_rollback_to_savepoint(THD *thd, LEX_STRING name) if (WSREP_ON) wsrep_register_hton(thd, thd->in_multi_stmt_transaction_mode()); - /** - Checking whether it is safe to release metadata locks acquired after - savepoint, if rollback to savepoint is successful. - - Whether it is safe to release MDL after rollback to savepoint depends - on storage engines participating in transaction: - - - InnoDB doesn't release any row-locks on rollback to savepoint so it - is probably a bad idea to release MDL as well. - - Binary log implementation in some cases (e.g when non-transactional - tables involved) may choose not to remove events added after savepoint - from transactional cache, but instead will write them to binary - log accompanied with ROLLBACK TO SAVEPOINT statement. Since the real - write happens at the end of transaction releasing MDL on tables - mentioned in these events (i.e. acquired after savepoint and before - rollback ot it) can break replication, as concurrent DROP TABLES - statements will be able to drop these tables before events will get - into binary log, - - For backward-compatibility reasons we always release MDL if binary - logging is off. - */ - bool mdl_can_safely_rollback_to_savepoint= - (!(mysql_bin_log.is_open() && thd->variables.sql_log_bin) || - ha_rollback_to_savepoint_can_release_mdl(thd)); - if (ha_rollback_to_savepoint(thd, sv)) res= TRUE; else if (((thd->variables.option_bits & OPTION_KEEP_LOG) || @@ -733,7 +708,14 @@ bool trans_rollback_to_savepoint(THD *thd, LEX_STRING name) thd->transaction.savepoints= sv; - if (!res && mdl_can_safely_rollback_to_savepoint) + if (res) + /* An error occurred during rollback; we cannot release any MDL */; + else if (thd->variables.sql_log_bin && mysql_bin_log.is_open()) + /* In some cases (such as with non-transactional tables) we may + choose to preserve events that were added after the SAVEPOINT, + delimiting them by SAVEPOINT and ROLLBACK TO SAVEPOINT statements. + Prematurely releasing MDL on such objects would break replication. */; + else if (ha_rollback_to_savepoint_can_release_mdl(thd)) thd->mdl_context.rollback_to_savepoint(sv->mdl_savepoint); DBUG_RETURN(MY_TEST(res)); From ffe744e77d02737e57c5f9a2e9383ce7dbc15096 Mon Sep 17 00:00:00 2001 From: Eugene Kosov Date: Fri, 2 Jul 2021 13:07:36 +0300 Subject: [PATCH 235/251] submodules.cmake: add missing --depth=1 --- cmake/submodules.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/submodules.cmake b/cmake/submodules.cmake index 6e039bfeae3..b6c64b32f3d 100644 --- a/cmake/submodules.cmake +++ b/cmake/submodules.cmake @@ -28,7 +28,7 @@ IF(GIT_EXECUTABLE AND EXISTS "${CMAKE_SOURCE_DIR}/.git") RESULT_VARIABLE update_result) ELSE() MESSAGE(STATUS "Updating submodules") - EXECUTE_PROCESS(COMMAND "${GIT_EXECUTABLE}" submodule update --init + EXECUTE_PROCESS(COMMAND "${GIT_EXECUTABLE}" submodule update --init --depth=1 WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" RESULT_VARIABLE update_result) ENDIF() From a6adefad4b7dbc3ab102250ef01607dc977848c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 2 Jul 2021 14:41:32 +0300 Subject: [PATCH 236/251] Fixup 586870f9effa48831fda2590f2aee2b95b30be39 One more result was affected by merging 768c51880a5aa6d25d4c0fe7de7a88561ff46422. --- mysql-test/suite/funcs_1/r/is_tables_is_embedded.result | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mysql-test/suite/funcs_1/r/is_tables_is_embedded.result b/mysql-test/suite/funcs_1/r/is_tables_is_embedded.result index 70564ab6af8..338f445c2d4 100644 --- a/mysql-test/suite/funcs_1/r/is_tables_is_embedded.result +++ b/mysql-test/suite/funcs_1/r/is_tables_is_embedded.result @@ -458,6 +458,8 @@ TABLE_COLLATION utf8_general_ci CHECKSUM NULL CREATE_OPTIONS #CO# TABLE_COMMENT #TC# +MAX_INDEX_LENGTH #MIL# +TEMPORARY Y user_comment Separator ----------------------------------------------------- TABLE_CATALOG def @@ -806,6 +808,8 @@ TABLE_COLLATION utf8_general_ci CHECKSUM NULL CREATE_OPTIONS #CO# TABLE_COMMENT #TC# +MAX_INDEX_LENGTH #MIL# +TEMPORARY Y user_comment Separator ----------------------------------------------------- TABLE_CATALOG def @@ -1545,6 +1549,8 @@ TABLE_COLLATION utf8_general_ci CHECKSUM NULL CREATE_OPTIONS #CO# TABLE_COMMENT #TC# +MAX_INDEX_LENGTH #MIL# +TEMPORARY Y user_comment Separator ----------------------------------------------------- TABLE_CATALOG def @@ -1893,6 +1899,8 @@ TABLE_COLLATION utf8_general_ci CHECKSUM NULL CREATE_OPTIONS #CO# TABLE_COMMENT #TC# +MAX_INDEX_LENGTH #MIL# +TEMPORARY Y user_comment Separator ----------------------------------------------------- TABLE_CATALOG def From a635588b56c77d306c21717be2facc9c82f717f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 2 Jul 2021 16:11:01 +0300 Subject: [PATCH 237/251] MDEV-25236 Online log apply fails for ROW_FORMAT=REDUNDANT tables In other ROW_FORMAT than REDUNDANT, the InnoDB record header size calculation depends on dict_index_t::n_core_null_bytes. In ROW_FORMAT=REDUNDANT, the record header always is 6 bytes plus n_fields or 2*n_fields bytes, depending on the maximum record size. But, during online ALTER TABLE, the log records in the temporary file always use a format similar to ROW_FORMAT=DYNAMIC, even omitting the 5-byte fixed-length part of the header. While creating a temporary file record for a ROW_FORMAT=REDUNDANT table, InnoDB must refer to dict_index_t::n_nullable. The field dict_index_t::n_core_null_bytes is only valid for other than ROW_FORMAT=REDUNDANT tables. The bug does not affect MariaDB 10.3, because only commit 7a27db778e3e5a04271568a94c75157bb6fb48f1 (MDEV-15563) allowed an ALGORITHM=INSTANT change of a NOT NULL column to NULL in a ROW_FORMAT=REDUNDANT table. The fix was developed by Thirunarayanan Balathandayuthapani and tested by Matthias Leich. The test case was simplified by me. --- .../suite/innodb/r/instant_alter_debug.result | 23 +++++++++- .../suite/innodb/t/instant_alter_debug.test | 26 +++++++++++ storage/innobase/rem/rem0rec.cc | 45 ++++++++++++++----- 3 files changed, 81 insertions(+), 13 deletions(-) diff --git a/mysql-test/suite/innodb/r/instant_alter_debug.result b/mysql-test/suite/innodb/r/instant_alter_debug.result index 9a681b77c76..359eb1fc384 100644 --- a/mysql-test/suite/innodb/r/instant_alter_debug.result +++ b/mysql-test/suite/innodb/r/instant_alter_debug.result @@ -443,10 +443,31 @@ SET GLOBAL innodb_limit_optimistic_insert_debug=@save_limit; SELECT * FROM t1; c2 c DROP TABLE t1; +# +# MDEV-25236 Online log apply fails for ROW_FORMAT=REDUNDANT tables +# +CREATE TABLE t1 +(a INT NOT NULL, b INT, c INT, d INT, e INT, f INT, g INT, h INT, i TEXT) +ENGINE=InnoDB; +ALTER TABLE t1 MODIFY a INT NULL; +SET DEBUG_SYNC='innodb_inplace_alter_table_enter SIGNAL alter WAIT_FOR go'; +ALTER TABLE t1 ADD PRIMARY KEY (a); +connect con1,localhost,root,,; +set DEBUG_SYNC='now WAIT_FOR alter'; +BEGIN; +INSERT INTO t1 SET a=0, i=REPEAT('1', 10000); +ROLLBACK; +set DEBUG_SYNC='now SIGNAL go'; +connection default; +disconnect con1; +SELECT * FROM t1; +a b c d e f g h i +DROP TABLE t1; +SET DEBUG_SYNC=RESET; # End of 10.4 tests SET GLOBAL innodb_purge_rseg_truncate_frequency = @save_frequency; SELECT variable_value-@old_instant instants FROM information_schema.global_status WHERE variable_name = 'innodb_instant_alter_column'; instants -32 +33 diff --git a/mysql-test/suite/innodb/t/instant_alter_debug.test b/mysql-test/suite/innodb/t/instant_alter_debug.test index b93b9dd8f1b..10f7546cc36 100644 --- a/mysql-test/suite/innodb/t/instant_alter_debug.test +++ b/mysql-test/suite/innodb/t/instant_alter_debug.test @@ -512,6 +512,32 @@ SET GLOBAL innodb_limit_optimistic_insert_debug=@save_limit; SELECT * FROM t1; DROP TABLE t1; +--echo # +--echo # MDEV-25236 Online log apply fails for ROW_FORMAT=REDUNDANT tables +--echo # + +CREATE TABLE t1 +(a INT NOT NULL, b INT, c INT, d INT, e INT, f INT, g INT, h INT, i TEXT) +ENGINE=InnoDB; + +ALTER TABLE t1 MODIFY a INT NULL; + +SET DEBUG_SYNC='innodb_inplace_alter_table_enter SIGNAL alter WAIT_FOR go'; +send ALTER TABLE t1 ADD PRIMARY KEY (a); +connect(con1,localhost,root,,); +set DEBUG_SYNC='now WAIT_FOR alter'; +BEGIN; +INSERT INTO t1 SET a=0, i=REPEAT('1', 10000); +ROLLBACK; +set DEBUG_SYNC='now SIGNAL go'; +connection default; +reap; + +disconnect con1; +SELECT * FROM t1; +DROP TABLE t1; +SET DEBUG_SYNC=RESET; + --echo # End of 10.4 tests SET GLOBAL innodb_purge_rseg_truncate_frequency = @save_frequency; diff --git a/storage/innobase/rem/rem0rec.cc b/storage/innobase/rem/rem0rec.cc index 581637be073..08682304410 100644 --- a/storage/innobase/rem/rem0rec.cc +++ b/storage/innobase/rem/rem0rec.cc @@ -248,6 +248,8 @@ enum rec_leaf_format { in ROW_FORMAT=COMPACT,DYNAMIC,COMPRESSED. This is a special case of rec_init_offsets() and rec_get_offsets_func(). @tparam mblob whether the record includes a metadata BLOB +@tparam redundant_temp whether the record belongs to a temporary file + of a ROW_FORMAT=REDUNDANT table @param[in] rec leaf-page record @param[in] index the index that the record belongs in @param[in] n_core number of core fields (index->n_core_fields) @@ -255,7 +257,7 @@ This is a special case of rec_init_offsets() and rec_get_offsets_func(). NULL to refer to index->fields[].col->def_val @param[in,out] offsets offsets, with valid rec_offs_n_fields(offsets) @param[in] format record format */ -template +template static inline void rec_init_offsets_comp_ordinary( @@ -286,7 +288,9 @@ rec_init_offsets_comp_ordinary( const unsigned n_core_null_bytes = UNIV_UNLIKELY(index->n_core_fields != n_core) ? UT_BITS_IN_BYTES(unsigned(index->get_n_nullable(n_core))) - : index->n_core_null_bytes; + : (redundant_temp + ? UT_BITS_IN_BYTES(index->n_nullable) + : index->n_core_null_bytes); if (mblob) { ut_ad(index->is_dummy || index->table->instant); @@ -1109,8 +1113,8 @@ rec_get_nth_field_offs_old( } /** Determine the size of a data tuple prefix in ROW_FORMAT=COMPACT. -@tparam mblob whether the record includes a metadata BLOB -@tparam redundant_temp whether to use the ROW_FORMAT=REDUNDANT format +@tparam mblob whether the record includes a metadata BLOB +@tparam redundant_temp whether to use the ROW_FORMAT=REDUNDANT format @param[in] index record descriptor; dict_table_is_comp() is assumed to hold, even if it doesn't @param[in] dfield array of data fields @@ -1157,7 +1161,9 @@ rec_get_converted_size_comp_prefix_low( - n_core_fields); } else { ut_ad(n_fields <= n_core_fields); - extra_size += index->n_core_null_bytes; + extra_size += redundant_temp + ? UT_BITS_IN_BYTES(index->n_nullable) + : index->n_core_null_bytes; } ulint data_size = 0; @@ -1837,10 +1843,19 @@ rec_init_offsets_temp( if it was emptied during an ALTER TABLE operation. */ ut_ad(index->n_core_fields == n_core || !index->is_instant()); ut_ad(index->n_core_fields >= n_core); - rec_init_offsets_comp_ordinary(rec, index, offsets, n_core, def_val, - status == REC_STATUS_INSTANT - ? REC_LEAF_TEMP_INSTANT - : REC_LEAF_TEMP); + if (index->table->not_redundant()) { + rec_init_offsets_comp_ordinary( + rec, index, offsets, n_core, def_val, + status == REC_STATUS_INSTANT + ? REC_LEAF_TEMP_INSTANT + : REC_LEAF_TEMP); + } else { + rec_init_offsets_comp_ordinary( + rec, index, offsets, n_core, def_val, + status == REC_STATUS_INSTANT + ? REC_LEAF_TEMP_INSTANT + : REC_LEAF_TEMP); + } } /** Determine the offset to each field in temporary file. @@ -1855,9 +1870,15 @@ rec_init_offsets_temp( rec_offs* offsets) { ut_ad(!index->is_instant()); - rec_init_offsets_comp_ordinary(rec, index, offsets, - index->n_core_fields, NULL, - REC_LEAF_TEMP); + if (index->table->not_redundant()) { + rec_init_offsets_comp_ordinary( + rec, index, offsets, + index->n_core_fields, NULL, REC_LEAF_TEMP); + } else { + rec_init_offsets_comp_ordinary( + rec, index, offsets, + index->n_core_fields, NULL, REC_LEAF_TEMP); + } } /** Convert a data tuple prefix to the temporary file format. From 779262842edf86c989c099c6930ae4683cbde609 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 30 Jun 2021 01:03:49 +0200 Subject: [PATCH 238/251] MDEV-23004 When using GROUP BY with JSON_ARRAYAGG with joint table, the square brackets are not included make test results stable followup for 98c7916f0f2 --- mysql-test/main/func_json.result | 2 +- mysql-test/main/func_json.test | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/main/func_json.result b/mysql-test/main/func_json.result index 0c242a886b7..4ad7efea8af 100644 --- a/mysql-test/main/func_json.result +++ b/mysql-test/main/func_json.result @@ -1372,7 +1372,7 @@ CREATE TABLE t1(id int primary key, name varchar(50)); CREATE TABLE t2(id int, owner_id int); INSERT INTO t1 VALUES (1, "name1"), (2, "name2"), (3, "name3"); INSERT INTO t2 VALUES (1, 1), (2, 1), (3, 2), (4, 3); -SELECT t1.id, JSON_ARRAYAGG(JSON_OBJECT('id',t2.id)) as materials +SELECT t1.id, JSON_ARRAYAGG(JSON_OBJECT('id',t2.id) ORDER BY t2.id) as materials from t1 LEFT JOIN t2 on t1.id = t2.owner_id GROUP BY t1.id ORDER BY id; id materials diff --git a/mysql-test/main/func_json.test b/mysql-test/main/func_json.test index f08a72a5bce..d598809adf5 100644 --- a/mysql-test/main/func_json.test +++ b/mysql-test/main/func_json.test @@ -866,7 +866,7 @@ CREATE TABLE t2(id int, owner_id int); INSERT INTO t1 VALUES (1, "name1"), (2, "name2"), (3, "name3"); INSERT INTO t2 VALUES (1, 1), (2, 1), (3, 2), (4, 3); -SELECT t1.id, JSON_ARRAYAGG(JSON_OBJECT('id',t2.id)) as materials +SELECT t1.id, JSON_ARRAYAGG(JSON_OBJECT('id',t2.id) ORDER BY t2.id) as materials from t1 LEFT JOIN t2 on t1.id = t2.owner_id GROUP BY t1.id ORDER BY id; From b5f50e2de8dd8f43f0975a3a913d808a54e87c8d Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 1 Jul 2021 13:33:38 +0200 Subject: [PATCH 239/251] errors after altering a table has finished aren't fatal We cannot revert the ALTER, so anything happening after the point of no return should not be treated as an error. A very unfortunate condition that a user needs to be warned about - yes, but we cannot say "ALTER TABLE has failed" if the table was successfully altered. --- mysql-test/suite/s3/alter.result | 4 ++- mysql-test/suite/s3/alter.test | 1 - sql/sql_class.h | 19 ++++++++++++ sql/sql_table.cc | 50 +++++++++++--------------------- sql/table.cc | 19 ------------ 5 files changed, 39 insertions(+), 54 deletions(-) diff --git a/mysql-test/suite/s3/alter.result b/mysql-test/suite/s3/alter.result index da9ddb11ea7..c6f79e8b0f9 100644 --- a/mysql-test/suite/s3/alter.result +++ b/mysql-test/suite/s3/alter.result @@ -102,7 +102,9 @@ drop table t1; create table t1 (a int, b int) engine=aria select seq as a,seq+10 as b from seq_1_to_10; lock table t1 write; alter table t1 add column c int, engine=s3; -ERROR HY000: Table 't1' is read only +Warnings: +Warning 1036 Table 't1' is read only +Warning 1213 Deadlock found when trying to get lock; try restarting transaction unlock tables; select count(*), sum(a), sum(b), sum(c) from t1; count(*) sum(a) sum(b) sum(c) diff --git a/mysql-test/suite/s3/alter.test b/mysql-test/suite/s3/alter.test index 4504804c91a..7882d14e7b4 100644 --- a/mysql-test/suite/s3/alter.test +++ b/mysql-test/suite/s3/alter.test @@ -69,7 +69,6 @@ drop table t1; create table t1 (a int, b int) engine=aria select seq as a,seq+10 as b from seq_1_to_10; lock table t1 write; ---error ER_OPEN_AS_READONLY alter table t1 add column c int, engine=s3; unlock tables; select count(*), sum(a), sum(b), sum(c) from t1; diff --git a/sql/sql_class.h b/sql/sql_class.h index 713523b7d75..548fef3f67b 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -2015,6 +2015,25 @@ private: }; +class Turn_errors_to_warnings_handler : public Internal_error_handler +{ +public: + Turn_errors_to_warnings_handler() {} + bool handle_condition(THD *thd, + uint sql_errno, + const char* sqlstate, + Sql_condition::enum_warning_level *level, + const char* msg, + Sql_condition ** cond_hdl) + { + *cond_hdl= NULL; + if (*level == Sql_condition::WARN_LEVEL_ERROR) + *level= Sql_condition::WARN_LEVEL_WARN; + return(0); + } +}; + + /** Tables that were locked with LOCK TABLES statement. diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 9610e795f7a..88fe883c2a4 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -9286,10 +9286,11 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db, uint order_num, ORDER *order, bool ignore, bool if_exists) { - bool engine_changed, error, frm_is_created= false; + bool engine_changed, error, frm_is_created= false, error_handler_pushed= false; bool no_ha_table= true; /* We have not created table in storage engine yet */ TABLE *table, *new_table; DDL_LOG_STATE ddl_log_state; + Turn_errors_to_warnings_handler errors_to_warnings; #ifdef WITH_PARTITION_STORAGE_ENGINE bool partition_changed= false; @@ -10610,19 +10611,21 @@ do_continue:; } // ALTER TABLE succeeded, delete the backup of the old table. - error= quick_rm_table(thd, old_db_type, &alter_ctx.db, &backup_name, - FN_IS_TMP | - (engine_changed ? NO_HA_TABLE | NO_PAR_TABLE: 0)); + // a failure to delete isn't an error, as we cannot rollback ALTER anymore + thd->push_internal_handler(&errors_to_warnings); + error_handler_pushed=1; + + quick_rm_table(thd, old_db_type, &alter_ctx.db, &backup_name, + FN_IS_TMP | (engine_changed ? NO_HA_TABLE | NO_PAR_TABLE: 0)); debug_crash_here("ddl_log_alter_after_delete_backup"); if (engine_changed) { /* the .frm file was removed but not the original table */ - error|= quick_rm_table(thd, old_db_type, &alter_ctx.db, - &alter_ctx.table_name, - NO_FRM_RENAME | - (engine_changed ? 0 : FN_IS_TMP)); + quick_rm_table(thd, old_db_type, &alter_ctx.db, &alter_ctx.table_name, + NO_FRM_RENAME | (engine_changed ? 0 : FN_IS_TMP)); } + debug_crash_here("ddl_log_alter_after_drop_original_table"); if (binlog_as_create_select) { @@ -10637,21 +10640,15 @@ do_continue:; thd->binlog_xid= 0; } - if (error) - { - /* - The fact that deletion of the backup failed is not critical - error, but still worth reporting as it might indicate serious - problem with server. - */ - goto err_with_mdl_after_alter; - } - end_inplace: thd->variables.option_bits&= ~OPTION_BIN_COMMIT_OFF; - if (thd->locked_tables_list.reopen_tables(thd, false)) - goto err_with_mdl_after_alter; + if (!error_handler_pushed) + thd->push_internal_handler(&errors_to_warnings); + + thd->locked_tables_list.reopen_tables(thd, false); + + thd->pop_internal_handler(); THD_STAGE_INFO(thd, stage_end); DEBUG_SYNC(thd, "alter_table_before_main_binlog"); @@ -10763,19 +10760,6 @@ err_cleanup: } DBUG_RETURN(true); -err_with_mdl_after_alter: - DBUG_PRINT("error", ("err_with_mdl_after_alter")); - /* the table was altered. binlog the operation */ - DBUG_ASSERT(!(mysql_bin_log.is_open() && - thd->is_current_stmt_binlog_format_row() && - (create_info->tmp_table()))); - /* - We can't reset error as we will return 'true' below and the server - expects that error is set - */ - if (!binlog_as_create_select) - write_bin_log_with_if_exists(thd, FALSE, FALSE, log_if_exists); - err_with_mdl: ddl_log_complete(&ddl_log_state); /* diff --git a/sql/table.cc b/sql/table.cc index 73d701e0b2b..071a0ef1f1f 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -8574,25 +8574,6 @@ bool is_simple_order(ORDER *order) return TRUE; } -class Turn_errors_to_warnings_handler : public Internal_error_handler -{ -public: - Turn_errors_to_warnings_handler() {} - bool handle_condition(THD *thd, - uint sql_errno, - const char* sqlstate, - Sql_condition::enum_warning_level *level, - const char* msg, - Sql_condition ** cond_hdl) - { - *cond_hdl= NULL; - if (*level == Sql_condition::WARN_LEVEL_ERROR) - *level= Sql_condition::WARN_LEVEL_WARN; - return(0); - } -}; - - /* to satisfy marked_for_write_or_computed() Field's assert we temporarily mark field for write before storing the generated value in it From 164a64baa3beb84e7a2c431cd136e22c9e3dbf81 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 2 Jul 2021 00:05:27 +0200 Subject: [PATCH 240/251] MDEV-15888 Implement FLUSH TABLES tbl_name [, tbl_name] ... WITH READ LOCK for views. privilege checks for tables flushed via views --- mysql-test/main/flush_notembedded.result | 28 +++++++++++++++++++++ mysql-test/main/flush_notembedded.test | 32 ++++++++++++++++++++++++ sql/privilege.h | 1 + sql/sql_parse.cc | 2 -- sql/sql_reload.cc | 26 +++++++++---------- 5 files changed, 74 insertions(+), 15 deletions(-) create mode 100644 mysql-test/main/flush_notembedded.result create mode 100644 mysql-test/main/flush_notembedded.test diff --git a/mysql-test/main/flush_notembedded.result b/mysql-test/main/flush_notembedded.result new file mode 100644 index 00000000000..2790b9145a1 --- /dev/null +++ b/mysql-test/main/flush_notembedded.result @@ -0,0 +1,28 @@ +# +# MDEV-15888 Implement FLUSH TABLES tbl_name [, tbl_name] ... WITH READ LOCK for views. +# +# +# privilege checks with views +# +create database mysqltest1; +create table mysqltest1.t1 (a int); +create user u1@localhost; +grant reload on *.* to u1@localhost; +grant select on mysqltest1.* to u1@localhost; +connect u1,localhost,u1; +flush tables mysqltest1.t1 for export; +ERROR 42000: Access denied for user 'u1'@'localhost' to database 'mysqltest1' +create view v as select * from mysqltest1.t1; +create view v2 as select * from v; +flush tables v for export; +ERROR 42000: Access denied for user 'u1'@'localhost' to database 'mysqltest1' +flush tables v2 for export; +ERROR 42000: Access denied for user 'u1'@'localhost' to database 'mysqltest1' +disconnect u1; +connection default; +drop database mysqltest1; +drop view v, v2; +drop user u1@localhost; +# +# End of 10.6 tests +# diff --git a/mysql-test/main/flush_notembedded.test b/mysql-test/main/flush_notembedded.test new file mode 100644 index 00000000000..233e1e5d958 --- /dev/null +++ b/mysql-test/main/flush_notembedded.test @@ -0,0 +1,32 @@ +source include/not_embedded.inc; + +--echo # +--echo # MDEV-15888 Implement FLUSH TABLES tbl_name [, tbl_name] ... WITH READ LOCK for views. +--echo # + +--echo # +--echo # privilege checks with views +--echo # +create database mysqltest1; +create table mysqltest1.t1 (a int); +create user u1@localhost; +grant reload on *.* to u1@localhost; +grant select on mysqltest1.* to u1@localhost; +connect u1,localhost,u1; +error ER_DBACCESS_DENIED_ERROR; +flush tables mysqltest1.t1 for export; +create view v as select * from mysqltest1.t1; +create view v2 as select * from v; +error ER_DBACCESS_DENIED_ERROR; +flush tables v for export; +error ER_DBACCESS_DENIED_ERROR; +flush tables v2 for export; +disconnect u1; +connection default; +drop database mysqltest1; +drop view v, v2; +drop user u1@localhost; + +--echo # +--echo # End of 10.6 tests +--echo # diff --git a/sql/privilege.h b/sql/privilege.h index 3e4c2526c6c..c1233102522 100644 --- a/sql/privilege.h +++ b/sql/privilege.h @@ -296,6 +296,7 @@ constexpr privilege_t TMP_TABLE_ACLS= COL_DML_ACLS | ALL_TABLE_DDL_ACLS; +constexpr privilege_t PRIV_LOCK_TABLES= SELECT_ACL | LOCK_TABLES_ACL; /* Allow to set an object definer: diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 8307cd0ed4d..2c6df6dbb03 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -98,8 +98,6 @@ #include "my_json_writer.h" -#define PRIV_LOCK_TABLES (SELECT_ACL | LOCK_TABLES_ACL) - #define FLAGSTR(V,F) ((V)&(F)?#F" ":"") #ifdef WITH_ARIA_STORAGE_ENGINE diff --git a/sql/sql_reload.cc b/sql/sql_reload.cc index 0fa2fa10df8..64544e42d30 100644 --- a/sql/sql_reload.cc +++ b/sql/sql_reload.cc @@ -24,6 +24,7 @@ #include "sql_connect.h" // reset_mqh #include "thread_cache.h" #include "sql_base.h" // close_cached_tables +#include "sql_parse.h" // check_single_table_access #include "sql_db.h" // my_dbopt_cleanup #include "hostname.h" // hostname_cache_refresh #include "sql_repl.h" // reset_master, reset_slave @@ -586,28 +587,27 @@ bool flush_tables_with_read_lock(THD *thd, TABLE_LIST *all_tables) &lock_tables_prelocking_strategy)) goto error_reset_bits; - if (thd->lex->type & REFRESH_FOR_EXPORT) + if (thd->lex->type & (REFRESH_FOR_EXPORT|REFRESH_READ_LOCK)) { - // Check if all storage engines support FOR EXPORT. for (TABLE_LIST *table_list= all_tables; table_list; table_list= table_list->next_global) { - if (!(table_list->is_view() || - table_list->table->file->ha_table_flags() & HA_CAN_EXPORT)) + if (table_list->belong_to_view && + check_single_table_access(thd, PRIV_LOCK_TABLES, table_list, FALSE)) + { + table_list->hide_view_error(thd); + goto error_reset_bits; + } + if (table_list->is_view()) + continue; + if (thd->lex->type & REFRESH_FOR_EXPORT && + !(table_list->table->file->ha_table_flags() & HA_CAN_EXPORT)) { my_error(ER_ILLEGAL_HA, MYF(0),table_list->table->file->table_type(), table_list->db.str, table_list->table_name.str); goto error_reset_bits; } - } - } - - if (thd->lex->type & REFRESH_READ_LOCK) - { - for (auto table_list= all_tables; table_list; - table_list= table_list->next_global) - { - if (!table_list->is_view() && + if (thd->lex->type & REFRESH_READ_LOCK && table_list->table->file->extra(HA_EXTRA_FLUSH)) goto error_reset_bits; } From 4145ebf99a5f88fd4836dbb931a2f87c90b88a5e Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 2 Jul 2021 00:26:04 +0200 Subject: [PATCH 241/251] MDEV-25906: SIGSEGV in flush_tables_with_read_lock on FTWRL or FTFE | SIGSEGV in ha_maria::extra --- mysql-test/main/flush.result | 34 +++++++++++++++++++ mysql-test/main/flush.test | 38 +++++++++++++++++++++ mysql-test/main/flush_notembedded.result | 42 +++++++++++++++++++++++- mysql-test/main/flush_notembedded.test | 36 +++++++++++++++++++- sql/sql_reload.cc | 2 +- 5 files changed, 149 insertions(+), 3 deletions(-) diff --git a/mysql-test/main/flush.result b/mysql-test/main/flush.result index c73125e3420..584e79e72db 100644 --- a/mysql-test/main/flush.result +++ b/mysql-test/main/flush.result @@ -626,3 +626,37 @@ show status like "Threads_cached"; Variable_name Value Threads_cached 0 set @@global.thread_cache_size=@save_thread_cache_size; +# +# MDEV-25906: SIGSEGV in flush_tables_with_read_lock on FTWRL or FTFE | SIGSEGV in ha_maria::extra +# +CREATE VIEW v0 AS SELECT 1; +CREATE VIEW v1 AS SELECT 1 FROM (SELECT 1) AS d; +CREATE VIEW v2 AS SELECT * FROM v1; +FLUSH TABLE v0 WITH READ LOCK; +DROP VIEW v0; +ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction +UNLOCK TABLES; +FLUSH TABLE v1 WITH READ LOCK; +DROP VIEW v1; +ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction +UNLOCK TABLES; +FLUSH TABLE v2 WITH READ LOCK; +DROP VIEW v2; +ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction +UNLOCK TABLES; +FLUSH TABLE v0 FOR EXPORT; +DROP VIEW v0; +ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction +UNLOCK TABLES; +FLUSH TABLE v1 FOR EXPORT; +DROP VIEW v1; +ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction +UNLOCK TABLES; +FLUSH TABLE v2 FOR EXPORT; +DROP VIEW v2; +ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction +UNLOCK TABLES; +DROP VIEW v2, v1, v0; +# +# End of 10.6 tests +# diff --git a/mysql-test/main/flush.test b/mysql-test/main/flush.test index f546b6f1fca..d31c7591cbf 100644 --- a/mysql-test/main/flush.test +++ b/mysql-test/main/flush.test @@ -745,3 +745,41 @@ set @@global.thread_cache_size=0; flush threads; show status like "Threads_cached"; set @@global.thread_cache_size=@save_thread_cache_size; + +--echo # +--echo # MDEV-25906: SIGSEGV in flush_tables_with_read_lock on FTWRL or FTFE | SIGSEGV in ha_maria::extra +--echo # +CREATE VIEW v0 AS SELECT 1; +CREATE VIEW v1 AS SELECT 1 FROM (SELECT 1) AS d; +CREATE VIEW v2 AS SELECT * FROM v1; + +FLUSH TABLE v0 WITH READ LOCK; +--error ER_LOCK_OR_ACTIVE_TRANSACTION +DROP VIEW v0; +UNLOCK TABLES; +FLUSH TABLE v1 WITH READ LOCK; +--error ER_LOCK_OR_ACTIVE_TRANSACTION +DROP VIEW v1; +UNLOCK TABLES; +FLUSH TABLE v2 WITH READ LOCK; +--error ER_LOCK_OR_ACTIVE_TRANSACTION +DROP VIEW v2; +UNLOCK TABLES; + +FLUSH TABLE v0 FOR EXPORT; +--error ER_LOCK_OR_ACTIVE_TRANSACTION +DROP VIEW v0; +UNLOCK TABLES; +FLUSH TABLE v1 FOR EXPORT; +--error ER_LOCK_OR_ACTIVE_TRANSACTION +DROP VIEW v1; +UNLOCK TABLES; +FLUSH TABLE v2 FOR EXPORT; +--error ER_LOCK_OR_ACTIVE_TRANSACTION +DROP VIEW v2; +UNLOCK TABLES; +DROP VIEW v2, v1, v0; + +--echo # +--echo # End of 10.6 tests +--echo # diff --git a/mysql-test/main/flush_notembedded.result b/mysql-test/main/flush_notembedded.result index 2790b9145a1..f4c83ff2361 100644 --- a/mysql-test/main/flush_notembedded.result +++ b/mysql-test/main/flush_notembedded.result @@ -14,15 +14,55 @@ flush tables mysqltest1.t1 for export; ERROR 42000: Access denied for user 'u1'@'localhost' to database 'mysqltest1' create view v as select * from mysqltest1.t1; create view v2 as select * from v; +create view v3 as select * from (select * from mysqltest1.t1) x; flush tables v for export; ERROR 42000: Access denied for user 'u1'@'localhost' to database 'mysqltest1' flush tables v2 for export; ERROR 42000: Access denied for user 'u1'@'localhost' to database 'mysqltest1' +flush tables v3 for export; +ERROR 42000: Access denied for user 'u1'@'localhost' to database 'mysqltest1' disconnect u1; connection default; drop database mysqltest1; -drop view v, v2; +drop view v, v2, v3; drop user u1@localhost; # +# MDEV-25906: SIGSEGV in flush_tables_with_read_lock on FTWRL or FTFE | SIGSEGV in ha_maria::extra +# +CREATE VIEW v0 AS SELECT * FROM information_schema.columns; +CREATE VIEW v1 AS SELECT * FROM information_schema.collations; +CREATE VIEW v2 AS SELECT * FROM performance_schema.accounts; +# +# first try to flush tables directly +# +FLUSH TABLE information_schema.collations WITH READ LOCK; +ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema' +FLUSH TABLE performance_schema.accounts WITH READ LOCK; +ERROR 42000: SELECT, LOCK TABLES command denied to user 'root'@'localhost' for table 'accounts' +FLUSH TABLE information_schema.colums WITH READ LOCK; +ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema' +FLUSH TABLE information_schema.collations FOR EXPORT; +ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema' +FLUSH TABLE performance_schema.accounts FOR EXPORT; +ERROR 42000: SELECT, LOCK TABLES command denied to user 'root'@'localhost' for table 'accounts' +FLUSH TABLE information_schema.colums FOR EXPORT; +ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema' +# +# and now via views +# +FLUSH TABLE v0 WITH READ LOCK; +ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema' +FLUSH TABLE v1 WITH READ LOCK; +ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema' +FLUSH TABLE v2 WITH READ LOCK; +ERROR HY000: View 'test.v2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +FLUSH TABLE v0 FOR EXPORT; +ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema' +FLUSH TABLE v1 FOR EXPORT; +ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema' +FLUSH TABLE v2 FOR EXPORT; +ERROR HY000: View 'test.v2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +DROP VIEW v0, v1, v2; +# # End of 10.6 tests # diff --git a/mysql-test/main/flush_notembedded.test b/mysql-test/main/flush_notembedded.test index 233e1e5d958..af3b8a00c55 100644 --- a/mysql-test/main/flush_notembedded.test +++ b/mysql-test/main/flush_notembedded.test @@ -1,4 +1,5 @@ source include/not_embedded.inc; +source include/have_perfschema.inc; --echo # --echo # MDEV-15888 Implement FLUSH TABLES tbl_name [, tbl_name] ... WITH READ LOCK for views. @@ -17,16 +18,49 @@ error ER_DBACCESS_DENIED_ERROR; flush tables mysqltest1.t1 for export; create view v as select * from mysqltest1.t1; create view v2 as select * from v; +create view v3 as select * from (select * from mysqltest1.t1) x; error ER_DBACCESS_DENIED_ERROR; flush tables v for export; error ER_DBACCESS_DENIED_ERROR; flush tables v2 for export; +error ER_DBACCESS_DENIED_ERROR; +flush tables v3 for export; disconnect u1; connection default; drop database mysqltest1; -drop view v, v2; +drop view v, v2, v3; drop user u1@localhost; +--echo # +--echo # MDEV-25906: SIGSEGV in flush_tables_with_read_lock on FTWRL or FTFE | SIGSEGV in ha_maria::extra +--echo # +CREATE VIEW v0 AS SELECT * FROM information_schema.columns; # Aria +CREATE VIEW v1 AS SELECT * FROM information_schema.collations; # Heap +CREATE VIEW v2 AS SELECT * FROM performance_schema.accounts; + +--disable_abort_on_error +--echo # +--echo # first try to flush tables directly +--echo # +FLUSH TABLE information_schema.collations WITH READ LOCK; +FLUSH TABLE performance_schema.accounts WITH READ LOCK; +FLUSH TABLE information_schema.colums WITH READ LOCK; +FLUSH TABLE information_schema.collations FOR EXPORT; +FLUSH TABLE performance_schema.accounts FOR EXPORT; +FLUSH TABLE information_schema.colums FOR EXPORT; + +--echo # +--echo # and now via views +--echo # +FLUSH TABLE v0 WITH READ LOCK; +FLUSH TABLE v1 WITH READ LOCK; +FLUSH TABLE v2 WITH READ LOCK; +FLUSH TABLE v0 FOR EXPORT; +FLUSH TABLE v1 FOR EXPORT; +FLUSH TABLE v2 FOR EXPORT; +--enable_abort_on_error +DROP VIEW v0, v1, v2; + --echo # --echo # End of 10.6 tests --echo # diff --git a/sql/sql_reload.cc b/sql/sql_reload.cc index 64544e42d30..ddada6ad892 100644 --- a/sql/sql_reload.cc +++ b/sql/sql_reload.cc @@ -598,7 +598,7 @@ bool flush_tables_with_read_lock(THD *thd, TABLE_LIST *all_tables) table_list->hide_view_error(thd); goto error_reset_bits; } - if (table_list->is_view()) + if (table_list->is_view_or_derived()) continue; if (thd->lex->type & REFRESH_FOR_EXPORT && !(table_list->table->file->ha_table_flags() & HA_CAN_EXPORT)) From 59bc063d26b2d2013f1d21ec8d16554ab44281f3 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 2 Jul 2021 08:26:32 +0200 Subject: [PATCH 242/251] main.lock_kill fails in embedded when killing a query in a parallel connection, disable warnings. Because --error doesn't apply to automatically sent SHOW WARNINGS, so if KILL arrives at the right moment the test will fail with mysqltest: At line 41: Error running query "SHOW WARNINGS": Server has gone away --- mysql-test/main/lock_kill.test | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mysql-test/main/lock_kill.test b/mysql-test/main/lock_kill.test index 2c1396e5ff3..5cf67fd3bc8 100644 --- a/mysql-test/main/lock_kill.test +++ b/mysql-test/main/lock_kill.test @@ -17,8 +17,10 @@ LOCK TABLE t1 WRITE; eval KILL $conid; --enable_query_log --connection con1 +--disable_warnings --error 0,2006,2013,ER_CONNECTION_KILLED reap; +--enable_warnings --connection default --disconnect con1 DROP TABLE t1; @@ -35,8 +37,10 @@ LOCK TABLE t1 WRITE, t2 WRITE; eval KILL $conid; --enable_query_log --connection con1 +--disable_warnings --error 0,2006,2013,ER_CONNECTION_KILLED reap; +--enable_warnings --connection default --disconnect con1 DROP TABLE t1, t2; From 028d611832025be1b6b73902e6075a40fe88e134 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 2 Jul 2021 20:36:37 +0200 Subject: [PATCH 243/251] update test result followup for bfedf1eb4b6 --- mysql-test/suite/galera/r/galera_sst_rsync_logbasename.result | 1 - 1 file changed, 1 deletion(-) diff --git a/mysql-test/suite/galera/r/galera_sst_rsync_logbasename.result b/mysql-test/suite/galera/r/galera_sst_rsync_logbasename.result index dabbaeaab4f..9b56a09d369 100644 --- a/mysql-test/suite/galera/r/galera_sst_rsync_logbasename.result +++ b/mysql-test/suite/galera/r/galera_sst_rsync_logbasename.result @@ -172,4 +172,3 @@ COUNT(*) = 0 1 DROP TABLE t1; COMMIT; -SET AUTOCOMMIT=ON; From 9ec3cd9af0d0667c7751be7779452214a4e4ce0c Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 2 Jul 2021 23:52:55 +0200 Subject: [PATCH 244/251] gamma -> stable --- VERSION | 2 +- mysql-test/suite/sys_vars/r/sysvars_star.result | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 46c8d25fe95..820984bb644 100644 --- a/VERSION +++ b/VERSION @@ -1,4 +1,4 @@ MYSQL_VERSION_MAJOR=10 MYSQL_VERSION_MINOR=6 MYSQL_VERSION_PATCH=3 -SERVER_MATURITY=gamma +SERVER_MATURITY=stable diff --git a/mysql-test/suite/sys_vars/r/sysvars_star.result b/mysql-test/suite/sys_vars/r/sysvars_star.result index 54af0aa3014..eede5c17b36 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_star.result +++ b/mysql-test/suite/sys_vars/r/sysvars_star.result @@ -60,7 +60,7 @@ VARIABLE_NAME PLUGIN_MATURITY SESSION_VALUE NULL GLOBAL_VALUE alpha GLOBAL_VALUE_ORIGIN CONFIG -DEFAULT_VALUE beta +DEFAULT_VALUE gamma VARIABLE_SCOPE GLOBAL VARIABLE_TYPE ENUM VARIABLE_COMMENT The lowest desirable plugin maturity. Plugins less mature than that will not be installed or loaded From bd5a6403cace36c6ed428cde62e35adcd3f7e7d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Sat, 3 Jul 2021 13:58:38 +0300 Subject: [PATCH 245/251] MDEV-26033: Race condition between buf_pool.page_hash and resize() The replacement of buf_pool.page_hash with a different type of hash table in commit 5155a300fab85e97217c75e3ba3c3ce78082dd8a (MDEV-22871) introduced a race condition with buffer pool resizing. We have an execution trace where buf_pool.page_hash.array is changed to point to something else while page_hash_latch::read_lock() is executing. The same should also affect page_hash_latch::write_lock(). We fix the race condition by never resizing (and reallocating) the buf_pool.page_hash. We assume that resizing the buffer pool is a rare operation. Yes, there might be a performance regression if a server is first started up with a tiny buffer pool, which is later enlarged. In that case, the tiny buf_pool.page_hash.array could cause increased use of the hash bucket lists. That problem can be worked around by initially starting up the server with a larger buffer pool and then shrinking that, until changing to a larger size again. buf_pool_t::resize_hash(): Remove. buf_pool_t::page_hash_table::lock(): Do not attempt to deal with hash table resizing. If we really wanted that in a safe manner, we would probably have to introduce a global rw-lock around the operation, or at the very least, poll buf_pool.resizing, both of which would be detrimental to performance. --- storage/innobase/buf/buf0buf.cc | 90 +----------------------------- storage/innobase/include/buf0buf.h | 29 ++-------- 2 files changed, 6 insertions(+), 113 deletions(-) diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index bbbb67a69df..dcf95fdd5f2 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -1536,13 +1536,6 @@ void buf_pool_t::close() ut_free(chunks); chunks= nullptr; page_hash.free(); - while (page_hash_table *old_page_hash= freed_page_hash) - { - freed_page_hash= static_cast - (old_page_hash->array[1].node); - old_page_hash->free(); - UT_DELETE(old_page_hash); - } zip_hash.free(); io_buf.close(); @@ -1829,57 +1822,6 @@ inline bool buf_pool_t::withdraw_blocks() return(false); } -/** resize page_hash and zip_hash */ -inline void buf_pool_t::resize_hash() -{ - page_hash_table *new_page_hash= UT_NEW_NOKEY(page_hash_table()); - new_page_hash->create(2 * buf_pool.curr_size); - new_page_hash->write_lock_all(); - - for (auto i= page_hash.pad(page_hash.n_cells); i--; ) - { - static_assert(!((page_hash_table::ELEMENTS_PER_LATCH + 1) & - page_hash_table::ELEMENTS_PER_LATCH), - "must be one less than a power of 2"); - if (!(i & page_hash_table::ELEMENTS_PER_LATCH)) - { - ut_ad(reinterpret_cast - (&page_hash.array[i])->is_write_locked()); - continue; - } - while (buf_page_t *bpage= static_cast - (page_hash.array[i].node)) - { - ut_ad(bpage->in_page_hash); - const ulint fold= bpage->id().fold(); - HASH_DELETE(buf_page_t, hash, &buf_pool.page_hash, fold, bpage); - HASH_INSERT(buf_page_t, hash, new_page_hash, fold, bpage); - } - } - - buf_pool.page_hash.array[1].node= freed_page_hash; - std::swap(buf_pool.page_hash, *new_page_hash); - freed_page_hash= new_page_hash; - - /* recreate zip_hash */ - hash_table_t new_hash; - new_hash.create(2 * buf_pool.curr_size); - - for (ulint i= 0; i < buf_pool.zip_hash.n_cells; i++) - { - while (buf_page_t *bpage= static_cast - (HASH_GET_FIRST(&buf_pool.zip_hash, i))) - { - const ulint fold= BUF_POOL_ZIP_FOLD_BPAGE(bpage); - HASH_DELETE(buf_page_t, hash, &buf_pool.zip_hash, fold, bpage); - HASH_INSERT(buf_page_t, hash, &new_hash, fold, bpage); - } - } - - std::swap(buf_pool.zip_hash.array, new_hash.array); - buf_pool.zip_hash.n_cells= new_hash.n_cells; - new_hash.free(); -} inline void buf_pool_t::page_hash_table::write_lock_all() @@ -1904,26 +1846,6 @@ inline void buf_pool_t::page_hash_table::write_unlock_all() } -inline void buf_pool_t::write_lock_all_page_hash() -{ - mysql_mutex_assert_owner(&mutex); - page_hash.write_lock_all(); - for (page_hash_table *old_page_hash= freed_page_hash; old_page_hash; - old_page_hash= static_cast - (old_page_hash->array[1].node)) - old_page_hash->write_lock_all(); -} - - -inline void buf_pool_t::write_unlock_all_page_hash() -{ - page_hash.write_unlock_all(); - for (page_hash_table *old_page_hash= freed_page_hash; old_page_hash; - old_page_hash= static_cast - (old_page_hash->array[1].node)) - old_page_hash->write_unlock_all(); -} - namespace { @@ -2097,7 +2019,7 @@ withdraw_retry: resizing.store(true, std::memory_order_relaxed); mysql_mutex_lock(&mutex); - write_lock_all_page_hash(); + page_hash.write_lock_all(); chunk_t::map_reg = UT_NEW_NOKEY(chunk_t::map()); @@ -2252,16 +2174,8 @@ calc_buf_pool_size: = srv_buf_pool_base_size > srv_buf_pool_size * 2 || srv_buf_pool_base_size * 2 < srv_buf_pool_size; - /* Normalize page_hash and zip_hash, - if the new size is too different */ - if (!warning && new_size_too_diff) { - buf_resize_status("Resizing hash table"); - resize_hash(); - ib::info() << "hash tables were resized"; - } - mysql_mutex_unlock(&mutex); - write_unlock_all_page_hash(); + page_hash.write_unlock_all(); UT_DELETE(chunk_map_old); diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h index e0e6c581442..5a118df48e1 100644 --- a/storage/innobase/include/buf0buf.h +++ b/storage/innobase/include/buf0buf.h @@ -1895,22 +1895,14 @@ public: page_hash_latch *lock_get(ulint fold) const { return lock_get(fold, n_cells); } - /** Acquire an array latch, tolerating concurrent buf_pool_t::resize() + /** Acquire an array latch. @tparam exclusive whether the latch is to be acquired exclusively @param fold hash bucket key */ template page_hash_latch *lock(ulint fold) { - for (;;) - { - auto n= n_cells; - page_hash_latch *latch= lock_get(fold, n); - latch->acquire(); - /* Our latch prevents n_cells from changing. */ - if (UNIV_LIKELY(n == n_cells)) - return latch; - /* Retry, because buf_pool_t::resize_hash() affected us. */ - latch->release(); - } + page_hash_latch *latch= lock_get(fold, n_cells); + latch->acquire(); + return latch; } /** Exclusively aqcuire all latches */ @@ -1920,19 +1912,6 @@ public: inline void write_unlock_all(); }; -private: - /** Former page_hash that has been deleted during resize(); - singly-linked list via freed_page_hash->array[1] */ - page_hash_table *freed_page_hash; - - /** Lock all page_hash, also freed_page_hash. */ - inline void write_lock_all_page_hash(); - /** Release all page_hash, also freed_page_hash. */ - inline void write_unlock_all_page_hash(); - /** Resize page_hash and zip_hash. */ - inline void resize_hash(); - -public: /** Hash table of file pages (buf_page_t::in_file() holds), indexed by page_id_t. Protected by both mutex and page_hash.lock_get(). */ page_hash_table page_hash; From f0f47cbca18232e279ec27c6fe843f475626cfec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Sat, 3 Jul 2021 14:52:04 +0300 Subject: [PATCH 246/251] MDEV-26017 fixup buf_flush_relocate_on_flush_list(): Use dpage->physical_size() because bpage->zip.ssize may already have been zeroed in page_zip_set_size() invoked by buf_pool_t::realloc(). This would cause occasional failures of the test innodb.innodb_buffer_pool_resize, which creates a ROW_FORMAT=COMPRESSED table. --- storage/innobase/buf/buf0flu.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc index e6999222447..1c425f308ef 100644 --- a/storage/innobase/buf/buf0flu.cc +++ b/storage/innobase/buf/buf0flu.cc @@ -302,7 +302,7 @@ buf_flush_relocate_on_flush_list( /* FIXME: Can we avoid holding buf_pool.mutex here? */ ut_ad(dpage->oldest_modification() == lsn); - if (const lsn_t o_lsn = bpage->oldest_modification()) { + if (ut_d(const lsn_t o_lsn =) bpage->oldest_modification()) { ut_ad(o_lsn == lsn); /* Important that we adjust the hazard pointer before removing @@ -321,7 +321,7 @@ buf_flush_relocate_on_flush_list( } if (lsn == 1) { - buf_pool.stat.flush_list_bytes -= bpage->physical_size(); + buf_pool.stat.flush_list_bytes -= dpage->physical_size(); was_clean: dpage->list.prev = nullptr; dpage->list.next = nullptr; From 789a2a363aa576af22fec412a6724140955978b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Sat, 3 Jul 2021 20:35:29 +0300 Subject: [PATCH 247/251] fixup 0a67b15a9d3348d10f6df0caae6f2f973295a43a trx_t::free(): Declare xid as fully initialized in order to avoid tripping the subsequent MEM_CHECK_DEFINED (in WITH_MSAN and WITH_VALGRIND builds). --- storage/innobase/trx/trx0trx.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc index 3ff09395d36..66ca04bbf04 100644 --- a/storage/innobase/trx/trx0trx.cc +++ b/storage/innobase/trx/trx0trx.cc @@ -362,6 +362,13 @@ trx_t *trx_create() /** Free the memory to trx_pools */ void trx_t::free() { +#ifdef HAVE_MEM_CHECK + if (xid.is_null()) + MEM_MAKE_DEFINED(&xid, sizeof xid); + else + MEM_MAKE_DEFINED(&xid.data[xid.gtrid_length + xid.bqual_length], + sizeof xid.data - (xid.gtrid_length + xid.bqual_length)); +#endif MEM_CHECK_DEFINED(this, sizeof *this); ut_ad(!n_mysql_tables_in_use); From 6fa72fb1f2a7b684c2f138499e820eeb4dfe19df Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sun, 4 Jul 2021 12:10:54 +0200 Subject: [PATCH 248/251] mtr: report full command line of mysqld that failed to start --- mysql-test/mariadb-test-run.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/mariadb-test-run.pl b/mysql-test/mariadb-test-run.pl index b0fd08abec2..becf799c825 100755 --- a/mysql-test/mariadb-test-run.pl +++ b/mysql-test/mariadb-test-run.pl @@ -5095,7 +5095,7 @@ sub mysqld_start ($$) { $tinfo->{logfile}=get_log_from_proc($mysqld->{'proc'}, $tinfo->{name}); report_option('verbose', 1); mtr_report_test($tinfo); - mtr_error("Failed to start mysqld $mname with command $exe"); + mtr_error("Failed to start mysqld $mname with command $exe @$args"); } # Remember options used when starting From 1f2ccc6db8a3e9be21d7ae599177380e2120d4af Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 5 Jul 2021 11:56:24 +0200 Subject: [PATCH 249/251] update C/C to 3.2.3 --- libmariadb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmariadb b/libmariadb index 74a405d9770..fffa8167d88 160000 --- a/libmariadb +++ b/libmariadb @@ -1 +1 @@ -Subproject commit 74a405d9770720e000c391672fca9e67421fa4bf +Subproject commit fffa8167d883bbf841ecb04a77abe2fbf1d1dfc9 From 94c508dd4f34ec9248fe809877ab185637aca9e2 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 6 Jul 2021 00:06:20 +0200 Subject: [PATCH 250/251] MDEV-22709 Assertion `store.length() <= (256L*256L*256L-1)' failed in net_send_ok add a test case (commented, as user var tracker is disabled) --- mysql-test/main/mysqltest_tracking_info.test | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mysql-test/main/mysqltest_tracking_info.test b/mysql-test/main/mysqltest_tracking_info.test index a3dfbba53c0..2be3e9344b9 100644 --- a/mysql-test/main/mysqltest_tracking_info.test +++ b/mysql-test/main/mysqltest_tracking_info.test @@ -84,4 +84,10 @@ SET SESSION session_track_system_variables=NULL; #--disable_session_track_info #set @@session.session_track_user_variables=0; +#--echo # +#--echo # MDEV-22709 Assertion `store.length() <= (256L*256L*256L-1)' failed in net_send_ok +#--echo # +#SET SESSION session_track_user_variables=1; +#SET @inserted_value=REPEAT(1,16777180); # Only crashes when >=16777180 (max = 16777216) + --echo # End of 10.5 tests From a8410693dccf206ca58089c72449cc78d03dd612 Mon Sep 17 00:00:00 2001 From: Daniel Bartholomew Date: Tue, 6 Jul 2021 09:50:41 -0400 Subject: [PATCH 251/251] bump the VERSION --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 820984bb644..ae3e2c7fe73 100644 --- a/VERSION +++ b/VERSION @@ -1,4 +1,4 @@ MYSQL_VERSION_MAJOR=10 MYSQL_VERSION_MINOR=6 -MYSQL_VERSION_PATCH=3 +MYSQL_VERSION_PATCH=4 SERVER_MATURITY=stable