From 36f84744031430747d27bfb2087c7ae51019a70a Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 10 Nov 2017 12:48:52 +0100 Subject: [PATCH 01/69] MDEV-14337 mysqld_safe may suppress error messages with --log-output=file don't close stdout/stderr, redirect them to /dev/null instead. otherwise redirections like >&2 fail with "invalid file descriptor" --- scripts/mysqld_safe.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh index b644184b1e1..46b37689093 100644 --- a/scripts/mysqld_safe.sh +++ b/scripts/mysqld_safe.sh @@ -868,8 +868,8 @@ if expr "${-}" : '.*x' > /dev/null then : else - exec 1>&- - exec 2>&- + exec 1>/dev/null + exec 2>/dev/null fi while true From b5cb4ae470c80e21cc340c2fa13683d7d31b3da6 Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Sat, 11 Nov 2017 11:45:59 -0800 Subject: [PATCH 02/69] Fixed bug MDEV-14368 Improper error for a grouping query that uses alias in HAVING when sql_mode = 'ONLY_FULL_GROUP_BY' This patch corrects the patch for bug#18739: non-standard HAVING extension was allowed in strict ANSI sql mode added in 2006 by commit 4b7c4cd27f68b9aac1970b9f21c50d4eee35df7d. As a result of incompleteness of the fix in the above commit if a query with GROUP BY contained an aggregate function with an alias and this alias was used in the HAVING clause of the query the server reported an error when sql_mode was set to 'ONLY_FULL_GROUP_BY'. --- mysql-test/r/having.result | 15 +++++++++++++++ mysql-test/t/having.test | 17 +++++++++++++++++ sql/item.cc | 3 ++- 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/having.result b/mysql-test/r/having.result index 514abbf5522..18915da1a09 100644 --- a/mysql-test/r/having.result +++ b/mysql-test/r/having.result @@ -697,3 +697,18 @@ id column_1 1 80a12660d24a72460e5e292fe33f870276d7f40a expected -- 1 row(s) returned not ER_BAD_FIELD_ERROR drop table t1; +# +# mdev-14368: grouping query with alias for aggregate function in HAVING +# when sql_mode = 'ONLY_FULL_GROUP_BY' +set @save_sql_mode= @@sql_mode; +set sql_mode = 'ONLY_FULL_GROUP_BY'; +create table t1(a int); +insert t1 values (4),(1),(2),(1), (3),(4); +SELECT a, COUNT(a) as ct FROM t1 GROUP BY a HAVING ct>0; +a ct +1 2 +2 1 +3 1 +4 2 +set sql_mode=@save_sql_mode; +drop table t1; diff --git a/mysql-test/t/having.test b/mysql-test/t/having.test index 505fb9ad3cf..a470f462d6a 100644 --- a/mysql-test/t/having.test +++ b/mysql-test/t/having.test @@ -727,3 +727,20 @@ HAVING UPPER(`column_1`) LIKE '8%'; --echo expected -- 1 row(s) returned not ER_BAD_FIELD_ERROR drop table t1; + +--echo # +--echo # mdev-14368: grouping query with alias for aggregate function in HAVING +--echo # when sql_mode = 'ONLY_FULL_GROUP_BY' + + +set @save_sql_mode= @@sql_mode; +set sql_mode = 'ONLY_FULL_GROUP_BY'; + +create table t1(a int); +insert t1 values (4),(1),(2),(1), (3),(4); + +SELECT a, COUNT(a) as ct FROM t1 GROUP BY a HAVING ct>0; + +set sql_mode=@save_sql_mode; + +drop table t1; diff --git a/sql/item.cc b/sql/item.cc index fa2e52bfd4a..332e027adf1 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -4771,7 +4771,8 @@ resolve_ref_in_select_and_group(THD *thd, Item_ident *ref, SELECT_LEX *select) if (thd->variables.sql_mode & MODE_ONLY_FULL_GROUP_BY && select->having_fix_field && - select_ref != not_found_item && !group_by_ref) + select_ref != not_found_item && !group_by_ref && + !ref->alias_name_used) { /* Report the error if fields was found only in the SELECT item list and From d7b2bc98bf55dded58e4d5d4a19e4aa48b30b26b Mon Sep 17 00:00:00 2001 From: Daniel Bartholomew Date: Tue, 14 Nov 2017 13:03:54 -0500 Subject: [PATCH 03/69] bump the VERSION --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 5a19a706528..24d355ca91e 100644 --- a/VERSION +++ b/VERSION @@ -1,3 +1,3 @@ MYSQL_VERSION_MAJOR=10 MYSQL_VERSION_MINOR=0 -MYSQL_VERSION_PATCH=33 +MYSQL_VERSION_PATCH=34 From f7b110bdc1fb0eb6b383f9647caa299de9d64aba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Thu, 16 Nov 2017 12:39:41 +0200 Subject: [PATCH 04/69] MDEV-9663: InnoDB assertion failure: *cursor->index->name == TEMP_INDEX_PREFIX Imported missing test case from MySQL 5.7 for commit 25781c154396dbbc21023786aa3be070057d6999 Author: Annamalai Gurusami Date: Mon Feb 24 14:00:03 2014 +0530 Bug #17604730 ASSERTION: *CURSOR->INDEX->NAME == TEMP_INDEX_PREFIX MariaDB 5.5 does not seem to be affected. --- .../suite/innodb/r/innodb-replace-debug.result | 9 +++++++++ mysql-test/suite/innodb/t/innodb-replace-debug.test | 13 +++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 mysql-test/suite/innodb/r/innodb-replace-debug.result create mode 100644 mysql-test/suite/innodb/t/innodb-replace-debug.test diff --git a/mysql-test/suite/innodb/r/innodb-replace-debug.result b/mysql-test/suite/innodb/r/innodb-replace-debug.result new file mode 100644 index 00000000000..0de351efded --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb-replace-debug.result @@ -0,0 +1,9 @@ +# +# Bug#17604730 ASSERTION: *CURSOR->INDEX->NAME == TEMP_INDEX_PREFIX +# +create table t1 (f1 int primary key, f2 int, f3 int, unique key k1(f2), +key k2(f3)) engine=innodb; +insert into t1 values (14, 24, 34); +set debug = '+d,row_ins_sec_index_entry_timeout'; +replace into t1 values (14, 25, 34); +drop table t1; diff --git a/mysql-test/suite/innodb/t/innodb-replace-debug.test b/mysql-test/suite/innodb/t/innodb-replace-debug.test new file mode 100644 index 00000000000..250c90ba5b1 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb-replace-debug.test @@ -0,0 +1,13 @@ +--source include/have_innodb.inc +--source include/have_debug.inc + +--echo # +--echo # Bug#17604730 ASSERTION: *CURSOR->INDEX->NAME == TEMP_INDEX_PREFIX +--echo # + +create table t1 (f1 int primary key, f2 int, f3 int, unique key k1(f2), + key k2(f3)) engine=innodb; +insert into t1 values (14, 24, 34); +set debug = '+d,row_ins_sec_index_entry_timeout'; +replace into t1 values (14, 25, 34); +drop table t1; From c44ece7342f14498630e4ab403ae125971137457 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Thu, 16 Nov 2017 12:56:54 +0200 Subject: [PATCH 05/69] MDEV-9663: InnoDB assertion failure: *cursor->index->name == TEMP_INDEX_PREFIX MariaDB adjustments to test case innodb-replace-debug. --- mysql-test/suite/innodb/r/innodb-replace-debug.result | 6 +++++- mysql-test/suite/innodb/t/innodb-replace-debug.test | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/mysql-test/suite/innodb/r/innodb-replace-debug.result b/mysql-test/suite/innodb/r/innodb-replace-debug.result index 0de351efded..84bc9dc9769 100644 --- a/mysql-test/suite/innodb/r/innodb-replace-debug.result +++ b/mysql-test/suite/innodb/r/innodb-replace-debug.result @@ -4,6 +4,10 @@ create table t1 (f1 int primary key, f2 int, f3 int, unique key k1(f2), key k2(f3)) engine=innodb; insert into t1 values (14, 24, 34); -set debug = '+d,row_ins_sec_index_entry_timeout'; +set @@debug_dbug = '+d,row_ins_sec_index_entry_timeout'; replace into t1 values (14, 25, 34); +select * from t1; +f1 f2 f3 +14 25 34 drop table t1; +set @@debug_dbug = '-d,row_ins_sec_index_entry_timeout'; diff --git a/mysql-test/suite/innodb/t/innodb-replace-debug.test b/mysql-test/suite/innodb/t/innodb-replace-debug.test index 250c90ba5b1..5cec9e1febf 100644 --- a/mysql-test/suite/innodb/t/innodb-replace-debug.test +++ b/mysql-test/suite/innodb/t/innodb-replace-debug.test @@ -8,6 +8,8 @@ create table t1 (f1 int primary key, f2 int, f3 int, unique key k1(f2), key k2(f3)) engine=innodb; insert into t1 values (14, 24, 34); -set debug = '+d,row_ins_sec_index_entry_timeout'; +set @@debug_dbug = '+d,row_ins_sec_index_entry_timeout'; replace into t1 values (14, 25, 34); +select * from t1; drop table t1; +set @@debug_dbug = '-d,row_ins_sec_index_entry_timeout'; From 9b53e541f03d74e2777e0d1e7618b6246b81c721 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 20 Nov 2017 09:33:19 +0400 Subject: [PATCH 06/69] MDEV-13788 Server crash when issuing bad SQL partition syntax --- .../suite/parts/inc/part_alter_values.inc | 24 +++++++++++++ .../parts/r/partition_alter_innodb.result | 35 +++++++++++++++++++ .../parts/r/partition_alter_maria.result | 35 +++++++++++++++++++ .../parts/r/partition_alter_myisam.result | 35 +++++++++++++++++++ .../suite/parts/t/partition_alter_innodb.test | 4 +++ .../suite/parts/t/partition_alter_maria.test | 3 ++ .../suite/parts/t/partition_alter_myisam.test | 3 ++ sql/partition_info.cc | 20 +++++++++++ sql/partition_info.h | 1 + sql/sql_partition.cc | 11 ++---- sql/sql_yacc.yy | 14 ++------ 11 files changed, 165 insertions(+), 20 deletions(-) create mode 100644 mysql-test/suite/parts/inc/part_alter_values.inc create mode 100644 mysql-test/suite/parts/r/partition_alter_innodb.result create mode 100644 mysql-test/suite/parts/r/partition_alter_myisam.result create mode 100644 mysql-test/suite/parts/t/partition_alter_innodb.test create mode 100644 mysql-test/suite/parts/t/partition_alter_myisam.test diff --git a/mysql-test/suite/parts/inc/part_alter_values.inc b/mysql-test/suite/parts/inc/part_alter_values.inc new file mode 100644 index 00000000000..f56d81d8930 --- /dev/null +++ b/mysql-test/suite/parts/inc/part_alter_values.inc @@ -0,0 +1,24 @@ +--echo # +--echo # MDEV-13788 Server crash when issuing bad SQL partition syntax +--echo # + +--eval CREATE TABLE t1 (id int, d date) ENGINE=$engine PARTITION BY RANGE COLUMNS(d) (PARTITION p1 VALUES LESS THAN (MAXVALUE)) +SHOW CREATE TABLE t1; +--error ER_PARTITION_REQUIRES_VALUES_ERROR +ALTER TABLE t1 REORGANIZE PARTITION p1 INTO +( + PARTITION p2, /* Notice no values */ + PARTITION p3 VALUES LESS THAN (MAXVALUE) +); +DROP TABLE t1; + + +--eval CREATE TABLE t1 (id int, d date) ENGINE=$engine PARTITION BY LIST (id) (PARTITION p1 VALUES IN (1,2,3)) +SHOW CREATE TABLE t1; +--error ER_PARTITION_REQUIRES_VALUES_ERROR +ALTER TABLE t1 REORGANIZE PARTITION p1 INTO +( + PARTITION p2, /* Notice no values */ + PARTITION p3 VALUES IN (4,5,6) +); +DROP TABLE t1; diff --git a/mysql-test/suite/parts/r/partition_alter_innodb.result b/mysql-test/suite/parts/r/partition_alter_innodb.result new file mode 100644 index 00000000000..4436ba5e737 --- /dev/null +++ b/mysql-test/suite/parts/r/partition_alter_innodb.result @@ -0,0 +1,35 @@ +# +# MDEV-13788 Server crash when issuing bad SQL partition syntax +# +CREATE TABLE t1 (id int, d date) ENGINE=InnoDB PARTITION BY RANGE COLUMNS(d) (PARTITION p1 VALUES LESS THAN (MAXVALUE)); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `id` int(11) DEFAULT NULL, + `d` date DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50500 PARTITION BY RANGE COLUMNS(d) +(PARTITION p1 VALUES LESS THAN (MAXVALUE) ENGINE = InnoDB) */ +ALTER TABLE t1 REORGANIZE PARTITION p1 INTO +( +PARTITION p2, /* Notice no values */ +PARTITION p3 VALUES LESS THAN (MAXVALUE) +); +ERROR HY000: Syntax error: RANGE PARTITIONING requires definition of VALUES LESS THAN for each partition +DROP TABLE t1; +CREATE TABLE t1 (id int, d date) ENGINE=InnoDB PARTITION BY LIST (id) (PARTITION p1 VALUES IN (1,2,3)); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `id` int(11) DEFAULT NULL, + `d` date DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (id) +(PARTITION p1 VALUES IN (1,2,3) ENGINE = InnoDB) */ +ALTER TABLE t1 REORGANIZE PARTITION p1 INTO +( +PARTITION p2, /* Notice no values */ +PARTITION p3 VALUES IN (4,5,6) +); +ERROR HY000: Syntax error: LIST PARTITIONING requires definition of VALUES IN for each partition +DROP TABLE t1; diff --git a/mysql-test/suite/parts/r/partition_alter_maria.result b/mysql-test/suite/parts/r/partition_alter_maria.result index 6343566e408..460d20b9255 100644 --- a/mysql-test/suite/parts/r/partition_alter_maria.result +++ b/mysql-test/suite/parts/r/partition_alter_maria.result @@ -16,3 +16,38 @@ select * from t1; pk dt 1 2017-09-28 15:12:00 drop table t1; +# +# MDEV-13788 Server crash when issuing bad SQL partition syntax +# +CREATE TABLE t1 (id int, d date) ENGINE=Aria PARTITION BY RANGE COLUMNS(d) (PARTITION p1 VALUES LESS THAN (MAXVALUE)); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `id` int(11) DEFAULT NULL, + `d` date DEFAULT NULL +) ENGINE=Aria DEFAULT CHARSET=latin1 +/*!50500 PARTITION BY RANGE COLUMNS(d) +(PARTITION p1 VALUES LESS THAN (MAXVALUE) ENGINE = Aria) */ +ALTER TABLE t1 REORGANIZE PARTITION p1 INTO +( +PARTITION p2, /* Notice no values */ +PARTITION p3 VALUES LESS THAN (MAXVALUE) +); +ERROR HY000: Syntax error: RANGE PARTITIONING requires definition of VALUES LESS THAN for each partition +DROP TABLE t1; +CREATE TABLE t1 (id int, d date) ENGINE=Aria PARTITION BY LIST (id) (PARTITION p1 VALUES IN (1,2,3)); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `id` int(11) DEFAULT NULL, + `d` date DEFAULT NULL +) ENGINE=Aria DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (id) +(PARTITION p1 VALUES IN (1,2,3) ENGINE = Aria) */ +ALTER TABLE t1 REORGANIZE PARTITION p1 INTO +( +PARTITION p2, /* Notice no values */ +PARTITION p3 VALUES IN (4,5,6) +); +ERROR HY000: Syntax error: LIST PARTITIONING requires definition of VALUES IN for each partition +DROP TABLE t1; diff --git a/mysql-test/suite/parts/r/partition_alter_myisam.result b/mysql-test/suite/parts/r/partition_alter_myisam.result new file mode 100644 index 00000000000..050e1d9a519 --- /dev/null +++ b/mysql-test/suite/parts/r/partition_alter_myisam.result @@ -0,0 +1,35 @@ +# +# MDEV-13788 Server crash when issuing bad SQL partition syntax +# +CREATE TABLE t1 (id int, d date) ENGINE=MyISAM PARTITION BY RANGE COLUMNS(d) (PARTITION p1 VALUES LESS THAN (MAXVALUE)); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `id` int(11) DEFAULT NULL, + `d` date DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50500 PARTITION BY RANGE COLUMNS(d) +(PARTITION p1 VALUES LESS THAN (MAXVALUE) ENGINE = MyISAM) */ +ALTER TABLE t1 REORGANIZE PARTITION p1 INTO +( +PARTITION p2, /* Notice no values */ +PARTITION p3 VALUES LESS THAN (MAXVALUE) +); +ERROR HY000: Syntax error: RANGE PARTITIONING requires definition of VALUES LESS THAN for each partition +DROP TABLE t1; +CREATE TABLE t1 (id int, d date) ENGINE=MyISAM PARTITION BY LIST (id) (PARTITION p1 VALUES IN (1,2,3)); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `id` int(11) DEFAULT NULL, + `d` date DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +/*!50100 PARTITION BY LIST (id) +(PARTITION p1 VALUES IN (1,2,3) ENGINE = MyISAM) */ +ALTER TABLE t1 REORGANIZE PARTITION p1 INTO +( +PARTITION p2, /* Notice no values */ +PARTITION p3 VALUES IN (4,5,6) +); +ERROR HY000: Syntax error: LIST PARTITIONING requires definition of VALUES IN for each partition +DROP TABLE t1; diff --git a/mysql-test/suite/parts/t/partition_alter_innodb.test b/mysql-test/suite/parts/t/partition_alter_innodb.test new file mode 100644 index 00000000000..451bec05adc --- /dev/null +++ b/mysql-test/suite/parts/t/partition_alter_innodb.test @@ -0,0 +1,4 @@ +--source include/have_innodb.inc +--source include/have_partition.inc +--let $engine=InnoDB +--source inc/part_alter_values.inc diff --git a/mysql-test/suite/parts/t/partition_alter_maria.test b/mysql-test/suite/parts/t/partition_alter_maria.test index db249591158..e21f0dfab82 100644 --- a/mysql-test/suite/parts/t/partition_alter_maria.test +++ b/mysql-test/suite/parts/t/partition_alter_maria.test @@ -16,3 +16,6 @@ select * from t1; alter table t1 drop partition p20181231; select * from t1; drop table t1; + +--let $engine=Aria +--source inc/part_alter_values.inc diff --git a/mysql-test/suite/parts/t/partition_alter_myisam.test b/mysql-test/suite/parts/t/partition_alter_myisam.test new file mode 100644 index 00000000000..a53fa333abd --- /dev/null +++ b/mysql-test/suite/parts/t/partition_alter_myisam.test @@ -0,0 +1,3 @@ +--source include/have_partition.inc +--let $engine=MyISAM +--source inc/part_alter_values.inc diff --git a/sql/partition_info.cc b/sql/partition_info.cc index 512bf296135..740e5087477 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -2132,6 +2132,24 @@ end: DBUG_RETURN(result); } + +bool partition_info::error_if_requires_values() const +{ + switch (part_type) { + case NOT_A_PARTITION: + case HASH_PARTITION: + break; + case RANGE_PARTITION: + my_error(ER_PARTITION_REQUIRES_VALUES_ERROR, MYF(0), "RANGE", "LESS THAN"); + return true; + case LIST_PARTITION: + my_error(ER_PARTITION_REQUIRES_VALUES_ERROR, MYF(0), "LIST", "IN"); + return true; + } + return false; +} + + /* The parser generates generic data structures, we need to set them up as the rest of the code expects to find them. This is in reality part @@ -2221,6 +2239,8 @@ int partition_info::fix_parser_data(THD *thd) part_elem= it++; List_iterator list_val_it(part_elem->list_val_list); num_elements= part_elem->list_val_list.elements; + if (!num_elements && error_if_requires_values()) + DBUG_RETURN(true); DBUG_ASSERT(part_type == RANGE_PARTITION ? num_elements == 1U : TRUE); for (j= 0; j < num_elements; j++) diff --git a/sql/partition_info.h b/sql/partition_info.h index cff941a858a..779948eddc9 100644 --- a/sql/partition_info.h +++ b/sql/partition_info.h @@ -313,6 +313,7 @@ public: void set_show_version_string(String *packet); void report_part_expr_error(bool use_subpart_expr); bool has_same_partitioning(partition_info *new_part_info); + bool error_if_requires_values() const; private: static int list_part_cmp(const void* a, const void* b); bool set_up_default_partitions(handler *file, HA_CREATE_INFO *info, diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index ab31a8c1791..01dcc7cc2ac 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -4770,16 +4770,11 @@ uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info, my_error(ER_PARTITION_WRONG_VALUES_ERROR, MYF(0), "LIST", "IN"); } - else if (tab_part_info->part_type == RANGE_PARTITION) - { - my_error(ER_PARTITION_REQUIRES_VALUES_ERROR, MYF(0), - "RANGE", "LESS THAN"); - } else { - DBUG_ASSERT(tab_part_info->part_type == LIST_PARTITION); - my_error(ER_PARTITION_REQUIRES_VALUES_ERROR, MYF(0), - "LIST", "IN"); + DBUG_ASSERT(tab_part_info->part_type == RANGE_PARTITION || + tab_part_info->part_type == LIST_PARTITION); + (void) tab_part_info->error_if_requires_values(); } goto err; } diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 4805cd4c66a..e1c6b5b6276 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -4679,18 +4679,8 @@ opt_part_values: partition_info *part_info= lex->part_info; if (! lex->is_partition_management()) { - if (part_info->part_type == RANGE_PARTITION) - { - my_error(ER_PARTITION_REQUIRES_VALUES_ERROR, MYF(0), - "RANGE", "LESS THAN"); - MYSQL_YYABORT; - } - if (part_info->part_type == LIST_PARTITION) - { - my_error(ER_PARTITION_REQUIRES_VALUES_ERROR, MYF(0), - "LIST", "IN"); - MYSQL_YYABORT; - } + if (part_info->error_if_requires_values()) + MYSQL_YYABORT; } else part_info->part_type= HASH_PARTITION; From b8d1398b1d061566ada0714fb2407cdd45ff42b2 Mon Sep 17 00:00:00 2001 From: Varun Gupta Date: Thu, 30 Nov 2017 11:56:02 +0200 Subject: [PATCH 07/69] MDEV-10397: Server crashes in key_copy with join_cache_level > 2 and join on BIT fields For BIT field null_bit is not set to 0 even for a field defined as NOT NULL. So now in the function TABLE::create_key_part_by_field, if the bit field is not nullable then the null_bit is explicitly set to 0 --- mysql-test/r/join_outer.result | 13 +++++++++++++ mysql-test/r/join_outer_jcl6.result | 13 +++++++++++++ mysql-test/t/join_outer.test | 14 ++++++++++++++ sql/table.cc | 8 ++++++++ 4 files changed, 48 insertions(+) diff --git a/mysql-test/r/join_outer.result b/mysql-test/r/join_outer.result index 5611b61a7b0..74580e67499 100644 --- a/mysql-test/r/join_outer.result +++ b/mysql-test/r/join_outer.result @@ -2339,5 +2339,18 @@ Warnings: Note 1003 select `test`.`t1`.`col1` AS `col1`,`test`.`t2`.`col1` AS `col1`,`test`.`t2`.`col3` AS `col3` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`col2` = `test`.`t1`.`col1`)) where (`f1`(`test`.`t2`.`col3`,0) = 0) DROP FUNCTION f1; DROP TABLE t1,t2; +# +# MDEV-10397: Server crashes in key_copy with join_cache_level > 2 and join on BIT fields +# +CREATE TABLE t1 (b1 BIT NOT NULL); +INSERT INTO t1 VALUES (0),(1); +CREATE TABLE t2 (b2 BIT NOT NULL); +INSERT INTO t2 VALUES (0),(1); +SET SESSION JOIN_CACHE_LEVEL = 3; +SELECT t1.b1+'0' , t2.b2 + '0' FROM t1 LEFT JOIN t2 ON b1 = b2; +t1.b1+'0' t2.b2 + '0' +0 0 +1 1 +DROP TABLE t1, t2; # end of 5.5 tests SET optimizer_switch=@save_optimizer_switch; diff --git a/mysql-test/r/join_outer_jcl6.result b/mysql-test/r/join_outer_jcl6.result index 8a1ccc7d5e5..d46a4ee6c7a 100644 --- a/mysql-test/r/join_outer_jcl6.result +++ b/mysql-test/r/join_outer_jcl6.result @@ -2350,6 +2350,19 @@ Warnings: Note 1003 select `test`.`t1`.`col1` AS `col1`,`test`.`t2`.`col1` AS `col1`,`test`.`t2`.`col3` AS `col3` from `test`.`t1` left join `test`.`t2` on((`test`.`t2`.`col2` = `test`.`t1`.`col1`)) where (`f1`(`test`.`t2`.`col3`,0) = 0) DROP FUNCTION f1; DROP TABLE t1,t2; +# +# MDEV-10397: Server crashes in key_copy with join_cache_level > 2 and join on BIT fields +# +CREATE TABLE t1 (b1 BIT NOT NULL); +INSERT INTO t1 VALUES (0),(1); +CREATE TABLE t2 (b2 BIT NOT NULL); +INSERT INTO t2 VALUES (0),(1); +SET SESSION JOIN_CACHE_LEVEL = 3; +SELECT t1.b1+'0' , t2.b2 + '0' FROM t1 LEFT JOIN t2 ON b1 = b2; +t1.b1+'0' t2.b2 + '0' +0 0 +1 1 +DROP TABLE t1, t2; # end of 5.5 tests SET optimizer_switch=@save_optimizer_switch; set join_cache_level=default; diff --git a/mysql-test/t/join_outer.test b/mysql-test/t/join_outer.test index 9645d8ad82a..896cc137e07 100644 --- a/mysql-test/t/join_outer.test +++ b/mysql-test/t/join_outer.test @@ -1881,6 +1881,20 @@ DROP FUNCTION f1; DROP TABLE t1,t2; +--echo # +--echo # MDEV-10397: Server crashes in key_copy with join_cache_level > 2 and join on BIT fields +--echo # + +CREATE TABLE t1 (b1 BIT NOT NULL); +INSERT INTO t1 VALUES (0),(1); + +CREATE TABLE t2 (b2 BIT NOT NULL); +INSERT INTO t2 VALUES (0),(1); + +SET SESSION JOIN_CACHE_LEVEL = 3; +SELECT t1.b1+'0' , t2.b2 + '0' FROM t1 LEFT JOIN t2 ON b1 = b2; +DROP TABLE t1, t2; + --echo # end of 5.5 tests SET optimizer_switch=@save_optimizer_switch; diff --git a/sql/table.cc b/sql/table.cc index 9d52d5f87a2..fbcd91f5326 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -5987,6 +5987,14 @@ void TABLE::create_key_part_by_field(KEY_PART_INFO *key_part_info, might be reused. */ key_part_info->store_length= key_part_info->length; + /* + For BIT fields null_bit is not set to 0 even if the field is defined + as NOT NULL, look at Field_bit::Field_bit + */ + if (!field->real_maybe_null()) + { + key_part_info->null_bit= 0; + } /* The total store length of the key part is the raw length of the field + From 7603463a46b288c1b5630348e36c622e4c2abb09 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Thu, 16 Nov 2017 20:32:33 +0800 Subject: [PATCH 08/69] Remove use of volatile in stored_field_cmp_to_item This was added in c79641594348 but would hurt all other compilers because of Visual Studio. Hopefully this has been fixed now. Signed-off-by: Daniel Black --- sql/item.cc | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/sql/item.cc b/sql/item.cc index 332e027adf1..574e8722c3d 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -8924,15 +8924,10 @@ int stored_field_cmp_to_item(THD *thd, Field *field, Item *item) } return my_time_compare(&field_time, &item_time); } - /* - The patch for Bug#13463415 started using this function for comparing - BIGINTs. That uncovered a bug in Visual Studio 32bit optimized mode. - Prefixing the auto variables with volatile fixes the problem.... - */ - volatile double result= item->val_real(); + double result= item->val_real(); if (item->null_value) return 0; - volatile double field_result= field->val_real(); + double field_result= field->val_real(); if (field_result < result) return -1; else if (field_result > result) From ac61a575dfff6b9510576be920a522c710732c0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicen=C8=9Biu=20Ciorbaru?= Date: Wed, 6 Dec 2017 02:16:14 +0200 Subject: [PATCH 09/69] Revert "Remove use of volatile in stored_field_cmp_to_item" This reverts commit 7603463a46b288c1b5630348e36c622e4c2abb09. The commit itself is fine, however when disabling volatile, compiler optimizations mess up our double results due to precision differences. Revert the patch till a proper solution is found. --- sql/item.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sql/item.cc b/sql/item.cc index 574e8722c3d..332e027adf1 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -8924,10 +8924,15 @@ int stored_field_cmp_to_item(THD *thd, Field *field, Item *item) } return my_time_compare(&field_time, &item_time); } - double result= item->val_real(); + /* + The patch for Bug#13463415 started using this function for comparing + BIGINTs. That uncovered a bug in Visual Studio 32bit optimized mode. + Prefixing the auto variables with volatile fixes the problem.... + */ + volatile double result= item->val_real(); if (item->null_value) return 0; - double field_result= field->val_real(); + volatile double field_result= field->val_real(); if (field_result < result) return -1; else if (field_result > result) From 20089f5a39fa8f6f08113f12ed87c34e844c4fc6 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Fri, 8 Dec 2017 14:40:27 +0400 Subject: [PATCH 10/69] MDEV-14596 Crash in INTERVAL(ROW(..),ROW(..)) --- mysql-test/r/func_set.result | 9 +++++++++ mysql-test/t/func_set.test | 11 +++++++++++ sql/item_cmpfunc.cc | 13 +++++++++++++ sql/item_cmpfunc.h | 1 + 4 files changed, 34 insertions(+) diff --git a/mysql-test/r/func_set.result b/mysql-test/r/func_set.result index 9c4976d46db..ca1ccd71c90 100644 --- a/mysql-test/r/func_set.result +++ b/mysql-test/r/func_set.result @@ -220,3 +220,12 @@ NULL 1,2,3,4,5,6,7 DROP TABLE t1; +# +# MDEV-14596 Crash in INTERVAL(ROW(..),ROW(..)) +# +SELECT INTERVAL(ROW(1,1),ROW(1,2)); +ERROR 21000: Operand should contain 1 column(s) +SELECT INTERVAL(1,ROW(1,2)); +ERROR 21000: Operand should contain 1 column(s) +SELECT INTERVAL(ROW(1,2),1); +ERROR 21000: Operand should contain 1 column(s) diff --git a/mysql-test/t/func_set.test b/mysql-test/t/func_set.test index ba984113fd7..887b1948498 100644 --- a/mysql-test/t/func_set.test +++ b/mysql-test/t/func_set.test @@ -136,3 +136,14 @@ SELECT * FROM t1 WHERE FIND_IN_SET(NULL, NULL) IS UNKNOWN; --echo DROP TABLE t1; + +--echo # +--echo # MDEV-14596 Crash in INTERVAL(ROW(..),ROW(..)) +--echo # + +--error ER_OPERAND_COLUMNS +SELECT INTERVAL(ROW(1,1),ROW(1,2)); +--error ER_OPERAND_COLUMNS +SELECT INTERVAL(1,ROW(1,2)); +--error ER_OPERAND_COLUMNS +SELECT INTERVAL(ROW(1,2),1); diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index ebe088e5092..62e76922c0e 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -2001,6 +2001,19 @@ bool Item_func_opt_neg::eq(const Item *item, bool binary_cmp) const } +bool Item_func_interval::fix_fields(THD *thd, Item **ref) +{ + if (Item_int_func::fix_fields(thd, ref)) + return true; + for (uint i= 0 ; i < row->cols(); i++) + { + if (row->element_index(i)->check_cols(1)) + return true; + } + return false; +} + + void Item_func_interval::fix_length_and_dec() { uint rows= row->cols(); diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index a8befa47b95..7b7ca9223fd 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -728,6 +728,7 @@ public: { allowed_arg_cols= 0; // Fetch this value from first argument } + bool fix_fields(THD *, Item **); longlong val_int(); void fix_length_and_dec(); const char *func_name() const { return "interval"; } From 15219eb08a28261aa730c301583f1c47a92790b8 Mon Sep 17 00:00:00 2001 From: Andrei Elkin Date: Mon, 11 Dec 2017 12:41:45 +0200 Subject: [PATCH 11/69] MDEV-14290 Binlog rotate crashes when two commit_checkpoint_notify capable engines. The crash (sometimes assert) in MYSQL_BIN_LOG::mark_xid_done was caused by a fact that log.cc:binlog_background_thread_queue could become a cyclic list. This possibility becomes real with two checkpoint capable engines that may execute TC_LOG_BINLOG::commit_checkpoint_notify() in succession before binlog_background thread gets control and eventually finds a freed memory while otherwise endlessly looping in while(queue). It is fixed with counting the notificaion kind instead of en-listing the same notificaion kind in commit_checkpoint_notify as formerly. The while(queue) of binlog background thread is refined to pay attention to the new counter. In effectno more access to free memory is possible. --- sql/log.cc | 21 +- sql/log.h | 1 + .../rocksdb_rpl/r/rpl_binlog_xid_count.result | 204 ++++++++++++++++++ .../t/rpl_binlog_xid_count-master.opt | 3 + .../rocksdb_rpl/t/rpl_binlog_xid_count.test | 20 ++ 5 files changed, 246 insertions(+), 3 deletions(-) create mode 100644 storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_binlog_xid_count.result create mode 100644 storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_binlog_xid_count-master.opt create mode 100644 storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_binlog_xid_count.test diff --git a/sql/log.cc b/sql/log.cc index 93d7a00c840..3aff3b2c40d 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -3583,6 +3583,7 @@ bool MYSQL_BIN_LOG::open(const char *log_name, new_xid_list_entry->binlog_name= name_mem; new_xid_list_entry->binlog_name_len= len; new_xid_list_entry->xid_count= 0; + new_xid_list_entry->notify_count= 0; /* Find the name for the Initial binlog checkpoint. @@ -9678,9 +9679,20 @@ void TC_LOG_BINLOG::commit_checkpoint_notify(void *cookie) { xid_count_per_binlog *entry= static_cast(cookie); + bool found_entry= false; mysql_mutex_lock(&LOCK_binlog_background_thread); - entry->next_in_queue= binlog_background_thread_queue; - binlog_background_thread_queue= entry; + /* count the same notification kind from different engines */ + for (xid_count_per_binlog *link= binlog_background_thread_queue; + link && !found_entry; link= link->next_in_queue) + { + if ((found_entry= (entry == link))) + entry->notify_count++; + } + if (!found_entry) + { + entry->next_in_queue= binlog_background_thread_queue; + binlog_background_thread_queue= entry; + } mysql_cond_signal(&COND_binlog_background_thread); mysql_mutex_unlock(&LOCK_binlog_background_thread); } @@ -9775,13 +9787,16 @@ binlog_background_thread(void *arg __attribute__((unused))) ); while (queue) { + long count= queue->notify_count; THD_STAGE_INFO(thd, stage_binlog_processing_checkpoint_notify); DEBUG_SYNC(thd, "binlog_background_thread_before_mark_xid_done"); /* Set the thread start time */ thd->set_time(); /* Grab next pointer first, as mark_xid_done() may free the element. */ next= queue->next_in_queue; - mysql_bin_log.mark_xid_done(queue->binlog_id, true); + queue->notify_count= 0; + for (long i= 0; i <= count; i++) + mysql_bin_log.mark_xid_done(queue->binlog_id, true); queue= next; DBUG_EXECUTE_IF("binlog_background_checkpoint_processed", diff --git a/sql/log.h b/sql/log.h index 8484d54c5c2..97e257829b7 100644 --- a/sql/log.h +++ b/sql/log.h @@ -580,6 +580,7 @@ public: ulong binlog_id; /* Total prepared XIDs and pending checkpoint requests in this binlog. */ long xid_count; + long notify_count; /* For linking in requests to the binlog background thread. */ xid_count_per_binlog *next_in_queue; xid_count_per_binlog(); /* Give link error if constructor used. */ diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_binlog_xid_count.result b/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_binlog_xid_count.result new file mode 100644 index 00000000000..9b46a5b5227 --- /dev/null +++ b/storage/rocksdb/mysql-test/rocksdb_rpl/r/rpl_binlog_xid_count.result @@ -0,0 +1,204 @@ +CREATE TABLE `t` ( +`a` text DEFAULT NULL +) ENGINE=ROCKSDB; +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +INSERT INTO t SET a=repeat('a', 4096); +INSERT INTO t SET a=repeat('a', 4096/2); +DROP TABLE t; diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_binlog_xid_count-master.opt b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_binlog_xid_count-master.opt new file mode 100644 index 00000000000..ed50a8a3deb --- /dev/null +++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_binlog_xid_count-master.opt @@ -0,0 +1,3 @@ +--innodb --max-binlog-size=4096 + + diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_binlog_xid_count.test b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_binlog_xid_count.test new file mode 100644 index 00000000000..7667f153cde --- /dev/null +++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/rpl_binlog_xid_count.test @@ -0,0 +1,20 @@ +--source include/have_rocksdb.inc +--source include/have_binlog_format_row.inc + +CREATE TABLE `t` ( + `a` text DEFAULT NULL +) ENGINE=ROCKSDB; + + +--let $size=`SELECT @@GLOBAL.max_binlog_size` +--let $loop_cnt= 100 +while ($loop_cnt) +{ + --eval INSERT INTO t SET a=repeat('a', $size) + --eval INSERT INTO t SET a=repeat('a', $size/2) + + --dec $loop_cnt +} + +# Cleanup +DROP TABLE t; From 273591df0c9917a93bc2d695f61d9f35fa7b1f5c Mon Sep 17 00:00:00 2001 From: Oleksandr Byelkin Date: Sun, 17 Dec 2017 00:01:55 +0100 Subject: [PATCH 12/69] MDEV-14619: VIEW and GROUP_CONCAT Correctly print separator string in single quotes. --- mysql-test/r/view.result | 14 ++++++++++++++ mysql-test/t/view.test | 12 ++++++++++++ sql/item_sum.cc | 2 +- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index c1f76ba58a4..8bc33a8860b 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -5629,6 +5629,20 @@ PREPARE stmt FROM 'REPLACE INTO v2 SELECT a FROM t3'; ERROR HY000: Can not insert into join view 'test.v2' without fields list drop view v1,v2; drop table t3; +# +# MDEV-14619: VIEW and GROUP_CONCAT +# +CREATE TABLE t1 (str text); +INSERT INTO t1 VALUES ("My"),("SQL"); +CREATE VIEW v1 AS SELECT GROUP_CONCAT(str SEPARATOR '\\') FROM t1; +SELECT * FROM v1; +GROUP_CONCAT(str SEPARATOR '\\') +My\SQL +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select group_concat(`t1`.`str` separator '\\') AS `GROUP_CONCAT(str SEPARATOR '\\')` from `t1` latin1 latin1_swedish_ci +drop view v1; +drop table t1; # ----------------------------------------------------------------- # -- End of 5.5 tests. # ----------------------------------------------------------------- diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index 79991f89683..0fc7cb6adf7 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -5578,6 +5578,18 @@ PREPARE stmt FROM 'REPLACE INTO v2 SELECT a FROM t3'; drop view v1,v2; drop table t3; +--echo # +--echo # MDEV-14619: VIEW and GROUP_CONCAT +--echo # + +CREATE TABLE t1 (str text); +INSERT INTO t1 VALUES ("My"),("SQL"); +CREATE VIEW v1 AS SELECT GROUP_CONCAT(str SEPARATOR '\\') FROM t1; +SELECT * FROM v1; +SHOW CREATE VIEW v1; +drop view v1; +drop table t1; + --echo # ----------------------------------------------------------------- --echo # -- End of 5.5 tests. --echo # ----------------------------------------------------------------- diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 9a2e2e6cd4c..709c2b6f7b5 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -3656,7 +3656,7 @@ void Item_func_group_concat::print(String *str, enum_query_type query_type) } } str->append(STRING_WITH_LEN(" separator \'")); - str->append(*separator); + str->append_for_single_quote(separator->ptr(), separator->length()); str->append(STRING_WITH_LEN("\')")); } From 2fced9e7b643d0c101d0ffde33f51e0a38f7017e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicen=C8=9Biu=20Ciorbaru?= Date: Sat, 16 Dec 2017 11:56:16 +0200 Subject: [PATCH 13/69] MDEV-13655: Set role does not properly grant privileges. When granting a role to another role, DB privileges get propagated. If the grantee had no previous DB privileges, an extra ACL_DB entry is created to house those "indirectly received" privileges. If, afterwards, DB privileges are granted to the grantee directly, we must make sure to not create a duplicate ACL_DB entry. --- mysql-test/suite/roles/set_role-13655.result | 50 ++++++++++++++++++++ mysql-test/suite/roles/set_role-13655.test | 49 +++++++++++++++++++ sql/sql_acl.cc | 47 ++++++++++++------ sql/structs.h | 2 +- 4 files changed, 132 insertions(+), 16 deletions(-) create mode 100644 mysql-test/suite/roles/set_role-13655.result create mode 100644 mysql-test/suite/roles/set_role-13655.test diff --git a/mysql-test/suite/roles/set_role-13655.result b/mysql-test/suite/roles/set_role-13655.result new file mode 100644 index 00000000000..1c4841c8afd --- /dev/null +++ b/mysql-test/suite/roles/set_role-13655.result @@ -0,0 +1,50 @@ +# +# MDEV-13655: SET ROLE does not properly grant privileges. +# +# We must test that if aditional db privileges get granted to a role +# which previously inherited privileges from another granted role +# keep the internal memory structures intact. +# +create role simple; +# +# First we create an entry with privileges for databases for the simple role. +# +grant select, insert, update, delete, lock tables, execute on t.* to simple; +create role admin; +# +# Now we grant the simple role to admin. This means that db privileges +# should propagate to admin. +# +grant simple to admin; +show grants for admin; +Grants for admin +GRANT simple TO 'admin' +GRANT USAGE ON *.* TO 'admin' +GRANT USAGE ON *.* TO 'simple' +GRANT SELECT, INSERT, UPDATE, DELETE, LOCK TABLES, EXECUTE ON `t`.* TO 'simple' +# +# Finally, we give the admin all the available privileges for the db. +# +grant all on t.* to admin; +# +# Create a user to test out the new roles; +# +create user foo; +grant admin to foo; +create database t; +ERROR 42000: Access denied for user 'foo'@'%' to database 't' +set role admin; +show grants; +Grants for foo@% +GRANT admin TO 'foo'@'%' +GRANT USAGE ON *.* TO 'foo'@'%' +GRANT simple TO 'admin' +GRANT USAGE ON *.* TO 'admin' +GRANT ALL PRIVILEGES ON `t`.* TO 'admin' +GRANT USAGE ON *.* TO 'simple' +GRANT SELECT, INSERT, UPDATE, DELETE, LOCK TABLES, EXECUTE ON `t`.* TO 'simple' +create database t; +drop database t; +drop role simple; +drop role admin; +drop user foo; diff --git a/mysql-test/suite/roles/set_role-13655.test b/mysql-test/suite/roles/set_role-13655.test new file mode 100644 index 00000000000..97a82109276 --- /dev/null +++ b/mysql-test/suite/roles/set_role-13655.test @@ -0,0 +1,49 @@ +source include/not_embedded.inc; + +--echo # +--echo # MDEV-13655: SET ROLE does not properly grant privileges. +--echo # +--echo # We must test that if aditional db privileges get granted to a role +--echo # which previously inherited privileges from another granted role +--echo # keep the internal memory structures intact. +--echo # + +create role simple; + +--echo # +--echo # First we create an entry with privileges for databases for the simple role. +--echo # +grant select, insert, update, delete, lock tables, execute on t.* to simple; +create role admin; + +--echo # +--echo # Now we grant the simple role to admin. This means that db privileges +--echo # should propagate to admin. +--echo # +grant simple to admin; +show grants for admin; + +--echo # +--echo # Finally, we give the admin all the available privileges for the db. +--echo # +grant all on t.* to admin; + +--echo # +--echo # Create a user to test out the new roles; +--echo # +create user foo; +grant admin to foo; + +connect (foo,localhost,foo,,,,,); +--error ER_DBACCESS_DENIED_ERROR +create database t; +set role admin; +show grants; +create database t; +drop database t; + +connection default; + +drop role simple; +drop role admin; +drop user foo; diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 177b4517904..1b25871b664 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -2129,37 +2129,42 @@ static void acl_insert_user(const char *user, const char *host, } -static void acl_update_db(const char *user, const char *host, const char *db, +static bool acl_update_db(const char *user, const char *host, const char *db, ulong privileges) { mysql_mutex_assert_owner(&acl_cache->lock); + bool updated= false; + for (uint i=0 ; i < acl_dbs.elements ; i++) { ACL_DB *acl_db=dynamic_element(&acl_dbs,i,ACL_DB*); if ((!acl_db->user && !user[0]) || - (acl_db->user && - !strcmp(user,acl_db->user))) + (acl_db->user && + !strcmp(user,acl_db->user))) { if ((!acl_db->host.hostname && !host[0]) || - (acl_db->host.hostname && - !strcmp(host, acl_db->host.hostname))) + (acl_db->host.hostname && + !strcmp(host, acl_db->host.hostname))) { - if ((!acl_db->db && !db[0]) || - (acl_db->db && !strcmp(db,acl_db->db))) + if ((!acl_db->db && !db[0]) || + (acl_db->db && !strcmp(db,acl_db->db))) - { - if (privileges) + { + if (privileges) { acl_db->access= privileges; acl_db->initial_access= acl_db->access; } - else - delete_dynamic_element(&acl_dbs,i); - } + else + delete_dynamic_element(&acl_dbs,i); + updated= true; + } } } } + + return updated; } @@ -3428,9 +3433,21 @@ static int replace_db_table(TABLE *table, const char *db, acl_cache->clear(1); // Clear privilege cache if (old_row_exists) acl_update_db(combo.user.str,combo.host.str,db,rights); - else - if (rights) - acl_insert_db(combo.user.str,combo.host.str,db,rights); + else if (rights) + { + /* + If we did not have an already existing row, for users, we must always + insert an ACL_DB entry. For roles however, it is possible that one was + already created when DB privileges were propagated from other granted + roles onto the current role. For this case, first try to update the + existing entry, otherwise insert a new one. + */ + if (!combo.is_role() || + !acl_update_db(combo.user.str, combo.host.str, db, rights)) + { + acl_insert_db(combo.user.str,combo.host.str,db,rights); + } + } DBUG_RETURN(0); /* This could only happen if the grant tables got corrupted */ diff --git a/sql/structs.h b/sql/structs.h index ee61b8d3b3a..e141a8d7668 100644 --- a/sql/structs.h +++ b/sql/structs.h @@ -191,7 +191,7 @@ typedef int *(*update_var)(THD *, struct st_mysql_show_var *); typedef struct st_lex_user { LEX_STRING user, host, password, plugin, auth; - bool is_role() { return user.str[0] && !host.str[0]; } + bool is_role() const { return user.str[0] && !host.str[0]; } void set_lex_string(LEX_STRING *l, char *buf) { if (is_role()) From be758322e299f1dc80898efcf2e71c4c8f4b3f4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicen=C8=9Biu=20Ciorbaru?= Date: Sun, 17 Dec 2017 18:33:22 +0200 Subject: [PATCH 14/69] MDEV-12366: FLUSH PRIVILEGES can break hierarchy of roles Whenever we call merge_role_privileges on a role, we make use of the role->counter variable to check if all it's children have had their privileges merged. Only if all children have had their privileges merged, do we update the privileges on parent. This is done to prevent extra work. The same idea is employed during flush privileges. You only begin merging from "leaf" roles. The recursive calls will merge their parents at some point. A problem arises when we try to "re-merge" a parent. Take the following graph: {noformat} A (0) ---- C (2) ---- D (2) ---- USER / / B (0) ----/ / / E (0) --------------/ {noformat} In parentheses we have the "counter" value right before we start to iterate through the roles hash and propagate values. It represents the number of roles granted to the current role. The order in which we iterate through the roles hash is alphabetical. * First merge A, which leads to decreasing the counter for C to 1. Since C is not 0, we don't proceed with merging into C. * Second we merge B, which leads to decreasing the counter for C to 0. Now we proceed with merging into C. This leads to reducing the counter for D to 1 as part of C merge process. * Third as we iterate through the hash, we see that C has counter 0, thus we start the merge process *again*. This leads to reducing the counter for D to 0! We then attempt to merge D. * Fourth we start merging E. When E sees D as it's parent (according to the code) it attempts to reduce D's counter, which leads to overflow. Now D's counter is a very large number, thus E's privileges are not forwarded to D yet. To correct this behavior we must make sure to only start merging from initial leaf nodes. --- .../suite/roles/flush_roles-12366.result | 539 ++++++++++++++++++ mysql-test/suite/roles/flush_roles-12366.test | 379 ++++++++++++ sql/sql_acl.cc | 30 +- 3 files changed, 936 insertions(+), 12 deletions(-) create mode 100644 mysql-test/suite/roles/flush_roles-12366.result create mode 100644 mysql-test/suite/roles/flush_roles-12366.test diff --git a/mysql-test/suite/roles/flush_roles-12366.result b/mysql-test/suite/roles/flush_roles-12366.result new file mode 100644 index 00000000000..5897e480cd4 --- /dev/null +++ b/mysql-test/suite/roles/flush_roles-12366.result @@ -0,0 +1,539 @@ +# +# MDEV-12366: FLUSH PRIVILEGES can break hierarchy of roles +# +# This testcase contains a user, who is granted a master role +# operations_cluster. operations_cluster is granted 8 different roles +# who in turn each have 4 different roles granted to them. +# +# Only the leaf roles contain privileges to access databases. +# Make sure the user has access to all databases if the master role +# is granted to him. +# +CREATE USER u; +CREATE ROLE operations_cluster; +GRANT operations_cluster TO u; +CREATE DATABASE bob_live_sg; +CREATE TABLE bob_live_sg.a (i INT(10)); +CREATE TABLE bob_live_sg.b (i INT(10)); +CREATE TABLE bob_live_sg.c (i INT(10)); +CREATE TABLE bob_live_sg.d (i INT(10)); +CREATE DATABASE oms_live_sg; +CREATE TABLE oms_live_sg.a (i INT(10)); +CREATE TABLE oms_live_sg.b (i INT(10)); +CREATE TABLE oms_live_sg.c (i INT(10)); +CREATE TABLE oms_live_sg.d (i INT(10)); +CREATE DATABASE bob_live_ph; +CREATE TABLE bob_live_ph.a (i INT(10)); +CREATE TABLE bob_live_ph.b (i INT(10)); +CREATE TABLE bob_live_ph.c (i INT(10)); +CREATE TABLE bob_live_ph.d (i INT(10)); +CREATE DATABASE oms_live_ph; +CREATE TABLE oms_live_ph.a (i INT(10)); +CREATE TABLE oms_live_ph.b (i INT(10)); +CREATE TABLE oms_live_ph.c (i INT(10)); +CREATE TABLE oms_live_ph.d (i INT(10)); +CREATE DATABASE bob_live_id; +CREATE TABLE bob_live_id.a (i INT(10)); +CREATE TABLE bob_live_id.b (i INT(10)); +CREATE TABLE bob_live_id.c (i INT(10)); +CREATE TABLE bob_live_id.d (i INT(10)); +CREATE DATABASE oms_live_id; +CREATE TABLE oms_live_id.a (i INT(10)); +CREATE TABLE oms_live_id.b (i INT(10)); +CREATE TABLE oms_live_id.c (i INT(10)); +CREATE TABLE oms_live_id.d (i INT(10)); +CREATE DATABASE bob_live_hk; +CREATE TABLE bob_live_hk.a (i INT(10)); +CREATE TABLE bob_live_hk.b (i INT(10)); +CREATE TABLE bob_live_hk.c (i INT(10)); +CREATE TABLE bob_live_hk.d (i INT(10)); +CREATE DATABASE oms_live_hk; +CREATE TABLE oms_live_hk.a (i INT(10)); +CREATE TABLE oms_live_hk.b (i INT(10)); +CREATE TABLE oms_live_hk.c (i INT(10)); +CREATE TABLE oms_live_hk.d (i INT(10)); +CREATE DATABASE bob_live_vn; +CREATE TABLE bob_live_vn.a (i INT(10)); +CREATE TABLE bob_live_vn.b (i INT(10)); +CREATE TABLE bob_live_vn.c (i INT(10)); +CREATE TABLE bob_live_vn.d (i INT(10)); +CREATE DATABASE oms_live_vn; +CREATE TABLE oms_live_vn.a (i INT(10)); +CREATE TABLE oms_live_vn.b (i INT(10)); +CREATE TABLE oms_live_vn.c (i INT(10)); +CREATE TABLE oms_live_vn.d (i INT(10)); +CREATE DATABASE bob_live_tw; +CREATE TABLE bob_live_tw.a (i INT(10)); +CREATE TABLE bob_live_tw.b (i INT(10)); +CREATE TABLE bob_live_tw.c (i INT(10)); +CREATE TABLE bob_live_tw.d (i INT(10)); +CREATE DATABASE oms_live_tw; +CREATE TABLE oms_live_tw.a (i INT(10)); +CREATE TABLE oms_live_tw.b (i INT(10)); +CREATE TABLE oms_live_tw.c (i INT(10)); +CREATE TABLE oms_live_tw.d (i INT(10)); +CREATE DATABASE bob_live_my; +CREATE TABLE bob_live_my.a (i INT(10)); +CREATE TABLE bob_live_my.b (i INT(10)); +CREATE TABLE bob_live_my.c (i INT(10)); +CREATE TABLE bob_live_my.d (i INT(10)); +CREATE DATABASE oms_live_my; +CREATE TABLE oms_live_my.a (i INT(10)); +CREATE TABLE oms_live_my.b (i INT(10)); +CREATE TABLE oms_live_my.c (i INT(10)); +CREATE TABLE oms_live_my.d (i INT(10)); +CREATE DATABASE bob_live_th; +CREATE TABLE bob_live_th.a (i INT(10)); +CREATE TABLE bob_live_th.b (i INT(10)); +CREATE TABLE bob_live_th.c (i INT(10)); +CREATE TABLE bob_live_th.d (i INT(10)); +CREATE DATABASE oms_live_th; +CREATE TABLE oms_live_th.a (i INT(10)); +CREATE TABLE oms_live_th.b (i INT(10)); +CREATE TABLE oms_live_th.c (i INT(10)); +CREATE TABLE oms_live_th.d (i INT(10)); +CREATE ROLE a_sg; +CREATE ROLE b_sg; +CREATE ROLE c_sg; +CREATE ROLE d_sg; +CREATE ROLE operations_sg; +GRANT a_sg TO operations_sg; +GRANT b_sg TO operations_sg; +GRANT c_sg TO operations_sg; +GRANT d_sg TO operations_sg; +GRANT SELECT ON bob_live_sg.a TO a_sg; +GRANT SELECT ON bob_live_sg.b TO b_sg; +GRANT SELECT ON bob_live_sg.c TO c_sg; +GRANT SELECT ON bob_live_sg.d TO d_sg; +GRANT SELECT ON oms_live_sg.a TO a_sg; +GRANT SELECT ON oms_live_sg.b TO b_sg; +GRANT SELECT ON oms_live_sg.c TO c_sg; +GRANT SELECT ON oms_live_sg.d TO d_sg; +CREATE ROLE a_ph; +CREATE ROLE b_ph; +CREATE ROLE c_ph; +CREATE ROLE d_ph; +CREATE ROLE operations_ph; +GRANT a_ph TO operations_ph; +GRANT b_ph TO operations_ph; +GRANT c_ph TO operations_ph; +GRANT d_ph TO operations_ph; +GRANT SELECT ON bob_live_ph.a TO a_ph; +GRANT SELECT ON bob_live_ph.b TO b_ph; +GRANT SELECT ON bob_live_ph.c TO c_ph; +GRANT SELECT ON bob_live_ph.d TO d_ph; +GRANT SELECT ON oms_live_ph.a TO a_ph; +GRANT SELECT ON oms_live_ph.b TO b_ph; +GRANT SELECT ON oms_live_ph.c TO c_ph; +GRANT SELECT ON oms_live_ph.d TO d_ph; +CREATE ROLE a_id; +CREATE ROLE b_id; +CREATE ROLE c_id; +CREATE ROLE d_id; +CREATE ROLE operations_id; +GRANT a_id TO operations_id; +GRANT b_id TO operations_id; +GRANT c_id TO operations_id; +GRANT d_id TO operations_id; +GRANT SELECT ON bob_live_id.a TO a_id; +GRANT SELECT ON bob_live_id.b TO b_id; +GRANT SELECT ON bob_live_id.c TO c_id; +GRANT SELECT ON bob_live_id.d TO d_id; +GRANT SELECT ON oms_live_id.a TO a_id; +GRANT SELECT ON oms_live_id.b TO b_id; +GRANT SELECT ON oms_live_id.c TO c_id; +GRANT SELECT ON oms_live_id.d TO d_id; +CREATE ROLE a_hk; +CREATE ROLE b_hk; +CREATE ROLE c_hk; +CREATE ROLE d_hk; +CREATE ROLE operations_hk; +GRANT a_hk TO operations_hk; +GRANT b_hk TO operations_hk; +GRANT c_hk TO operations_hk; +GRANT d_hk TO operations_hk; +GRANT SELECT ON bob_live_hk.a TO a_hk; +GRANT SELECT ON bob_live_hk.b TO b_hk; +GRANT SELECT ON bob_live_hk.c TO c_hk; +GRANT SELECT ON bob_live_hk.d TO d_hk; +GRANT SELECT ON oms_live_hk.a TO a_hk; +GRANT SELECT ON oms_live_hk.b TO b_hk; +GRANT SELECT ON oms_live_hk.c TO c_hk; +GRANT SELECT ON oms_live_hk.d TO d_hk; +CREATE ROLE a_vn; +CREATE ROLE b_vn; +CREATE ROLE c_vn; +CREATE ROLE d_vn; +CREATE ROLE operations_vn; +GRANT a_vn TO operations_vn; +GRANT b_vn TO operations_vn; +GRANT c_vn TO operations_vn; +GRANT d_vn TO operations_vn; +GRANT SELECT ON bob_live_vn.a TO a_vn; +GRANT SELECT ON bob_live_vn.b TO b_vn; +GRANT SELECT ON bob_live_vn.c TO c_vn; +GRANT SELECT ON bob_live_vn.d TO d_vn; +GRANT SELECT ON oms_live_vn.a TO a_vn; +GRANT SELECT ON oms_live_vn.b TO b_vn; +GRANT SELECT ON oms_live_vn.c TO c_vn; +GRANT SELECT ON oms_live_vn.d TO d_vn; +CREATE ROLE a_tw; +CREATE ROLE b_tw; +CREATE ROLE c_tw; +CREATE ROLE d_tw; +CREATE ROLE operations_tw; +GRANT a_tw TO operations_tw; +GRANT b_tw TO operations_tw; +GRANT c_tw TO operations_tw; +GRANT d_tw TO operations_tw; +GRANT SELECT ON bob_live_tw.a TO a_tw; +GRANT SELECT ON bob_live_tw.b TO b_tw; +GRANT SELECT ON bob_live_tw.c TO c_tw; +GRANT SELECT ON bob_live_tw.d TO d_tw; +GRANT SELECT ON oms_live_tw.a TO a_tw; +GRANT SELECT ON oms_live_tw.b TO b_tw; +GRANT SELECT ON oms_live_tw.c TO c_tw; +GRANT SELECT ON oms_live_tw.d TO d_tw; +CREATE ROLE a_my; +CREATE ROLE b_my; +CREATE ROLE c_my; +CREATE ROLE d_my; +CREATE ROLE operations_my; +GRANT a_my TO operations_my; +GRANT b_my TO operations_my; +GRANT c_my TO operations_my; +GRANT d_my TO operations_my; +GRANT SELECT ON bob_live_my.a TO a_my; +GRANT SELECT ON bob_live_my.b TO b_my; +GRANT SELECT ON bob_live_my.c TO c_my; +GRANT SELECT ON bob_live_my.d TO d_my; +GRANT SELECT ON oms_live_my.a TO a_my; +GRANT SELECT ON oms_live_my.b TO b_my; +GRANT SELECT ON oms_live_my.c TO c_my; +GRANT SELECT ON oms_live_my.d TO d_my; +CREATE ROLE a_th; +CREATE ROLE b_th; +CREATE ROLE c_th; +CREATE ROLE d_th; +CREATE ROLE operations_th; +GRANT a_th TO operations_th; +GRANT b_th TO operations_th; +GRANT c_th TO operations_th; +GRANT d_th TO operations_th; +GRANT SELECT ON bob_live_th.a TO a_th; +GRANT SELECT ON bob_live_th.b TO b_th; +GRANT SELECT ON bob_live_th.c TO c_th; +GRANT SELECT ON bob_live_th.d TO d_th; +GRANT SELECT ON oms_live_th.a TO a_th; +GRANT SELECT ON oms_live_th.b TO b_th; +GRANT SELECT ON oms_live_th.c TO c_th; +GRANT SELECT ON oms_live_th.d TO d_th; +GRANT operations_sg TO operations_cluster; +GRANT operations_ph TO operations_cluster; +GRANT operations_id TO operations_cluster; +GRANT operations_hk TO operations_cluster; +GRANT operations_vn TO operations_cluster; +GRANT operations_tw TO operations_cluster; +GRANT operations_my TO operations_cluster; +GRANT operations_th TO operations_cluster; +SHOW DATABASES; +Database +information_schema +test +SET ROLE operations_cluster; +SHOW DATABASES; +Database +bob_live_hk +bob_live_id +bob_live_my +bob_live_ph +bob_live_sg +bob_live_th +bob_live_tw +bob_live_vn +information_schema +oms_live_hk +oms_live_id +oms_live_my +oms_live_ph +oms_live_sg +oms_live_th +oms_live_tw +oms_live_vn +test +SELECT COUNT(1) FROM oms_live_sg.a; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_sg.b; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_sg.c; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_sg.d; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_ph.a; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_ph.b; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_ph.c; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_ph.d; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_id.a; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_id.b; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_id.c; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_id.d; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_hk.a; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_hk.b; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_hk.c; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_hk.d; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_vn.a; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_vn.b; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_vn.c; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_vn.d; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_tw.a; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_tw.b; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_tw.c; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_tw.d; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_my.a; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_my.b; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_my.c; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_my.d; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_th.a; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_th.b; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_th.c; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_th.d; +COUNT(1) +0 +FLUSH PRIVILEGES; +SHOW DATABASES; +Database +information_schema +test +SET ROLE operations_cluster; +SHOW DATABASES; +Database +bob_live_hk +bob_live_id +bob_live_my +bob_live_ph +bob_live_sg +bob_live_th +bob_live_tw +bob_live_vn +information_schema +oms_live_hk +oms_live_id +oms_live_my +oms_live_ph +oms_live_sg +oms_live_th +oms_live_tw +oms_live_vn +test +SELECT COUNT(1) FROM oms_live_sg.a; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_sg.b; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_sg.c; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_sg.d; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_ph.a; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_ph.b; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_ph.c; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_ph.d; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_id.a; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_id.b; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_id.c; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_id.d; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_hk.a; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_hk.b; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_hk.c; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_hk.d; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_vn.a; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_vn.b; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_vn.c; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_vn.d; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_tw.a; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_tw.b; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_tw.c; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_tw.d; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_my.a; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_my.b; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_my.c; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_my.d; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_th.a; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_th.b; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_th.c; +COUNT(1) +0 +SELECT COUNT(1) FROM oms_live_th.d; +COUNT(1) +0 +DROP DATABASE bob_live_sg; +DROP DATABASE oms_live_sg; +DROP DATABASE bob_live_ph; +DROP DATABASE oms_live_ph; +DROP DATABASE bob_live_id; +DROP DATABASE oms_live_id; +DROP DATABASE bob_live_hk; +DROP DATABASE oms_live_hk; +DROP DATABASE bob_live_vn; +DROP DATABASE oms_live_vn; +DROP DATABASE bob_live_tw; +DROP DATABASE oms_live_tw; +DROP DATABASE bob_live_my; +DROP DATABASE oms_live_my; +DROP DATABASE bob_live_th; +DROP DATABASE oms_live_th; +DROP ROLE operations_sg; +DROP ROLE a_sg; +DROP ROLE b_sg; +DROP ROLE c_sg; +DROP ROLE d_sg; +DROP ROLE operations_ph; +DROP ROLE a_ph; +DROP ROLE b_ph; +DROP ROLE c_ph; +DROP ROLE d_ph; +DROP ROLE operations_id; +DROP ROLE a_id; +DROP ROLE b_id; +DROP ROLE c_id; +DROP ROLE d_id; +DROP ROLE operations_hk; +DROP ROLE a_hk; +DROP ROLE b_hk; +DROP ROLE c_hk; +DROP ROLE d_hk; +DROP ROLE operations_vn; +DROP ROLE a_vn; +DROP ROLE b_vn; +DROP ROLE c_vn; +DROP ROLE d_vn; +DROP ROLE operations_tw; +DROP ROLE a_tw; +DROP ROLE b_tw; +DROP ROLE c_tw; +DROP ROLE d_tw; +DROP ROLE operations_my; +DROP ROLE a_my; +DROP ROLE b_my; +DROP ROLE c_my; +DROP ROLE d_my; +DROP ROLE operations_th; +DROP ROLE a_th; +DROP ROLE b_th; +DROP ROLE c_th; +DROP ROLE d_th; +DROP USER u; +DROP ROLE operations_cluster; diff --git a/mysql-test/suite/roles/flush_roles-12366.test b/mysql-test/suite/roles/flush_roles-12366.test new file mode 100644 index 00000000000..343ac4abf72 --- /dev/null +++ b/mysql-test/suite/roles/flush_roles-12366.test @@ -0,0 +1,379 @@ +--source include/not_embedded.inc +--echo # +--echo # MDEV-12366: FLUSH PRIVILEGES can break hierarchy of roles +--echo # +--echo # This testcase contains a user, who is granted a master role +--echo # operations_cluster. operations_cluster is granted 8 different roles +--echo # who in turn each have 4 different roles granted to them. +--echo # +--echo # Only the leaf roles contain privileges to access databases. +--echo # Make sure the user has access to all databases if the master role +--echo # is granted to him. +--echo # +CREATE USER u; +CREATE ROLE operations_cluster; +GRANT operations_cluster TO u; +CREATE DATABASE bob_live_sg; +CREATE TABLE bob_live_sg.a (i INT(10)); +CREATE TABLE bob_live_sg.b (i INT(10)); +CREATE TABLE bob_live_sg.c (i INT(10)); +CREATE TABLE bob_live_sg.d (i INT(10)); +CREATE DATABASE oms_live_sg; +CREATE TABLE oms_live_sg.a (i INT(10)); +CREATE TABLE oms_live_sg.b (i INT(10)); +CREATE TABLE oms_live_sg.c (i INT(10)); +CREATE TABLE oms_live_sg.d (i INT(10)); +CREATE DATABASE bob_live_ph; +CREATE TABLE bob_live_ph.a (i INT(10)); +CREATE TABLE bob_live_ph.b (i INT(10)); +CREATE TABLE bob_live_ph.c (i INT(10)); +CREATE TABLE bob_live_ph.d (i INT(10)); +CREATE DATABASE oms_live_ph; +CREATE TABLE oms_live_ph.a (i INT(10)); +CREATE TABLE oms_live_ph.b (i INT(10)); +CREATE TABLE oms_live_ph.c (i INT(10)); +CREATE TABLE oms_live_ph.d (i INT(10)); +CREATE DATABASE bob_live_id; +CREATE TABLE bob_live_id.a (i INT(10)); +CREATE TABLE bob_live_id.b (i INT(10)); +CREATE TABLE bob_live_id.c (i INT(10)); +CREATE TABLE bob_live_id.d (i INT(10)); +CREATE DATABASE oms_live_id; +CREATE TABLE oms_live_id.a (i INT(10)); +CREATE TABLE oms_live_id.b (i INT(10)); +CREATE TABLE oms_live_id.c (i INT(10)); +CREATE TABLE oms_live_id.d (i INT(10)); +CREATE DATABASE bob_live_hk; +CREATE TABLE bob_live_hk.a (i INT(10)); +CREATE TABLE bob_live_hk.b (i INT(10)); +CREATE TABLE bob_live_hk.c (i INT(10)); +CREATE TABLE bob_live_hk.d (i INT(10)); +CREATE DATABASE oms_live_hk; +CREATE TABLE oms_live_hk.a (i INT(10)); +CREATE TABLE oms_live_hk.b (i INT(10)); +CREATE TABLE oms_live_hk.c (i INT(10)); +CREATE TABLE oms_live_hk.d (i INT(10)); +CREATE DATABASE bob_live_vn; +CREATE TABLE bob_live_vn.a (i INT(10)); +CREATE TABLE bob_live_vn.b (i INT(10)); +CREATE TABLE bob_live_vn.c (i INT(10)); +CREATE TABLE bob_live_vn.d (i INT(10)); +CREATE DATABASE oms_live_vn; +CREATE TABLE oms_live_vn.a (i INT(10)); +CREATE TABLE oms_live_vn.b (i INT(10)); +CREATE TABLE oms_live_vn.c (i INT(10)); +CREATE TABLE oms_live_vn.d (i INT(10)); +CREATE DATABASE bob_live_tw; +CREATE TABLE bob_live_tw.a (i INT(10)); +CREATE TABLE bob_live_tw.b (i INT(10)); +CREATE TABLE bob_live_tw.c (i INT(10)); +CREATE TABLE bob_live_tw.d (i INT(10)); +CREATE DATABASE oms_live_tw; +CREATE TABLE oms_live_tw.a (i INT(10)); +CREATE TABLE oms_live_tw.b (i INT(10)); +CREATE TABLE oms_live_tw.c (i INT(10)); +CREATE TABLE oms_live_tw.d (i INT(10)); +CREATE DATABASE bob_live_my; +CREATE TABLE bob_live_my.a (i INT(10)); +CREATE TABLE bob_live_my.b (i INT(10)); +CREATE TABLE bob_live_my.c (i INT(10)); +CREATE TABLE bob_live_my.d (i INT(10)); +CREATE DATABASE oms_live_my; +CREATE TABLE oms_live_my.a (i INT(10)); +CREATE TABLE oms_live_my.b (i INT(10)); +CREATE TABLE oms_live_my.c (i INT(10)); +CREATE TABLE oms_live_my.d (i INT(10)); +CREATE DATABASE bob_live_th; +CREATE TABLE bob_live_th.a (i INT(10)); +CREATE TABLE bob_live_th.b (i INT(10)); +CREATE TABLE bob_live_th.c (i INT(10)); +CREATE TABLE bob_live_th.d (i INT(10)); +CREATE DATABASE oms_live_th; +CREATE TABLE oms_live_th.a (i INT(10)); +CREATE TABLE oms_live_th.b (i INT(10)); +CREATE TABLE oms_live_th.c (i INT(10)); +CREATE TABLE oms_live_th.d (i INT(10)); +CREATE ROLE a_sg; +CREATE ROLE b_sg; +CREATE ROLE c_sg; +CREATE ROLE d_sg; +CREATE ROLE operations_sg; +GRANT a_sg TO operations_sg; +GRANT b_sg TO operations_sg; +GRANT c_sg TO operations_sg; +GRANT d_sg TO operations_sg; +GRANT SELECT ON bob_live_sg.a TO a_sg; +GRANT SELECT ON bob_live_sg.b TO b_sg; +GRANT SELECT ON bob_live_sg.c TO c_sg; +GRANT SELECT ON bob_live_sg.d TO d_sg; +GRANT SELECT ON oms_live_sg.a TO a_sg; +GRANT SELECT ON oms_live_sg.b TO b_sg; +GRANT SELECT ON oms_live_sg.c TO c_sg; +GRANT SELECT ON oms_live_sg.d TO d_sg; +CREATE ROLE a_ph; +CREATE ROLE b_ph; +CREATE ROLE c_ph; +CREATE ROLE d_ph; +CREATE ROLE operations_ph; +GRANT a_ph TO operations_ph; +GRANT b_ph TO operations_ph; +GRANT c_ph TO operations_ph; +GRANT d_ph TO operations_ph; +GRANT SELECT ON bob_live_ph.a TO a_ph; +GRANT SELECT ON bob_live_ph.b TO b_ph; +GRANT SELECT ON bob_live_ph.c TO c_ph; +GRANT SELECT ON bob_live_ph.d TO d_ph; +GRANT SELECT ON oms_live_ph.a TO a_ph; +GRANT SELECT ON oms_live_ph.b TO b_ph; +GRANT SELECT ON oms_live_ph.c TO c_ph; +GRANT SELECT ON oms_live_ph.d TO d_ph; +CREATE ROLE a_id; +CREATE ROLE b_id; +CREATE ROLE c_id; +CREATE ROLE d_id; +CREATE ROLE operations_id; +GRANT a_id TO operations_id; +GRANT b_id TO operations_id; +GRANT c_id TO operations_id; +GRANT d_id TO operations_id; +GRANT SELECT ON bob_live_id.a TO a_id; +GRANT SELECT ON bob_live_id.b TO b_id; +GRANT SELECT ON bob_live_id.c TO c_id; +GRANT SELECT ON bob_live_id.d TO d_id; +GRANT SELECT ON oms_live_id.a TO a_id; +GRANT SELECT ON oms_live_id.b TO b_id; +GRANT SELECT ON oms_live_id.c TO c_id; +GRANT SELECT ON oms_live_id.d TO d_id; +CREATE ROLE a_hk; +CREATE ROLE b_hk; +CREATE ROLE c_hk; +CREATE ROLE d_hk; +CREATE ROLE operations_hk; +GRANT a_hk TO operations_hk; +GRANT b_hk TO operations_hk; +GRANT c_hk TO operations_hk; +GRANT d_hk TO operations_hk; +GRANT SELECT ON bob_live_hk.a TO a_hk; +GRANT SELECT ON bob_live_hk.b TO b_hk; +GRANT SELECT ON bob_live_hk.c TO c_hk; +GRANT SELECT ON bob_live_hk.d TO d_hk; +GRANT SELECT ON oms_live_hk.a TO a_hk; +GRANT SELECT ON oms_live_hk.b TO b_hk; +GRANT SELECT ON oms_live_hk.c TO c_hk; +GRANT SELECT ON oms_live_hk.d TO d_hk; +CREATE ROLE a_vn; +CREATE ROLE b_vn; +CREATE ROLE c_vn; +CREATE ROLE d_vn; +CREATE ROLE operations_vn; +GRANT a_vn TO operations_vn; +GRANT b_vn TO operations_vn; +GRANT c_vn TO operations_vn; +GRANT d_vn TO operations_vn; +GRANT SELECT ON bob_live_vn.a TO a_vn; +GRANT SELECT ON bob_live_vn.b TO b_vn; +GRANT SELECT ON bob_live_vn.c TO c_vn; +GRANT SELECT ON bob_live_vn.d TO d_vn; +GRANT SELECT ON oms_live_vn.a TO a_vn; +GRANT SELECT ON oms_live_vn.b TO b_vn; +GRANT SELECT ON oms_live_vn.c TO c_vn; +GRANT SELECT ON oms_live_vn.d TO d_vn; +CREATE ROLE a_tw; +CREATE ROLE b_tw; +CREATE ROLE c_tw; +CREATE ROLE d_tw; +CREATE ROLE operations_tw; +GRANT a_tw TO operations_tw; +GRANT b_tw TO operations_tw; +GRANT c_tw TO operations_tw; +GRANT d_tw TO operations_tw; +GRANT SELECT ON bob_live_tw.a TO a_tw; +GRANT SELECT ON bob_live_tw.b TO b_tw; +GRANT SELECT ON bob_live_tw.c TO c_tw; +GRANT SELECT ON bob_live_tw.d TO d_tw; +GRANT SELECT ON oms_live_tw.a TO a_tw; +GRANT SELECT ON oms_live_tw.b TO b_tw; +GRANT SELECT ON oms_live_tw.c TO c_tw; +GRANT SELECT ON oms_live_tw.d TO d_tw; +CREATE ROLE a_my; +CREATE ROLE b_my; +CREATE ROLE c_my; +CREATE ROLE d_my; +CREATE ROLE operations_my; +GRANT a_my TO operations_my; +GRANT b_my TO operations_my; +GRANT c_my TO operations_my; +GRANT d_my TO operations_my; +GRANT SELECT ON bob_live_my.a TO a_my; +GRANT SELECT ON bob_live_my.b TO b_my; +GRANT SELECT ON bob_live_my.c TO c_my; +GRANT SELECT ON bob_live_my.d TO d_my; +GRANT SELECT ON oms_live_my.a TO a_my; +GRANT SELECT ON oms_live_my.b TO b_my; +GRANT SELECT ON oms_live_my.c TO c_my; +GRANT SELECT ON oms_live_my.d TO d_my; +CREATE ROLE a_th; +CREATE ROLE b_th; +CREATE ROLE c_th; +CREATE ROLE d_th; +CREATE ROLE operations_th; +GRANT a_th TO operations_th; +GRANT b_th TO operations_th; +GRANT c_th TO operations_th; +GRANT d_th TO operations_th; +GRANT SELECT ON bob_live_th.a TO a_th; +GRANT SELECT ON bob_live_th.b TO b_th; +GRANT SELECT ON bob_live_th.c TO c_th; +GRANT SELECT ON bob_live_th.d TO d_th; +GRANT SELECT ON oms_live_th.a TO a_th; +GRANT SELECT ON oms_live_th.b TO b_th; +GRANT SELECT ON oms_live_th.c TO c_th; +GRANT SELECT ON oms_live_th.d TO d_th; +GRANT operations_sg TO operations_cluster; +GRANT operations_ph TO operations_cluster; +GRANT operations_id TO operations_cluster; +GRANT operations_hk TO operations_cluster; +GRANT operations_vn TO operations_cluster; +GRANT operations_tw TO operations_cluster; +GRANT operations_my TO operations_cluster; +GRANT operations_th TO operations_cluster; + +connect(con1,localhost,u,,); +SHOW DATABASES; +SET ROLE operations_cluster; +SHOW DATABASES; +SELECT COUNT(1) FROM oms_live_sg.a; +SELECT COUNT(1) FROM oms_live_sg.b; +SELECT COUNT(1) FROM oms_live_sg.c; +SELECT COUNT(1) FROM oms_live_sg.d; +SELECT COUNT(1) FROM oms_live_ph.a; +SELECT COUNT(1) FROM oms_live_ph.b; +SELECT COUNT(1) FROM oms_live_ph.c; +SELECT COUNT(1) FROM oms_live_ph.d; +SELECT COUNT(1) FROM oms_live_id.a; +SELECT COUNT(1) FROM oms_live_id.b; +SELECT COUNT(1) FROM oms_live_id.c; +SELECT COUNT(1) FROM oms_live_id.d; +SELECT COUNT(1) FROM oms_live_hk.a; +SELECT COUNT(1) FROM oms_live_hk.b; +SELECT COUNT(1) FROM oms_live_hk.c; +SELECT COUNT(1) FROM oms_live_hk.d; +SELECT COUNT(1) FROM oms_live_vn.a; +SELECT COUNT(1) FROM oms_live_vn.b; +SELECT COUNT(1) FROM oms_live_vn.c; +SELECT COUNT(1) FROM oms_live_vn.d; +SELECT COUNT(1) FROM oms_live_tw.a; +SELECT COUNT(1) FROM oms_live_tw.b; +SELECT COUNT(1) FROM oms_live_tw.c; +SELECT COUNT(1) FROM oms_live_tw.d; +SELECT COUNT(1) FROM oms_live_my.a; +SELECT COUNT(1) FROM oms_live_my.b; +SELECT COUNT(1) FROM oms_live_my.c; +SELECT COUNT(1) FROM oms_live_my.d; +SELECT COUNT(1) FROM oms_live_th.a; +SELECT COUNT(1) FROM oms_live_th.b; +SELECT COUNT(1) FROM oms_live_th.c; +SELECT COUNT(1) FROM oms_live_th.d; + + +connect(con2,localhost,root,,); +FLUSH PRIVILEGES; + +connect(con3,localhost,u,,); +SHOW DATABASES; +SET ROLE operations_cluster; +SHOW DATABASES; +SELECT COUNT(1) FROM oms_live_sg.a; +SELECT COUNT(1) FROM oms_live_sg.b; +SELECT COUNT(1) FROM oms_live_sg.c; +SELECT COUNT(1) FROM oms_live_sg.d; +SELECT COUNT(1) FROM oms_live_ph.a; +SELECT COUNT(1) FROM oms_live_ph.b; +SELECT COUNT(1) FROM oms_live_ph.c; +SELECT COUNT(1) FROM oms_live_ph.d; +SELECT COUNT(1) FROM oms_live_id.a; +SELECT COUNT(1) FROM oms_live_id.b; +SELECT COUNT(1) FROM oms_live_id.c; +SELECT COUNT(1) FROM oms_live_id.d; +SELECT COUNT(1) FROM oms_live_hk.a; +SELECT COUNT(1) FROM oms_live_hk.b; +SELECT COUNT(1) FROM oms_live_hk.c; +SELECT COUNT(1) FROM oms_live_hk.d; +SELECT COUNT(1) FROM oms_live_vn.a; +SELECT COUNT(1) FROM oms_live_vn.b; +SELECT COUNT(1) FROM oms_live_vn.c; +SELECT COUNT(1) FROM oms_live_vn.d; +SELECT COUNT(1) FROM oms_live_tw.a; +SELECT COUNT(1) FROM oms_live_tw.b; +SELECT COUNT(1) FROM oms_live_tw.c; +SELECT COUNT(1) FROM oms_live_tw.d; +SELECT COUNT(1) FROM oms_live_my.a; +SELECT COUNT(1) FROM oms_live_my.b; +SELECT COUNT(1) FROM oms_live_my.c; +SELECT COUNT(1) FROM oms_live_my.d; +SELECT COUNT(1) FROM oms_live_th.a; +SELECT COUNT(1) FROM oms_live_th.b; +SELECT COUNT(1) FROM oms_live_th.c; +SELECT COUNT(1) FROM oms_live_th.d; + + +connect(con4,localhost,root,,); + +DROP DATABASE bob_live_sg; +DROP DATABASE oms_live_sg; +DROP DATABASE bob_live_ph; +DROP DATABASE oms_live_ph; +DROP DATABASE bob_live_id; +DROP DATABASE oms_live_id; +DROP DATABASE bob_live_hk; +DROP DATABASE oms_live_hk; +DROP DATABASE bob_live_vn; +DROP DATABASE oms_live_vn; +DROP DATABASE bob_live_tw; +DROP DATABASE oms_live_tw; +DROP DATABASE bob_live_my; +DROP DATABASE oms_live_my; +DROP DATABASE bob_live_th; +DROP DATABASE oms_live_th; +DROP ROLE operations_sg; +DROP ROLE a_sg; +DROP ROLE b_sg; +DROP ROLE c_sg; +DROP ROLE d_sg; +DROP ROLE operations_ph; +DROP ROLE a_ph; +DROP ROLE b_ph; +DROP ROLE c_ph; +DROP ROLE d_ph; +DROP ROLE operations_id; +DROP ROLE a_id; +DROP ROLE b_id; +DROP ROLE c_id; +DROP ROLE d_id; +DROP ROLE operations_hk; +DROP ROLE a_hk; +DROP ROLE b_hk; +DROP ROLE c_hk; +DROP ROLE d_hk; +DROP ROLE operations_vn; +DROP ROLE a_vn; +DROP ROLE b_vn; +DROP ROLE c_vn; +DROP ROLE d_vn; +DROP ROLE operations_tw; +DROP ROLE a_tw; +DROP ROLE b_tw; +DROP ROLE c_tw; +DROP ROLE d_tw; +DROP ROLE operations_my; +DROP ROLE a_my; +DROP ROLE b_my; +DROP ROLE c_my; +DROP ROLE d_my; +DROP ROLE operations_th; +DROP ROLE a_th; +DROP ROLE b_th; +DROP ROLE c_th; +DROP ROLE d_th; +DROP USER u; +DROP ROLE operations_cluster; diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 1b25871b664..27292105dde 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -5362,6 +5362,7 @@ static int merge_role_privileges(ACL_ROLE *role __attribute__((unused)), { PRIVS_TO_MERGE *data= (PRIVS_TO_MERGE *)context; + DBUG_ASSERT(grantee->counter > 0); if (--grantee->counter) return 1; // don't recurse into grantee just yet @@ -6554,16 +6555,14 @@ end_index_init: DBUG_RETURN(return_val); } - -my_bool role_propagate_grants_action(void *ptr, void *unused __attribute__((unused))) +static my_bool collect_leaf_roles(void *role_ptr, + void *roles_array) { - ACL_ROLE *role= (ACL_ROLE *)ptr; - if (role->counter) - return 0; - - mysql_mutex_assert_owner(&acl_cache->lock); - PRIVS_TO_MERGE data= { PRIVS_TO_MERGE::ALL, 0, 0 }; - traverse_role_graph_up(role, &data, NULL, merge_role_privileges); + ACL_ROLE *role= static_cast(role_ptr); + Dynamic_array *array= + static_cast *>(roles_array); + if (!role->counter) + array->push(role); return 0; } @@ -6614,7 +6613,7 @@ my_bool grant_reload(THD *thd) obtaining LOCK_grant rwlock. */ if (open_and_lock_tables(thd, tables, FALSE, MYSQL_LOCK_IGNORE_TIMEOUT)) - goto end; + DBUG_RETURN(1); mysql_rwlock_wrlock(&LOCK_grant); grant_version++; @@ -6646,14 +6645,21 @@ my_bool grant_reload(THD *thd) } mysql_mutex_lock(&acl_cache->lock); - my_hash_iterate(&acl_roles, role_propagate_grants_action, NULL); + Dynamic_array leaf_roles; + my_hash_iterate(&acl_roles, collect_leaf_roles, &leaf_roles); + PRIVS_TO_MERGE data= { PRIVS_TO_MERGE::ALL, 0, 0 }; + for (size_t i= 0; i < leaf_roles.elements(); i++) + { + traverse_role_graph_up(leaf_roles.at(i), &data, NULL, + merge_role_privileges); + } + mysql_mutex_unlock(&acl_cache->lock); mysql_rwlock_unlock(&LOCK_grant); close_mysql_tables(thd); -end: DBUG_RETURN(return_val); } From ed7e4b68ed59fb7c34dc06625dfe378e71d1e8a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Tue, 19 Dec 2017 16:45:10 +0200 Subject: [PATCH 15/69] DEV-14701: install_db shows corruption for rest encryption with innodb_data_file_path=ibdata1:3M Problem was that crypt_data->min_key_version is not a reliable way to detect is tablespace encrypted and could lead that in first page of the second (page 192 and similarly for other files if more configured) system tablespace file used key_version is replaced with zero leading a corruption as in next startup page is though to be corrupted. Note that crypt_data->min_key_version is updated only after all pages from tablespace have been processed (i.e. key rotation is done) and flushed. fil_write_flushed_lsn Use crypt_data->should_encrypt() instead. --- storage/innobase/fil/fil0fil.cc | 4 +++- storage/xtradb/fil/fil0fil.cc | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index ac30f3c7a25..c9ecf3dab0b 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -2085,7 +2085,9 @@ fil_write_flushed_lsn( /* If tablespace is not encrypted, stamp flush_lsn to first page of all system tablespace datafiles to avoid unnecessary error messages on possible downgrade. */ - if (!space->crypt_data || space->crypt_data->min_key_version == 0) { + if (!space->crypt_data + || !space->crypt_data->should_encrypt()) { + fil_node_t* node; ulint sum_of_sizes = 0; diff --git a/storage/xtradb/fil/fil0fil.cc b/storage/xtradb/fil/fil0fil.cc index 00f2c44637e..9023b4446b5 100644 --- a/storage/xtradb/fil/fil0fil.cc +++ b/storage/xtradb/fil/fil0fil.cc @@ -2136,7 +2136,8 @@ fil_write_flushed_lsn( /* If tablespace is not encrypted, stamp flush_lsn to first page of all system tablespace datafiles to avoid unnecessary error messages on possible downgrade. */ - if (!space->crypt_data || space->crypt_data->min_key_version == 0) { + if (!space->crypt_data + || !space->crypt_data->should_encrypt()) { fil_node_t* node; ulint sum_of_sizes = 0; From 2cd316911309e3db4007aa224f7874bfbeb14032 Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Mon, 18 Dec 2017 17:15:48 +0400 Subject: [PATCH 16/69] MDEV-14265 - RPMLint warning: shared-lib-calls-exit find_type_or_exit() client helper did exit(1) on error, exit(1) moved to clients. mysql_read_default_options() did exit(1) on error, error is passed through and handled now. my_str_malloc_default() did exit(1) on error, replaced my_str_ allocator functions with normal my_malloc()/my_realloc()/my_free(). sql_connect.cc did many exit(1) on hash initialisation failure. Removed error check since my_hash_init() never fails. my_malloc() did exit(1) on error. Replaced with abort(). my_load_defaults() did exit(1) on error, replaced with return 2. my_load_defaults() still does exit(0) when invoked with --print-defaults. --- client/mysql.cc | 8 ++++-- client/mysqladmin.cc | 8 ++++-- client/mysqlbinlog.cc | 19 ++++++++++--- client/mysqlcheck.c | 8 ++++-- client/mysqldump.c | 8 ++++-- client/mysqlimport.c | 8 ++++-- client/mysqlshow.c | 8 ++++-- client/mysqlslap.c | 8 ++++-- client/mysqltest.cc | 8 ++++-- extra/mariabackup/xtrabackup.cc | 8 ++++-- include/m_string.h | 9 ------ include/mysql.h.pp | 2 -- include/typelib.h | 2 -- libmysqld/libmysqld.c | 3 ++ mysql-test/t/xml.test | 2 +- mysys/my_default.c | 6 ++-- mysys/my_malloc.c | 2 +- mysys/typelib.c | 12 -------- sql-common/client.c | 7 +++-- sql/mysqld.cc | 21 +------------- sql/sql_connect.cc | 49 ++++++++++----------------------- strings/CMakeLists.txt | 2 +- strings/ctype-tis620.c | 8 +++--- strings/my_vsnprintf.c | 6 ++-- strings/str_alloc.c | 41 --------------------------- strings/xml.c | 9 +++--- 26 files changed, 110 insertions(+), 162 deletions(-) delete mode 100644 strings/str_alloc.c diff --git a/client/mysql.cc b/client/mysql.cc index c043d054ea5..977085ebd42 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -1793,8 +1793,12 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), break; case OPT_MYSQL_PROTOCOL: #ifndef EMBEDDED_LIBRARY - opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib, - opt->name); + if ((opt_protocol= find_type_with_warning(argument, &sql_protocol_typelib, + opt->name)) <= 0) + { + sf_leaking_memory= 1; /* no memory leak reports here */ + exit(1); + } #endif break; case OPT_SERVER_ARG: diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc index ffdc73f99ad..897c2eb41c3 100644 --- a/client/mysqladmin.cc +++ b/client/mysqladmin.cc @@ -298,8 +298,12 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), #endif break; case OPT_MYSQL_PROTOCOL: - opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib, - opt->name); + if ((opt_protocol= find_type_with_warning(argument, &sql_protocol_typelib, + opt->name)) <= 0) + { + sf_leaking_memory= 1; /* no memory leak reports here */ + exit(1); + } break; } return 0; diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index c103061bbc5..b871a70ef01 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -1649,8 +1649,12 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), remote_opt= 1; break; case OPT_MYSQL_PROTOCOL: - opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib, - opt->name); + if ((opt_protocol= find_type_with_warning(argument, &sql_protocol_typelib, + opt->name)) <= 0) + { + sf_leaking_memory= 1; /* no memory leak reports here */ + exit(1); + } break; case OPT_START_DATETIME: start_datetime= convert_str_to_timestamp(start_datetime_str); @@ -1663,8 +1667,15 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), opt_base64_output_mode= BASE64_OUTPUT_ALWAYS; else { - opt_base64_output_mode= (enum_base64_output_mode) - (find_type_or_exit(argument, &base64_output_mode_typelib, opt->name)-1); + int val; + + if ((val= find_type_with_warning(argument, &base64_output_mode_typelib, + opt->name)) <= 0) + { + sf_leaking_memory= 1; /* no memory leak reports here */ + exit(1); + } + opt_base64_output_mode= (enum_base64_output_mode) (val - 1); } break; case OPT_REWRITE_DB: // db_from->db_to diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index c4ac58973f8..47cb38751eb 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -367,8 +367,12 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), print_version(); exit(0); break; case OPT_MYSQL_PROTOCOL: - opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib, - opt->name); + if ((opt_protocol= find_type_with_warning(argument, &sql_protocol_typelib, + opt->name)) <= 0) + { + sf_leaking_memory= 1; /* no memory leak reports here */ + exit(1); + } break; } diff --git a/client/mysqldump.c b/client/mysqldump.c index aead4caf506..5c0ec2a5510 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -956,8 +956,12 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), break; } case (int) OPT_MYSQL_PROTOCOL: - opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib, - opt->name); + if ((opt_protocol= find_type_with_warning(argument, &sql_protocol_typelib, + opt->name)) <= 0) + { + sf_leaking_memory= 1; /* no memory leak reports here */ + exit(1); + } break; } return 0; diff --git a/client/mysqlimport.c b/client/mysqlimport.c index 7f03cb355f8..9c84d4a62a6 100644 --- a/client/mysqlimport.c +++ b/client/mysqlimport.c @@ -249,8 +249,12 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), break; #endif case OPT_MYSQL_PROTOCOL: - opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib, - opt->name); + if ((opt_protocol= find_type_with_warning(argument, &sql_protocol_typelib, + opt->name)) <= 0) + { + sf_leaking_memory= 1; /* no memory leak reports here */ + exit(1); + } break; case '#': DBUG_PUSH(argument ? argument : "d:t:o"); diff --git a/client/mysqlshow.c b/client/mysqlshow.c index 6f434d6770d..f851c15106e 100644 --- a/client/mysqlshow.c +++ b/client/mysqlshow.c @@ -328,8 +328,12 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), #endif break; case OPT_MYSQL_PROTOCOL: - opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib, - opt->name); + if ((opt_protocol= find_type_with_warning(argument, &sql_protocol_typelib, + opt->name)) <= 0) + { + sf_leaking_memory= 1; /* no memory leak reports here */ + exit(1); + } break; case '#': DBUG_PUSH(argument ? argument : "d:t:o"); diff --git a/client/mysqlslap.c b/client/mysqlslap.c index a78bf35d51b..6a0b214305c 100644 --- a/client/mysqlslap.c +++ b/client/mysqlslap.c @@ -779,8 +779,12 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), #endif break; case OPT_MYSQL_PROTOCOL: - opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib, - opt->name); + if ((opt_protocol= find_type_with_warning(argument, &sql_protocol_typelib, + opt->name)) <= 0) + { + sf_leaking_memory= 1; /* no memory leak reports here */ + exit(1); + } break; case '#': DBUG_PUSH(argument ? argument : default_dbug_option); diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 155d0c4c092..2200462b2fe 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -7292,8 +7292,12 @@ get_one_option(int optid, const struct my_option *opt, char *argument) exit(0); case OPT_MYSQL_PROTOCOL: #ifndef EMBEDDED_LIBRARY - opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib, - opt->name); + if ((opt_protocol= find_type_with_warning(argument, &sql_protocol_typelib, + opt->name)) <= 0) + { + sf_leaking_memory= 1; /* no memory leak reports here */ + exit(1); + } #endif break; case '?': diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index eb1cbf4748d..437fc4aa7f9 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -1380,8 +1380,12 @@ xb_get_one_option(int optid, case OPT_PROTOCOL: if (argument) { - opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib, - opt->name); + if ((opt_protocol= find_type_with_warning(argument, &sql_protocol_typelib, + opt->name)) <= 0) + { + sf_leaking_memory= 1; /* no memory leak reports here */ + exit(1); + } } break; #include "sslopt-case.h" diff --git a/include/m_string.h b/include/m_string.h index 7437ea8b7cd..d088b510de5 100644 --- a/include/m_string.h +++ b/include/m_string.h @@ -64,15 +64,6 @@ extern "C" { #endif -/* - my_str_malloc(), my_str_realloc() and my_str_free() are assigned to - implementations in strings/alloc.c, but can be overridden in - the calling program. - */ -extern void *(*my_str_malloc)(size_t); -extern void *(*my_str_realloc)(void *, size_t); -extern void (*my_str_free)(void *); - #ifdef DBUG_OFF #if defined(HAVE_STPCPY) && MY_GNUC_PREREQ(3, 4) && !defined(__INTEL_COMPILER) #define strmov(A,B) __builtin_stpcpy((A),(B)) diff --git a/include/mysql.h.pp b/include/mysql.h.pp index 32d87b7391c..8936a716b90 100644 --- a/include/mysql.h.pp +++ b/include/mysql.h.pp @@ -221,8 +221,6 @@ typedef struct st_typelib { extern my_ulonglong find_typeset(char *x, TYPELIB *typelib,int *error_position); extern int find_type_with_warning(const char *x, TYPELIB *typelib, const char *option); -extern int find_type_or_exit(const char *x, TYPELIB *typelib, - const char *option); extern int find_type(const char *x, const TYPELIB *typelib, unsigned int flags); extern void make_type(char *to,unsigned int nr,TYPELIB *typelib); extern const char *get_type(TYPELIB *typelib,unsigned int nr); diff --git a/include/typelib.h b/include/typelib.h index 4504bea4ff7..ab5a0f0d258 100644 --- a/include/typelib.h +++ b/include/typelib.h @@ -29,8 +29,6 @@ typedef struct st_typelib { /* Different types saved here */ extern my_ulonglong find_typeset(char *x, TYPELIB *typelib,int *error_position); extern int find_type_with_warning(const char *x, TYPELIB *typelib, const char *option); -extern int find_type_or_exit(const char *x, TYPELIB *typelib, - const char *option); #define FIND_TYPE_BASIC 0 /** makes @c find_type() require the whole name, no prefix */ #define FIND_TYPE_NO_PREFIX (1 << 0) diff --git a/libmysqld/libmysqld.c b/libmysqld/libmysqld.c index 36728cf573c..543ab86643e 100644 --- a/libmysqld/libmysqld.c +++ b/libmysqld/libmysqld.c @@ -121,6 +121,9 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, my_free(mysql->options.my_cnf_file); my_free(mysql->options.my_cnf_group); mysql->options.my_cnf_file=mysql->options.my_cnf_group=0; + + if (mysql->options.protocol == UINT_MAX32) + goto error; } if (!db || !db[0]) diff --git a/mysql-test/t/xml.test b/mysql-test/t/xml.test index 371fcb72b0d..ae7e9058e26 100644 --- a/mysql-test/t/xml.test +++ b/mysql-test/t/xml.test @@ -713,7 +713,7 @@ FROM t1; SELECT UPDATEXML(txt, CONCAT('//', REPEAT('b', 63)), '63/63+') FROM t1; DROP TABLE t1; -# This will call my_str_realloc_mysqld() +# This will call realloc() CREATE TABLE t1 (a TEXT); INSERT INTO t1 VALUES (CONCAT('<', REPEAT('b',128),'>b128<',REPEAT('c',512),'>c512')); SELECT ExtractValue (a, CONCAT('//',REPEAT('c',512))) AS c512 FROM t1; diff --git a/mysys/my_default.c b/mysys/my_default.c index 655e9a57747..dba22c4e58b 100644 --- a/mysys/my_default.c +++ b/mysys/my_default.c @@ -487,8 +487,7 @@ int load_defaults(const char *conf_file, const char **groups, easily command line options override options in configuration files NOTES - In case of fatal error, the function will print a warning and do - exit(1) + In case of fatal error, the function will print a warning and returns 2 To free used memory one should call free_defaults() with the argument that was put in *argv @@ -641,8 +640,7 @@ int my_load_defaults(const char *conf_file, const char **groups, err: fprintf(stderr,"Fatal error in defaults handling. Program aborted\n"); - exit(1); - return 0; /* Keep compiler happy */ + return 2; } diff --git a/mysys/my_malloc.c b/mysys/my_malloc.c index dc02d3896bd..719c13a040e 100644 --- a/mysys/my_malloc.c +++ b/mysys/my_malloc.c @@ -109,7 +109,7 @@ void *my_malloc(size_t size, myf my_flags) my_error(EE_OUTOFMEMORY, MYF(ME_BELL + ME_WAITTANG + ME_NOREFRESH + ME_FATALERROR),size); if (my_flags & MY_FAE) - exit(1); + abort(); } else { diff --git a/mysys/typelib.c b/mysys/typelib.c index 96842b1a3ad..9ca0847570f 100644 --- a/mysys/typelib.c +++ b/mysys/typelib.c @@ -45,18 +45,6 @@ int find_type_with_warning(const char *x, TYPELIB *typelib, const char *option) } -int find_type_or_exit(const char *x, TYPELIB *typelib, const char *option) -{ - int res; - if ((res= find_type_with_warning(x, typelib, option)) <= 0) - { - sf_leaking_memory= 1; /* no memory leak reports here */ - exit(1); - } - return res; -} - - /** Search after a string in a list of strings. Endspace in x is not compared. diff --git a/sql-common/client.c b/sql-common/client.c index ea686a79a1f..da18a0fdea1 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -1232,11 +1232,12 @@ void mysql_read_default_options(struct st_mysql_options *options, options->max_allowed_packet= atoi(opt_arg); break; case OPT_protocol: - if ((options->protocol= find_type(opt_arg, &sql_protocol_typelib, + if (options->protocol != UINT_MAX32 && + (options->protocol= find_type(opt_arg, &sql_protocol_typelib, FIND_TYPE_BASIC)) <= 0) { fprintf(stderr, "Unknown option to protocol: %s\n", opt_arg); - exit(1); + options->protocol= UINT_MAX32; } break; case OPT_shared_memory_base_name: @@ -3133,6 +3134,8 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, my_free(mysql->options.my_cnf_file); my_free(mysql->options.my_cnf_group); mysql->options.my_cnf_file=mysql->options.my_cnf_group=0; + if (mysql->options.protocol == UINT_MAX32) + goto error; } /* Some empty-string-tests are done because of ODBC */ diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 8b7fdd2f705..227c3eb6f99 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -3542,8 +3542,6 @@ void my_message_sql(uint error, const char *str, myf MyFlags) extern "C" void *my_str_malloc_mysqld(size_t size); -extern "C" void my_str_free_mysqld(void *ptr); -extern "C" void *my_str_realloc_mysqld(void *ptr, size_t size); void *my_str_malloc_mysqld(size_t size) { @@ -3551,17 +3549,6 @@ void *my_str_malloc_mysqld(size_t size) } -void my_str_free_mysqld(void *ptr) -{ - my_free(ptr); -} - -void *my_str_realloc_mysqld(void *ptr, size_t size) -{ - return my_realloc(ptr, size, MYF(MY_FAE)); -} - - #ifdef __WIN__ pthread_handler_t handle_shutdown(void *arg) @@ -3617,14 +3604,8 @@ check_enough_stack_size(int recurse_level) } -/* - Initialize my_str_malloc() and my_str_free() -*/ static void init_libstrings() { - my_str_malloc= &my_str_malloc_mysqld; - my_str_free= &my_str_free_mysqld; - my_str_realloc= &my_str_realloc_mysqld; #ifndef EMBEDDED_LIBRARY my_string_stack_guard= check_enough_stack_size; #endif @@ -3635,7 +3616,7 @@ ulonglong my_pcre_frame_size; static void init_pcre() { pcre_malloc= pcre_stack_malloc= my_str_malloc_mysqld; - pcre_free= pcre_stack_free= my_str_free_mysqld; + pcre_free= pcre_stack_free= my_free; pcre_stack_guard= check_enough_stack_size_slow; /* See http://pcre.org/original/doc/html/pcrestack.html */ my_pcre_frame_size= -pcre_exec(NULL, NULL, NULL, -999, -999, 0, NULL, 0); diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc index ac5b6ab29a2..d3ef245209d 100644 --- a/sql/sql_connect.cc +++ b/sql/sql_connect.cc @@ -314,13 +314,9 @@ extern "C" void free_user(struct user_conn *uc) void init_max_user_conn(void) { #ifndef NO_EMBEDDED_ACCESS_CHECKS - if (my_hash_init(&hash_user_connections,system_charset_info,max_connections, - 0,0, (my_hash_get_key) get_key_conn, - (my_hash_free_key) free_user, 0)) - { - sql_print_error("Initializing hash_user_connections failed."); - exit(1); - } + my_hash_init(&hash_user_connections, system_charset_info, max_connections, + 0, 0, (my_hash_get_key) get_key_conn, + (my_hash_free_key) free_user, 0); #endif } @@ -479,24 +475,16 @@ void init_user_stats(USER_STATS *user_stats, void init_global_user_stats(void) { - if (my_hash_init(&global_user_stats, system_charset_info, max_connections, - 0, 0, (my_hash_get_key) get_key_user_stats, - (my_hash_free_key)free_user_stats, 0)) - { - sql_print_error("Initializing global_user_stats failed."); - exit(1); - } + my_hash_init(&global_user_stats, system_charset_info, max_connections, + 0, 0, (my_hash_get_key) get_key_user_stats, + (my_hash_free_key) free_user_stats, 0); } void init_global_client_stats(void) { - if (my_hash_init(&global_client_stats, system_charset_info, max_connections, - 0, 0, (my_hash_get_key) get_key_user_stats, - (my_hash_free_key)free_user_stats, 0)) - { - sql_print_error("Initializing global_client_stats failed."); - exit(1); - } + my_hash_init(&global_client_stats, system_charset_info, max_connections, + 0, 0, (my_hash_get_key) get_key_user_stats, + (my_hash_free_key) free_user_stats, 0); } extern "C" uchar *get_key_table_stats(TABLE_STATS *table_stats, size_t *length, @@ -513,12 +501,9 @@ extern "C" void free_table_stats(TABLE_STATS* table_stats) void init_global_table_stats(void) { - if (my_hash_init(&global_table_stats, system_charset_info, max_connections, - 0, 0, (my_hash_get_key) get_key_table_stats, - (my_hash_free_key)free_table_stats, 0)) { - sql_print_error("Initializing global_table_stats failed."); - exit(1); - } + my_hash_init(&global_table_stats, system_charset_info, max_connections, + 0, 0, (my_hash_get_key) get_key_table_stats, + (my_hash_free_key) free_table_stats, 0); } extern "C" uchar *get_key_index_stats(INDEX_STATS *index_stats, size_t *length, @@ -535,13 +520,9 @@ extern "C" void free_index_stats(INDEX_STATS* index_stats) void init_global_index_stats(void) { - if (my_hash_init(&global_index_stats, system_charset_info, max_connections, - 0, 0, (my_hash_get_key) get_key_index_stats, - (my_hash_free_key)free_index_stats, 0)) - { - sql_print_error("Initializing global_index_stats failed."); - exit(1); - } + my_hash_init(&global_index_stats, system_charset_info, max_connections, + 0, 0, (my_hash_get_key) get_key_index_stats, + (my_hash_free_key) free_index_stats, 0); } diff --git a/strings/CMakeLists.txt b/strings/CMakeLists.txt index 32a3f06c861..65eeb457f2d 100644 --- a/strings/CMakeLists.txt +++ b/strings/CMakeLists.txt @@ -20,7 +20,7 @@ SET(STRINGS_SOURCES bchange.c bmove_upp.c ctype-big5.c ctype-bin.c ctype-cp932.c ctype-latin1.c ctype-mb.c ctype-simple.c ctype-sjis.c ctype-tis620.c ctype-uca.c ctype-ucs2.c ctype-ujis.c ctype-utf8.c ctype-win1250ch.c ctype.c decimal.c dtoa.c int2str.c is_prefix.c llstr.c longlong2str.c my_strtoll10.c my_vsnprintf.c - str2int.c str_alloc.c strcend.c strend.c strfill.c strmake.c strmov.c strnmov.c + str2int.c strcend.c strend.c strfill.c strmake.c strmov.c strnmov.c strxmov.c strxnmov.c xml.c strmov_overlapp.c my_strchr.c strcont.c strappend.c) diff --git a/strings/ctype-tis620.c b/strings/ctype-tis620.c index bd8efeff1ec..5284109b816 100644 --- a/strings/ctype-tis620.c +++ b/strings/ctype-tis620.c @@ -524,7 +524,7 @@ int my_strnncoll_tis620(CHARSET_INFO *cs __attribute__((unused)), tc1= buf; if ((len1 + len2 +2) > (int) sizeof(buf)) - tc1= (uchar*) my_str_malloc(len1+len2+2); + tc1= (uchar*) my_malloc(len1+len2+2, MYF(MY_FAE)); tc2= tc1 + len1+1; memcpy((char*) tc1, (char*) s1, len1); tc1[len1]= 0; /* if length(s1)> len1, need to put 'end of string' */ @@ -534,7 +534,7 @@ int my_strnncoll_tis620(CHARSET_INFO *cs __attribute__((unused)), thai2sortable(tc2, len2); i= strcmp((char*)tc1, (char*)tc2); if (tc1 != buf) - my_str_free(tc1); + my_free(tc1); return i; } @@ -555,7 +555,7 @@ int my_strnncollsp_tis620(CHARSET_INFO * cs __attribute__((unused)), a= buf; if ((a_length + b_length +2) > (int) sizeof(buf)) - alloced= a= (uchar*) my_str_malloc(a_length+b_length+2); + alloced= a= (uchar*) my_malloc(a_length+b_length+2, MYF(MY_FAE)); b= a + a_length+1; memcpy((char*) a, (char*) a0, a_length); @@ -604,7 +604,7 @@ int my_strnncollsp_tis620(CHARSET_INFO * cs __attribute__((unused)), ret: if (alloced) - my_str_free(alloced); + my_free(alloced); return res; } diff --git a/strings/my_vsnprintf.c b/strings/my_vsnprintf.c index 4178b20789d..134fdfc57b8 100644 --- a/strings/my_vsnprintf.c +++ b/strings/my_vsnprintf.c @@ -755,14 +755,14 @@ int my_vfprintf(FILE *stream, const char* format, va_list args) and try again. */ if (alloc) - (*my_str_free)(p); + my_free(p); else alloc= 1; new_len= cur_len*2; if (new_len < cur_len) return 0; /* Overflow */ cur_len= new_len; - p= (*my_str_malloc)(cur_len); + p= my_malloc(cur_len, MYF(MY_FAE)); if (!p) return 0; } @@ -770,7 +770,7 @@ int my_vfprintf(FILE *stream, const char* format, va_list args) if (fputs(p, stream) < 0) ret= -1; if (alloc) - (*my_str_free)(p); + my_free(p); return ret; } diff --git a/strings/str_alloc.c b/strings/str_alloc.c deleted file mode 100644 index 91246603f2e..00000000000 --- a/strings/str_alloc.c +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (c) 2005, 2006 MySQL AB - Copyright (c) 2009-2011, Monty Program Ab - Use is subject to license terms. - Copyright (c) 2009-2011, Monty Program Ab - - 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-1301 USA */ - -#include "strings_def.h" - -static void *my_str_malloc_default(size_t size) -{ - void *ret= malloc(size); - if (!ret) - exit(1); - return ret; -} - -static void my_str_free_default(void *ptr) -{ - free(ptr); -} - -void *my_str_realloc_default(void *ptr, size_t size) -{ - return realloc(ptr, size); -} - -void *(*my_str_malloc)(size_t)= &my_str_malloc_default; -void (*my_str_free)(void *)= &my_str_free_default; -void *(*my_str_realloc)(void *, size_t)= &my_str_realloc_default; diff --git a/strings/xml.c b/strings/xml.c index 4685a04faec..b5fed6a6760 100644 --- a/strings/xml.c +++ b/strings/xml.c @@ -17,6 +17,7 @@ #include "strings_def.h" #include "m_string.h" #include "my_xml.h" +#include "my_sys.h" #define MY_XML_UNKNOWN 'U' @@ -231,13 +232,13 @@ static int my_xml_attr_ensure_space(MY_XML_PARSER *st, size_t len) if (!st->attr.buffer) { - st->attr.buffer= (char *) my_str_malloc(st->attr.buffer_size); + st->attr.buffer= (char *) my_malloc(st->attr.buffer_size, MYF(0)); if (st->attr.buffer) memcpy(st->attr.buffer, st->attr.static_buffer, ofs + 1 /*term. zero */); } else - st->attr.buffer= (char *) my_str_realloc(st->attr.buffer, - st->attr.buffer_size); + st->attr.buffer= (char *) my_realloc(st->attr.buffer, + st->attr.buffer_size, MYF(0)); st->attr.start= st->attr.buffer; st->attr.end= st->attr.start + ofs; @@ -507,7 +508,7 @@ void my_xml_parser_free(MY_XML_PARSER *p) { if (p->attr.buffer) { - my_str_free(p->attr.buffer); + my_free(p->attr.buffer); p->attr.buffer= NULL; } } From cfa18e4ae11e77579ee7c577356ed7b4f874c8c7 Mon Sep 17 00:00:00 2001 From: Simon J Mudd Date: Fri, 15 Dec 2017 07:42:04 +0100 Subject: [PATCH 17/69] MDEV-14639: Fix unexpected end of line at 'Normal shutdown' --- sql/share/errmsg-utf8.txt | 44 +++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt index 51a9f6e3847..57ff5902178 100644 --- a/sql/share/errmsg-utf8.txt +++ b/sql/share/errmsg-utf8.txt @@ -1825,28 +1825,28 @@ ER_WRONG_AUTO_KEY 42000 S1009 ER_UNUSED_2 eng "You should never see it" ER_NORMAL_SHUTDOWN - cze "%s: norm-Bální ukončení\n" - dan "%s: Normal nedlukning\n" - nla "%s: Normaal afgesloten \n" - eng "%s: Normal shutdown\n" - est "%s: MariaDB lõpetas\n" - fre "%s: Arrêt normal du serveur\n" - ger "%s: Normal heruntergefahren\n" - greek "%s: Φυσιολογική διαδικασία shutdown\n" - hun "%s: Normal leallitas\n" - ita "%s: Shutdown normale\n" - kor "%s: 정상적인 shutdown\n" - nor "%s: Normal avslutning\n" - norwegian-ny "%s: Normal nedkopling\n" - pol "%s: Standardowe zakończenie działania\n" - por "%s: 'Shutdown' normal\n" - rum "%s: Terminare normala\n" - rus "%s: Корректная остановка\n" - serbian "%s: Normalno gašenje\n" - slo "%s: normálne ukončenie\n" - spa "%s: Apagado normal\n" - swe "%s: Normal avslutning\n" - ukr "%s: Нормальне завершення\n" + cze "%s: norm-Bální ukončení" + dan "%s: Normal nedlukning" + nla "%s: Normaal afgesloten" + eng "%s: Normal shutdown" + est "%s: MariaDB lõpetas" + fre "%s: Arrêt normal du serveur" + ger "%s: Normal heruntergefahren" + greek "%s: Φυσιολογική διαδικασία shutdown" + hun "%s: Normal leallitas" + ita "%s: Shutdown normale" + kor "%s: 정상적인 shutdown" + nor "%s: Normal avslutning" + norwegian-ny "%s: Normal nedkopling" + pol "%s: Standardowe zakończenie działania" + por "%s: 'Shutdown' normal" + rum "%s: Terminare normala" + rus "%s: Корректная остановка" + serbian "%s: Normalno gašenje" + slo "%s: normálne ukončenie" + spa "%s: Apagado normal" + swe "%s: Normal avslutning" + ukr "%s: Нормальне завершення" ER_GOT_SIGNAL cze "%s: p-Břijat signal %d, končím\n" dan "%s: Fangede signal %d. Afslutter!!\n" From 1a8da003f6d2947d2e6ef0f2edea19394657fa0d Mon Sep 17 00:00:00 2001 From: sjaakola Date: Wed, 4 Oct 2017 22:47:59 +0300 Subject: [PATCH 18/69] MW-416 Changed return code for replicatio error to TRUE. This is aligned with native mysql convention to return TRUE (defined to 1) or FALSE (defined to 0) from a bool function. This is wrong, but follows the mysql conventiosn, at least... --- sql/events.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/events.cc b/sql/events.cc index cdc15f41716..cb81e98a254 100644 --- a/sql/events.cc +++ b/sql/events.cc @@ -420,7 +420,7 @@ Events::create_event(THD *thd, Event_parse_data *parse_data) DBUG_RETURN(ret); #ifdef WITH_WSREP error: - DBUG_RETURN(true); + DBUG_RETURN(TRUE); #endif /* WITH_WSREP */ } From 64e1dda0a007d12e3826252866123c3e790a0357 Mon Sep 17 00:00:00 2001 From: sjaakola Date: Fri, 6 Oct 2017 09:49:42 +0300 Subject: [PATCH 19/69] MW-416 DDL replication moved after acl checking galera_events test shows a regression with the original fix for MW-416 Reason was that Events::drop_event() can be called also from inside event execution, and there we have a speacial treatment for event, which executes "DROP EVENT" statement, and runs TOI replication inside the event processing body. This resulted in executing WSREP_TO_ISOLATION two times for such DROP EVENT statement. Fix is to call WSREP_TO_ISOLATION_BEGIN only in Events::drop_event() --- sql/event_data_objects.cc | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/sql/event_data_objects.cc b/sql/event_data_objects.cc index 9e1ee6f30f9..6ef9fa9f8ef 100644 --- a/sql/event_data_objects.cc +++ b/sql/event_data_objects.cc @@ -1472,19 +1472,33 @@ end: bool save_tx_read_only= thd->tx_read_only; thd->tx_read_only= false; - if (WSREP(thd)) - { + /* + This code is processing event execution and does not have client + connection. Here, event execution will now execute a prepared + DROP EVENT statement, but thd->lex->sql_command is set to + SQLCOM_CREATE_PROCEDURE + DROP EVENT will be logged in binlog, and we have to + replicate it to make all nodes have consistent event definitions + Wsrep DDL replication is triggered inside Events::drop_event(), + and here we need to prepare the THD so that DDL replication is + possible, essentially it requires setting sql_command to + SQLCOMM_DROP_EVENT, we will switch sql_command for the duration + of DDL replication only. + */ + const enum_sql_command sql_command_save= thd->lex->sql_command; + const bool sql_command_set= WSREP(thd); + + if (sql_command_set) thd->lex->sql_command = SQLCOM_DROP_EVENT; - WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL); - } ret= Events::drop_event(thd, dbname, name, FALSE); - WSREP_TO_ISOLATION_END; + if (sql_command_set) + { + WSREP_TO_ISOLATION_END; + thd->lex->sql_command = sql_command_save; + } -#ifdef WITH_WSREP - error: -#endif thd->tx_read_only= save_tx_read_only; thd->security_ctx->master_access= saved_master_access; } From f7f5c710e478a835196b2fec1f6ae9362eb07cdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 20 Dec 2017 09:21:08 +0200 Subject: [PATCH 20/69] Correct a function comment The comment became stale in commit 9f57e595b49744e3c1920f8c46a2ec8e7fc5fd66 which removed the parameter "flags". --- storage/innobase/include/trx0rec.h | 6 ++---- storage/innobase/trx/trx0rec.cc | 6 ++---- storage/xtradb/include/trx0rec.h | 6 ++---- storage/xtradb/trx/trx0rec.cc | 6 ++---- 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/storage/innobase/include/trx0rec.h b/storage/innobase/include/trx0rec.h index a6e202d04e4..630818a8648 100644 --- a/storage/innobase/include/trx0rec.h +++ b/storage/innobase/include/trx0rec.h @@ -226,10 +226,8 @@ trx_undo_report_row_operation( marking, the record in the clustered index, otherwise NULL */ const ulint* offsets, /*!< in: rec_get_offsets(rec) */ - roll_ptr_t* roll_ptr) /*!< out: rollback pointer to the - inserted undo log record, - 0 if BTR_NO_UNDO_LOG - flag was specified */ + roll_ptr_t* roll_ptr) /*!< out: DB_ROLL_PTR to the + undo log record */ MY_ATTRIBUTE((nonnull(1,2,8), warn_unused_result)); /******************************************************************//** Copies an undo record to heap. This function can be called if we know that diff --git a/storage/innobase/trx/trx0rec.cc b/storage/innobase/trx/trx0rec.cc index e3ab15e185f..178f7a19678 100644 --- a/storage/innobase/trx/trx0rec.cc +++ b/storage/innobase/trx/trx0rec.cc @@ -1220,10 +1220,8 @@ trx_undo_report_row_operation( marking, the record in the clustered index, otherwise NULL */ const ulint* offsets, /*!< in: rec_get_offsets(rec) */ - roll_ptr_t* roll_ptr) /*!< out: rollback pointer to the - inserted undo log record, - 0 if BTR_NO_UNDO_LOG - flag was specified */ + roll_ptr_t* roll_ptr) /*!< out: DB_ROLL_PTR to the + undo log record */ { trx_t* trx; trx_undo_t* undo; diff --git a/storage/xtradb/include/trx0rec.h b/storage/xtradb/include/trx0rec.h index a6e202d04e4..630818a8648 100644 --- a/storage/xtradb/include/trx0rec.h +++ b/storage/xtradb/include/trx0rec.h @@ -226,10 +226,8 @@ trx_undo_report_row_operation( marking, the record in the clustered index, otherwise NULL */ const ulint* offsets, /*!< in: rec_get_offsets(rec) */ - roll_ptr_t* roll_ptr) /*!< out: rollback pointer to the - inserted undo log record, - 0 if BTR_NO_UNDO_LOG - flag was specified */ + roll_ptr_t* roll_ptr) /*!< out: DB_ROLL_PTR to the + undo log record */ MY_ATTRIBUTE((nonnull(1,2,8), warn_unused_result)); /******************************************************************//** Copies an undo record to heap. This function can be called if we know that diff --git a/storage/xtradb/trx/trx0rec.cc b/storage/xtradb/trx/trx0rec.cc index 4e0ba825ed2..8cd51c8066b 100644 --- a/storage/xtradb/trx/trx0rec.cc +++ b/storage/xtradb/trx/trx0rec.cc @@ -1221,10 +1221,8 @@ trx_undo_report_row_operation( marking, the record in the clustered index, otherwise NULL */ const ulint* offsets, /*!< in: rec_get_offsets(rec) */ - roll_ptr_t* roll_ptr) /*!< out: rollback pointer to the - inserted undo log record, - 0 if BTR_NO_UNDO_LOG - flag was specified */ + roll_ptr_t* roll_ptr) /*!< out: DB_ROLL_PTR to the + undo log record */ { trx_t* trx; trx_undo_t* undo; From c58df0cdd40258254b40f501857106c843347e39 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Wed, 20 Dec 2017 12:14:49 +0400 Subject: [PATCH 21/69] MDEV-14031 Password policy causes replication failure --- .../r/binlog-simple_plugin_check.result | 19 ++++++++++++ .../plugins/t/binlog-simple_plugin_check.test | 31 +++++++++++++++++++ sql/sql_acl.cc | 2 +- 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 mysql-test/suite/plugins/r/binlog-simple_plugin_check.result create mode 100644 mysql-test/suite/plugins/t/binlog-simple_plugin_check.test diff --git a/mysql-test/suite/plugins/r/binlog-simple_plugin_check.result b/mysql-test/suite/plugins/r/binlog-simple_plugin_check.result new file mode 100644 index 00000000000..6c960ee325c --- /dev/null +++ b/mysql-test/suite/plugins/r/binlog-simple_plugin_check.result @@ -0,0 +1,19 @@ +INSTALL SONAME "simple_password_check"; +SELECT PLUGIN_NAME FROM INFORMATION_SCHEMA.PLUGINS +WHERE PLUGIN_NAME='simple_password_check'; +PLUGIN_NAME +simple_password_check +# +# MDEV-14031 Password policy causes replication failure +# +CREATE USER user1@localhost IDENTIFIED BY 'BsG9#9.cem#!85'; +CREATE USER user2@localhost IDENTIFIED BY 'bsg9#d.cem#!85'; +ERROR HY000: Your password does not satisfy the current policy requirements +DROP USER user1@localhost; +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 USER user1@localhost IDENTIFIED BY 'BsG9#9.cem#!85' +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; DROP USER user1@localhost +UNINSTALL PLUGIN simple_password_check; diff --git a/mysql-test/suite/plugins/t/binlog-simple_plugin_check.test b/mysql-test/suite/plugins/t/binlog-simple_plugin_check.test new file mode 100644 index 00000000000..773dafe8a81 --- /dev/null +++ b/mysql-test/suite/plugins/t/binlog-simple_plugin_check.test @@ -0,0 +1,31 @@ +--source include/not_embedded.inc +--source include/have_binlog_format_statement.inc + +if (!$SIMPLE_PASSWORD_CHECK_SO) { + skip No SIMPLE_PASSWORD_CHECK plugin; +} + +INSTALL SONAME "simple_password_check"; +SELECT PLUGIN_NAME FROM INFORMATION_SCHEMA.PLUGINS +WHERE PLUGIN_NAME='simple_password_check'; + + +--echo # +--echo # MDEV-14031 Password policy causes replication failure +--echo # + +--disable_query_log +RESET MASTER; # get rid of previous tests binlog +--enable_query_log + +CREATE USER user1@localhost IDENTIFIED BY 'BsG9#9.cem#!85'; + +--error ER_NOT_VALID_PASSWORD +CREATE USER user2@localhost IDENTIFIED BY 'bsg9#d.cem#!85'; + +DROP USER user1@localhost; + +--let $binlog_file = LAST +source include/show_binlog_events.inc; + +UNINSTALL PLUGIN simple_password_check; diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 5ccc5f75118..6029f4ed71a 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -9507,13 +9507,13 @@ bool mysql_create_user(THD *thd, List &list, bool handle_as_role) } } - binlog= true; if (replace_user_table(thd, tables[USER_TABLE].table, *user_name, 0, 0, 1, 0)) { append_user(thd, &wrong_users, user_name); result= TRUE; continue; } + binlog= true; // every created role is automatically granted to its creator-admin if (handle_as_role) From cb121a047b55403fe271570c928fd95ed64a1c8f Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Wed, 20 Dec 2017 13:49:27 +0400 Subject: [PATCH 22/69] An after-fix for MDEV-14008 Assertion failing: `!is_set() || (m_status == DA_OK_BULK && is_bulk_op()) Fixing an additional failure discovered after a merge to 10.2 --- mysql-test/suite/innodb/r/innodb-autoinc.result | 6 ++++++ mysql-test/suite/innodb/t/innodb-autoinc.test | 5 +++++ sql/field.cc | 9 ++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/innodb/r/innodb-autoinc.result b/mysql-test/suite/innodb/r/innodb-autoinc.result index 9aa819de22b..4af674adc6a 100644 --- a/mysql-test/suite/innodb/r/innodb-autoinc.result +++ b/mysql-test/suite/innodb/r/innodb-autoinc.result @@ -1360,3 +1360,9 @@ SELECT * FROM t1; c1 1e19 DROP TABLE t1; +CREATE TABLE t1 (a DOUBLE PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (-1); +SELECT * FROM t1; +a +-1 +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/innodb-autoinc.test b/mysql-test/suite/innodb/t/innodb-autoinc.test index ebb6a5d24ff..9835a9779cf 100644 --- a/mysql-test/suite/innodb/t/innodb-autoinc.test +++ b/mysql-test/suite/innodb/t/innodb-autoinc.test @@ -692,3 +692,8 @@ CREATE TABLE t1 ( INSERT INTO t1 VALUES (); SELECT * FROM t1; DROP TABLE t1; + +CREATE TABLE t1 (a DOUBLE PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (-1); +SELECT * FROM t1; +DROP TABLE t1; diff --git a/sql/field.cc b/sql/field.cc index a3c20ec18f2..f4aaaca69d6 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -4399,7 +4399,14 @@ longlong Field_double::val_int_from_real(bool want_unsigned_result) float8get(j,ptr); res= double_to_longlong(j, want_unsigned_result, &error); - if (error) + /* + Note, val_uint() is currently used for auto_increment purposes only, + and we want to suppress all warnings in such cases. + If we ever start using val_uint() for other purposes, + val_int_from_real() will need a new separate parameter to + suppress warnings. + */ + if (error && !want_unsigned_result) { ErrConvDouble err(j); push_warning_printf(current_thd, Sql_condition::WARN_LEVEL_WARN, From 924db8b4ed3f268cbe91a1734611f4dc2311c7be Mon Sep 17 00:00:00 2001 From: Varun Gupta Date: Wed, 20 Dec 2017 02:27:03 +0530 Subject: [PATCH 23/69] MDEV-12350: Heap corruption, overrun buffer, ASAN errors, server crash in my_fill_8bit / filesort In the function make_sortkey a tmp buffer was defined and in the absence of param->tmp_buffer, tmp buffer used the sort_keys buffer. sort_keys buffer has a length defined in sort_field->length, while param->tmp_buffer is stored in param->rec_length. Make sure to use the appropriate length based on which buffer we are using otherwise we'll overflow. Also added a type cast to size_t during the calculation of the sort keys buffer size to avoid an oveflow if the buffer size exceeds 32 bits. --- mysql-test/r/group_by.result | 25 +++++++++++++++++++++++++ mysql-test/t/group_by.test | 26 ++++++++++++++++++++++++++ sql/filesort.cc | 7 +++++-- 3 files changed, 56 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result index b948c9a6f88..52ee73e6612 100644 --- a/mysql-test/r/group_by.result +++ b/mysql-test/r/group_by.result @@ -2558,3 +2558,28 @@ create table t2 (c1 int, c2 int); select t1.c1 as c1, t2.c2 as c1 from t1, t2 where t1.c1 < 20 and t2.c2 > 5 group by t1.c1, t2.c2 having t1.c1 < 3; c1 c1 drop table t1, t2; +SET @old_sort_buff_size = @@sort_buffer_size; +SET @@sort_buffer_size=256*1024; +CREATE TABLE t1 (c INT) ENGINE=MyISAM; +INSERT INTO t1 VALUES +(2011),(1977),(1982),(2027),(2023),(NULL),(NULL),(2004),(1974),(2032), +(1993),(NULL),(1995),(2034),(NULL),(2009),(1900),(NULL),(2025),(1900), +(2033),(1900),(2012),(NULL),(2009),(1992),(1974),(1974),(2012),(2028), +(2007),(2012),(1900),(1983),(1900),(2010),(1987),(1994),(1981),(2032), +(2010),(1989),(2014),(1900),(1900),(1976),(1978),(2007),(2030),(NULL), +(2002),(1997),(1900),(NULL),(2000),(2027),(1975),(2026),(1975),(2026), +(2029),(1977),(1900),(1900),(2031),(1993),(1986),(2012),(1979),(2013), +(1994),(2014),(2025),(2006),(1971),(1974),(2021),(2011),(NULL),(1991), +(2001),(1977),(2023),(2012),(1900),(1978),(1998),(NULL),(1988),(1999), +(2017),(2008),(1976),(1900),(2005),(2030),(2023),(1900),(1978),(1990), +(1978),(1987),(2030),(1900),(2034),(2006),(2015),(2001),(2019),(2024), +(2030),(1989),(1997),(2007),(2023),(1994),(1971),(2011),(2011),(2015), +(1984),(1978),(1979),(1989),(2008),(2030); +SELECT ExtractValue('','/a') AS f1, SPACE(c) AS f2 FROM t1 GROUP BY f1, f2 WITH ROLLUP; +f1 f2 + NULL + + NULL +NULL NULL +SET @@sort_buffer_size = @old_sort_buff_size; +DROP TABLE t1; diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test index 80ecfea539b..43274532b3e 100644 --- a/mysql-test/t/group_by.test +++ b/mysql-test/t/group_by.test @@ -1741,6 +1741,32 @@ create table t2 (c1 int, c2 int); select t1.c1 as c1, t2.c2 as c1 from t1, t2 where t1.c1 < 20 and t2.c2 > 5 group by t1.c1, t2.c2 having t1.c1 < 3; drop table t1, t2; +# +# MDEV-12350: Heap corruption, overrun buffer, ASAN errors, server crash in my_fill_8bit / filesort +# + +SET @old_sort_buff_size = @@sort_buffer_size; +SET @@sort_buffer_size=256*1024; +CREATE TABLE t1 (c INT) ENGINE=MyISAM; +INSERT INTO t1 VALUES + (2011),(1977),(1982),(2027),(2023),(NULL),(NULL),(2004),(1974),(2032), + (1993),(NULL),(1995),(2034),(NULL),(2009),(1900),(NULL),(2025),(1900), + (2033),(1900),(2012),(NULL),(2009),(1992),(1974),(1974),(2012),(2028), + (2007),(2012),(1900),(1983),(1900),(2010),(1987),(1994),(1981),(2032), + (2010),(1989),(2014),(1900),(1900),(1976),(1978),(2007),(2030),(NULL), + (2002),(1997),(1900),(NULL),(2000),(2027),(1975),(2026),(1975),(2026), + (2029),(1977),(1900),(1900),(2031),(1993),(1986),(2012),(1979),(2013), + (1994),(2014),(2025),(2006),(1971),(1974),(2021),(2011),(NULL),(1991), + (2001),(1977),(2023),(2012),(1900),(1978),(1998),(NULL),(1988),(1999), + (2017),(2008),(1976),(1900),(2005),(2030),(2023),(1900),(1978),(1990), + (1978),(1987),(2030),(1900),(2034),(2006),(2015),(2001),(2019),(2024), + (2030),(1989),(1997),(2007),(2023),(1994),(1971),(2011),(2011),(2015), + (1984),(1978),(1979),(1989),(2008),(2030); + +SELECT ExtractValue('','/a') AS f1, SPACE(c) AS f2 FROM t1 GROUP BY f1, f2 WITH ROLLUP; +SET @@sort_buffer_size = @old_sort_buff_size; +DROP TABLE t1; + # # End of MariaDB 5.5 tests # diff --git a/sql/filesort.cc b/sql/filesort.cc index 38404b01cf7..5674786d8b2 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -210,7 +210,9 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length, { ulonglong keys= memory_available / (param.rec_length + sizeof(char*)); table_sort.keys= (uint) min(num_rows, keys); - sort_buff_sz= table_sort.keys*(param.rec_length+sizeof(char*)); + /* Cast to size_t to avoid overflow when result is greater than uint. */ + sort_buff_sz= ((size_t)table_sort.keys) * + (param.rec_length + sizeof(char*)); set_if_bigger(sort_buff_sz, param.rec_length * MERGEBUFF2); DBUG_EXECUTE_IF("make_sort_keys_alloc_fail", @@ -914,7 +916,8 @@ static void make_sortkey(register SORTPARAM *param, if (maybe_null) *to++=1; char *tmp_buffer= param->tmp_buffer ? param->tmp_buffer : (char*)to; - String tmp(tmp_buffer, param->sort_length, cs); + String tmp(tmp_buffer, param->tmp_buffer ? param->sort_length : + sort_field->length, cs); String *res= item->str_result(&tmp); if (!res) { From 7bbc6c14d1e8fcf1f4737e0a5fcf6237fe18bd23 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 19 May 2017 15:45:07 +0200 Subject: [PATCH 24/69] Generate and install sysusers and tmpfiles configuration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Using systemd we can automate creating users and directories. So generate and install the configuration files. Signed-off-by: Vicențiu Ciorbaru Small change in cmake/install_layout.cmake compared to original contributor patch to also install SYSTEMD_SYSUSERS and SYSTEMD_TMPFILES directories. The variables were being set, but the loop which defines the final install files was not updated. --- cmake/install_layout.cmake | 6 +++++- support-files/CMakeLists.txt | 15 +++++++++++++++ support-files/sysusers.conf.in | 1 + support-files/tmpfiles.conf.in | 1 + 4 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 support-files/sysusers.conf.in create mode 100644 support-files/tmpfiles.conf.in diff --git a/cmake/install_layout.cmake b/cmake/install_layout.cmake index d1a261f8cef..5484691e94a 100644 --- a/cmake/install_layout.cmake +++ b/cmake/install_layout.cmake @@ -162,6 +162,8 @@ SET(INSTALL_MYSQLDATADIR_RPM "/var/lib/mysql") SET(INSTALL_UNIX_ADDRDIR_RPM "${INSTALL_MYSQLDATADIR_RPM}/mysql.sock") SET(INSTALL_SYSTEMD_UNITDIR_RPM "/usr/lib/systemd/system") +SET(INSTALL_SYSTEMD_SYSUSERSDIR_RPM "/usr/lib/sysusers.d") +SET(INSTALL_SYSTEMD_TMPFILESDIR_RPM "/usr/lib/tmpfiles.d") # # DEB layout @@ -191,6 +193,8 @@ SET(INSTALL_MYSQLDATADIR_DEB "/var/lib/mysql") SET(INSTALL_UNIX_ADDRDIR_DEB "/var/run/mysqld/mysqld.sock") SET(INSTALL_SYSTEMD_UNITDIR_DEB "/lib/systemd/system") +SET(INSTALL_SYSTEMD_SYSUSERSDIR_DEB "/usr/lib/sysusers.d") +SET(INSTALL_SYSTEMD_TMPFILESDIR_DEB "/usr/lib/tmpfiles.d") # # SVR4 layout @@ -232,7 +236,7 @@ SET(OLD_INSTALL_LAYOUT ${INSTALL_LAYOUT} CACHE INTERNAL "") # layout is chosen) FOREACH(var BIN SBIN LIB MYSQLSHARE SHARE PLUGIN INCLUDE SCRIPT DOC MAN SYSCONF SYSCONF2 INFO MYSQLTEST SQLBENCH DOCREADME SUPPORTFILES MYSQLDATA UNIX_ADDR - SYSTEMD_UNIT) + SYSTEMD_UNIT SYSTEMD_SYSUSERS SYSTEMD_TMPFILES) SET(INSTALL_${var}DIR ${INSTALL_${var}DIR_${INSTALL_LAYOUT}} CACHE STRING "${var} installation directory" ${FORCE}) MARK_AS_ADVANCED(INSTALL_${var}DIR) diff --git a/support-files/CMakeLists.txt b/support-files/CMakeLists.txt index 71e9b3fad3d..3b6e86030ab 100644 --- a/support-files/CMakeLists.txt +++ b/support-files/CMakeLists.txt @@ -104,6 +104,21 @@ IF(UNIX) ${CMAKE_CURRENT_BINARY_DIR}/mariadb.service DESTINATION ${inst_location}/systemd COMPONENT SupportFiles) + IF(INSTALL_SYSTEMD_SYSUSERSDIR) + CONFIGURE_FILE(sysusers.conf.in + ${CMAKE_CURRENT_BINARY_DIR}/sysusers.conf @ONLY) + INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/sysusers.conf + DESTINATION ${INSTALL_SYSTEMD_SYSUSERSDIR} COMPONENT Server) + ENDIF() + + IF(INSTALL_SYSTEMD_TMPFILESDIR) + get_filename_component(MYSQL_UNIX_DIR ${MYSQL_UNIX_ADDR} DIRECTORY) + CONFIGURE_FILE(tmpfiles.conf.in + ${CMAKE_CURRENT_BINARY_DIR}/tmpfiles.conf @ONLY) + INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/tmpfiles.conf + DESTINATION ${INSTALL_SYSTEMD_TMPFILESDIR} COMPONENT Server) + ENDIF() + # @ in directory name broken between CMake version 2.8.12.2 and 3.3 # http://public.kitware.com/Bug/view.php?id=14782 IF(NOT CMAKE_VERSION VERSION_LESS 3.3.0 OR NOT RPM) diff --git a/support-files/sysusers.conf.in b/support-files/sysusers.conf.in new file mode 100644 index 00000000000..a975b29476a --- /dev/null +++ b/support-files/sysusers.conf.in @@ -0,0 +1 @@ +u @MYSQLD_USER@ - "MariaDB" @MYSQL_DATADIR@ diff --git a/support-files/tmpfiles.conf.in b/support-files/tmpfiles.conf.in new file mode 100644 index 00000000000..03d66abc0c7 --- /dev/null +++ b/support-files/tmpfiles.conf.in @@ -0,0 +1 @@ +d @MYSQL_UNIX_DIR@ 0755 @MYSQLD_USER@ @MYSQLD_USER@ - From eb1404238346405edc51b0b916a8e0650f061cf0 Mon Sep 17 00:00:00 2001 From: Oleksandr Byelkin Date: Wed, 20 Dec 2017 16:52:02 +0100 Subject: [PATCH 25/69] MDEV-14613: Assertion `fixed == 0' failed in Item_func::fix_fields fix_fields calls fixed. --- mysql-test/r/func_misc.result | 15 +++++++++++++++ mysql-test/t/func_misc.test | 21 +++++++++++++++++++++ sql/item.cc | 6 ++++-- 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/func_misc.result b/mysql-test/r/func_misc.result index 0462a1dc48a..218b11a2fc2 100644 --- a/mysql-test/r/func_misc.result +++ b/mysql-test/r/func_misc.result @@ -1523,5 +1523,20 @@ str str1 b c ::10.0.5.9 ::10.0.5.9 1 0 DROP TABLE t1; # +# MDEV-14613: Assertion `fixed == 0' failed in Item_func::fix_fields +# +CREATE TABLE `t1` ( +`numgtfmt` char(10) COLLATE utf8_bin NOT NULL +) DEFAULT CHARSET=utf8 COLLATE=utf8_bin; +create view v1(numgtfmt) +as +select 'x' from t1 +union +select 'x' from t1 ; +SELECT * FROM v1 WHERE numgtfmt = NAME_CONST('wnumgtfmt',_utf8'QEDITIONS' COLLATE 'utf8_bin'); +numgtfmt +DROP VIEW v1; +DROP TABLE t1; +# # End of 10.2 tests # diff --git a/mysql-test/t/func_misc.test b/mysql-test/t/func_misc.test index 5d0dc52a6af..e2684ab4957 100644 --- a/mysql-test/t/func_misc.test +++ b/mysql-test/t/func_misc.test @@ -1152,6 +1152,27 @@ INSERT INTO t1 (str) VALUES ('::FFFF:192.168.0.1'),('::10.0.5.9'); SELECT str, str1, b,c FROM t1; DROP TABLE t1; +--echo # +--echo # MDEV-14613: Assertion `fixed == 0' failed in Item_func::fix_fields +--echo # + +CREATE TABLE `t1` ( + `numgtfmt` char(10) COLLATE utf8_bin NOT NULL +) DEFAULT CHARSET=utf8 COLLATE=utf8_bin; + +create view v1(numgtfmt) +as +select 'x' from t1 +union +select 'x' from t1 ; + +SELECT * FROM v1 WHERE numgtfmt = NAME_CONST('wnumgtfmt',_utf8'QEDITIONS' COLLATE 'utf8_bin'); + +# Cleanup +DROP VIEW v1; +DROP TABLE t1; + + --echo # --echo # End of 10.2 tests --echo # diff --git a/sql/item.cc b/sql/item.cc index 029f8216bf1..6dcb436baba 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1814,8 +1814,10 @@ bool Item_name_const::fix_fields(THD *thd, Item **ref) String s(buf, sizeof(buf), &my_charset_bin); s.length(0); - if (value_item->fix_fields(thd, &value_item) || - name_item->fix_fields(thd, &name_item) || + if ((!value_item->fixed && + value_item->fix_fields(thd, &value_item)) || + (!name_item->fixed && + name_item->fix_fields(thd, &name_item)) || !value_item->const_item() || !name_item->const_item() || !(item_name= name_item->val_str(&s))) // Can't have a NULL name From 21eed925a0e374c9f643d32544d3468954435ebc Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Wed, 20 Dec 2017 19:37:07 +0300 Subject: [PATCH 26/69] Cleanup out of date comments (no real changes). --- storage/rocksdb/mysql-test/rocksdb/t/disabled.def | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/storage/rocksdb/mysql-test/rocksdb/t/disabled.def b/storage/rocksdb/mysql-test/rocksdb/t/disabled.def index a0810fe63ec..1c4bdf1b082 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/disabled.def +++ b/storage/rocksdb/mysql-test/rocksdb/t/disabled.def @@ -68,19 +68,12 @@ lock_wait_timeout_stats: MDEV-13404 compact_deletes: MDEV-12663 : rocksdb.compact_deletes times out and causes other tests to fail blind_delete_without_tx_api: MDEV-12286: rocksdb.blind_delete_without_tx_api test fails -# Enabling these didn't seem to cause any trouble: -# autoinc_vars_thread : MDEV-12474 Regularly fails on buildbot -# unique_check : MDEV-12474 Regularly fails on buildbot -# bloomfilter : MDEV-12474 Regularly fails on buildbot -# unique_sec : Intermittent failures in BB - - ## ## Tests that fail for some other reason ## + information_schema : MariaRocks: requires GTIDs mysqlbinlog_gtid_skip_empty_trans_rocksdb : MariaRocks: requires GTIDs -#read_only_tx : MariaRocks: requires GTIDs rpl_row_triggers : MariaRocks: requires GTIDs From 73fa7aeb203299d8d358f8f6b4cdd58aa9f1d0ec Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Wed, 20 Dec 2017 19:49:56 +0300 Subject: [PATCH 27/69] MDEV-14165: not MyRocks -problem in ps-protocol, happens in upstream too Enable the test back, as the fix has been pushed. --- storage/rocksdb/mysql-test/rocksdb/t/disabled.def | 1 - 1 file changed, 1 deletion(-) diff --git a/storage/rocksdb/mysql-test/rocksdb/t/disabled.def b/storage/rocksdb/mysql-test/rocksdb/t/disabled.def index 1c4bdf1b082..91bbe7fe30e 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/disabled.def +++ b/storage/rocksdb/mysql-test/rocksdb/t/disabled.def @@ -41,7 +41,6 @@ rocksdb_deadlock_stress_rr: stress test ## persistent_cache: Upstream RocksDB bug https://github.com/facebook/mysql-5.6/issues/579 collation: Fails on gcc 4.8 and before, MDEV-12433 -col_opt_zerofill: MDEV-14165: not MyRocks -problem in ps-protocol, happens in upstream too ## From 2a4faa8ab61bd508e6fa5a477853d0ddeed94fcc Mon Sep 17 00:00:00 2001 From: Sachin Setiya Date: Wed, 20 Dec 2017 00:06:02 +0530 Subject: [PATCH 28/69] MDEV-13478 Full SST sync fails because of the error in the cleaning part Problem: The command was: find $paths -mindepth 1 -regex $cpat -prune -o -exec rm -rf {} \+ Which was supposed to work as * skipping $paths directories themselves (-mindepth 1) * see if the dir/file name matches $cpat (-regex) * if yes - don't dive into the directory, skip it (-prune) * otherwise (-o) * remove it and everything inside (-exec) Now -exec ... \+ works like this: every new found path is appended to the end of the command line. when accumulated command line length reaches `getconf ARG_MAX` (~2Gb) it's executed, and find continues, appending to a new command line. What happens here, find appends some directory to the command line, then dives into it, and starts appending files from that directory. At some point command line overflows, rm -rf gets executed and removes the whole directory. Now find tries to continue scanning the directory that was already removed. Fix: don't dive into directories that will be recursively removed anyway, use -prune for them. Basically, we should be pruning both paths that have matched $cpat and paths that have not matched it. This is achived by pruning unconditionally, before the regex is tested: find $paths -mindepth 1 -prune -regex $cpat -o -exec rm -rf {} \+ Patch Credit:- Serg --- scripts/wsrep_sst_xtrabackup-v2.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/wsrep_sst_xtrabackup-v2.sh b/scripts/wsrep_sst_xtrabackup-v2.sh index 40e686d4d6b..9284bf78019 100644 --- a/scripts/wsrep_sst_xtrabackup-v2.sh +++ b/scripts/wsrep_sst_xtrabackup-v2.sh @@ -1072,7 +1072,7 @@ then wsrep_log_info "Cleaning the existing datadir and innodb-data/log directories" - find $ib_home_dir $ib_log_dir $ib_undo_dir $DATA -mindepth 1 -regex $cpat -prune -o -exec rm -rfv {} 1>&2 \+ + find $ib_home_dir $ib_log_dir $ib_undo_dir $DATA -mindepth 1 -prune -regex $cpat -o -exec rm -rfv {} 1>&2 \+ tempdir=$(parse_cnf mysqld log-bin "") if [[ -n ${tempdir:-} ]];then From 85fad60dc77f4c5b85ec1b7e5d4c3bff456a0ada Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Thu, 21 Dec 2017 01:50:44 +0300 Subject: [PATCH 29/69] Disable back rocksdb.col_opt_zerofill due to MDEV-14729 --- storage/rocksdb/mysql-test/rocksdb/t/disabled.def | 1 + 1 file changed, 1 insertion(+) diff --git a/storage/rocksdb/mysql-test/rocksdb/t/disabled.def b/storage/rocksdb/mysql-test/rocksdb/t/disabled.def index 91bbe7fe30e..dc2e04b93d7 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/disabled.def +++ b/storage/rocksdb/mysql-test/rocksdb/t/disabled.def @@ -41,6 +41,7 @@ rocksdb_deadlock_stress_rr: stress test ## persistent_cache: Upstream RocksDB bug https://github.com/facebook/mysql-5.6/issues/579 collation: Fails on gcc 4.8 and before, MDEV-12433 +col_opt_zerofill: MDEV-14729 (also MDEV-14165 which was fixed): problem in the client ## From e27e7ec767e6c278c7e6a4db1c1ce0006f72a955 Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Thu, 21 Dec 2017 02:02:25 +0300 Subject: [PATCH 30/69] Better comments part #1 --- .../rocksdb/mysql-test/rocksdb_rpl/t/disabled.def | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/disabled.def b/storage/rocksdb/mysql-test/rocksdb_rpl/t/disabled.def index 07a2738eee5..3232ff185bb 100644 --- a/storage/rocksdb/mysql-test/rocksdb_rpl/t/disabled.def +++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/disabled.def @@ -1,5 +1,14 @@ +## +## Tests that require FB/MySQL specific features for which there are +## no plans to port them to MariaDB +## +rpl_no_unique_check_on_lag : unique_check_lag_threshold is not available in MariaDB +rpl_no_unique_check_on_lag_mts : unique_check_lag_threshold is not available in MariaDB -# rpl_rocksdb_2pc_crash_recover + +## +## Tests that are disabled for other reasons +## consistent_snapshot_mixed_engines : Didn't try with MariaDB, yet multiclient_2pc : Didn't try with MariaDB, yet @@ -8,8 +17,6 @@ rpl_ddl_high_priority : Didn't try with MariaDB, yet rpl_gtid_crash_safe : Didn't try with MariaDB, yet rpl_gtid_crash_safe_wal_corrupt : Didn't try with MariaDB, yet rpl_gtid_rocksdb_sys_header : Didn't try with MariaDB, yet -rpl_no_unique_check_on_lag : Didn't try with MariaDB, yet -rpl_no_unique_check_on_lag_mts : Didn't try with MariaDB, yet rpl_rocksdb_snapshot : Didn't try with MariaDB, yet rpl_rocksdb_snapshot_without_gtid : Didn't try with MariaDB, yet rpl_rocksdb_stress_crash : Didn't try with MariaDB, yet From 207976d6b9c42868d982a54a2bdd16b77a3c73da Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Thu, 21 Dec 2017 02:34:02 +0300 Subject: [PATCH 31/69] Better comments part #2 --- storage/rocksdb/mysql-test/rocksdb_rpl/t/disabled.def | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/disabled.def b/storage/rocksdb/mysql-test/rocksdb_rpl/t/disabled.def index 3232ff185bb..e46e89517a9 100644 --- a/storage/rocksdb/mysql-test/rocksdb_rpl/t/disabled.def +++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/disabled.def @@ -4,13 +4,12 @@ ## rpl_no_unique_check_on_lag : unique_check_lag_threshold is not available in MariaDB rpl_no_unique_check_on_lag_mts : unique_check_lag_threshold is not available in MariaDB - +consistent_snapshot_mixed_engines : Tests START TRANSACTION WITH CONSISTENT $ENGINE_NAME SNAPSHOT ## ## Tests that are disabled for other reasons ## -consistent_snapshot_mixed_engines : Didn't try with MariaDB, yet multiclient_2pc : Didn't try with MariaDB, yet rpl_crash_safe_wal_corrupt : Didn't try with MariaDB, yet rpl_ddl_high_priority : Didn't try with MariaDB, yet From 5f896b360429e19f53109ccf14da6ef58d45b179 Mon Sep 17 00:00:00 2001 From: Elena Stepanova Date: Thu, 21 Dec 2017 03:31:39 +0200 Subject: [PATCH 32/69] Updated list of unstable tests for 10.1.30 release --- mysql-test/unstable-tests | 144 +++++++++++++++++--------------------- 1 file changed, 65 insertions(+), 79 deletions(-) diff --git a/mysql-test/unstable-tests b/mysql-test/unstable-tests index b5f8f9fffb9..3010c5ddf79 100644 --- a/mysql-test/unstable-tests +++ b/mysql-test/unstable-tests @@ -26,16 +26,17 @@ main.alter_table : Modified in 10.1.29 main.alter_table_trans : MDEV-12084 - timeout main.analyze_stmt_slow_query_log : MDEV-12237 - Wrong result +main.auth_named_pipe : MDEV-14724 - System error 2 main.bootstrap : Include files modified in 10.1.29 main.case : Modified in 10.1.29 -main.count_distinct : Modified in 10.1.27 main.create_delayed : MDEV-10605 - failed with timeout main.ctype_gbk : Modified in 10.1.29 main.ctype_latin1 : Modified in 10.1.29 main.ctype_ucs : Modified in 10.1.29 main.ctype_utf16le : MDEV-10675: timeout or extra warnings main.ctype_utf32 : Modified in 10.1.29 -main.ctype_utf8 : Modified in 10.1.29 +main.ctype_utf8 : Modified in 10.1.30 +main.ctype_utf8mb4 : Modified in 10.1.30 main.delete_returning : Modified in 10.1.29 main.delimiter_command_case_sensitivity : Added in 10.1.29 main.events_2 : MDEV-13277 - Server crash @@ -44,16 +45,19 @@ main.events_restart : MDEV-12236 - Server shutdown problem main.func_in : Modified in 10.1.29 main.func_misc : Modified in 10.1.29 main.func_regexp_pcre : Modified in 10.1.29 +main.func_set : Modified in 10.1.30 +main.func_str : Modified in 10.1.30 main.func_time : Modified in 10.1.29 main.gis-precise : Modified in 10.1.29 +main.group_by : Modified in 10.1.30 +main.having : Modified in 10.1.30 main.host_cache_size_functionality : MDEV-10606 - sporadic failure on shutdown main.index_intersect_innodb : MDEV-10643 - failed with timeout main.index_merge_innodb : MDEV-7142 - Wrong execution plan, timeout with valgrind main.information_schema : Modified in 10.1.29 main.innodb_mysql_lock : MDEV-7861 - sporadic lock detection failure -main.insert : Modified in 10.1.27 +main.join_outer : Modified in 10.1.30 main.kill_processlist-6619 : MDEV-10793 - wrong result in processlist -main.log_tables-big : Modified in 10.1.27 main.mdev-504 : MDEV-10607 - sporadic "can't connect" main.mdev13607 : Added in 10.1.29 main.mdev375 : MDEV-10607 - sporadic "can't connect" @@ -63,12 +67,10 @@ main.mysql_upgrade_noengine : MDEV-14355 - Plugin is busy main.mysqlbinlog : Modified in 10.1.29 main.mysqlslap : MDEV-11801 - timeout main.mysqltest : MDEV-9269 - fails on Alpha -main.old-mode : Modified in 10.1.27 main.order_by_optimizer_innodb : MDEV-10683 - wrong execution plan main.partition_datatype : Modified in 10.1.29 main.partition_example : Include files modified in 10.1.29 main.partition_innodb_plugin : MDEV-12901 - Valgrind warnings -main.partition_symlink : Modified in 10.1.27 main.plugin : Include files modified in 10.1.29 main.plugin_innodb : Include files modified in 10.1.29 main.plugin_load : Include files modified in 10.1.29 @@ -83,31 +85,33 @@ main.read_only : Modified in 10.1.29 main.set_statement : MDEV-13183 - Wrong result main.show_explain : MDEV-10674 - sporadic failure main.show_function_with_pad_char_to_full_length : Added in 10.1.29 -main.sp : Modified in 10.1.27 +main.sp : Modified in 10.1.30 main.sp-security : MDEV-10607 - sporadic "can't connect" main.status : MDEV-8510 - sporadic wrong result main.subselect_exists2in : Modified in 10.1.29 main.subselect_innodb : MDEV-10614 - sporadic wrong results main.subselect_mat_cost_bugs : Modified in 10.1.29 -main.symlink : Modified in 10.1.27 main.table_options-5867 : Include files modified in 10.1.29 -main.tc_heuristic_recover : Added in 10.1.27 +main.trigger : Modified in 10.1.30 main.truncate_badse : Include files modified in 10.1.29 main.type_bit : Modified in 10.1.29 main.type_date : Modified in 10.1.29 main.type_datetime_hires : MDEV-10687 - timeout main.type_varchar : Modified in 10.1.29 main.user_var : Modified in 10.1.29 -main.view : Modified in 10.1.29 -main.xml : Modified in 10.1.29 +main.view : Modified in 10.1.30 +main.xml : Modified in 10.1.30 #---------------------------------------------------------------- -archive.discover : MDEV-10510 - table is marked as crashed +archive.discover : MDEV-10510 - Table is marked as crashed +archive.mysqlhotcopy_archive : MDEV-14726 - Table is marked as crashed #---------------------------------------------------------------- binlog.binlog_commit_wait : MDEV-10150 - Error: too much time elapsed +binlog.binlog_flush_binlogs_delete_domain : MDEV-14431 - Wrong error code; added in 10.1.30 +binlog.binlog_gtid_delete_domain_debug : Added in 10.1.30 binlog.binlog_killed : MDEV-12925 - Wrong result binlog.binlog_spurious_ddl_errors : Include files modified in 10.1.29 binlog.binlog_xa_recover : MDEV-8517 - Extra checkpoint @@ -118,44 +122,20 @@ binlog_encryption.binlog_xa_recover : MDEV-12908 - Extra checkpoint binlog_encryption.encrypted_master : MDEV-12906 - Failed to sync binlog_encryption.rpl_parallel : MDEV-10653 - Timeout binlog_encryption.rpl_semi_sync : MDEV-11220 - Wrong result, MDEV-11673 - Valgrind warning +binlog_encryption.rpl_ssl : MDEV-14507 - Timeout on SLES 11.4 binlog_encryption.rpl_typeconv : MDEV-14362 - Lost connection to MySQL server during query #---------------------------------------------------------------- -connect.alter_xml : Modified in 10.1.27 -connect.alter_xml2 : Added in 10.1.27 -connect.infoschema-9739 : Modified in 10.1.27 -connect.infoschema2-9739 : Added in 10.1.27 -connect.jdbc_new : Modified in 10.1.27 -connect.json : Modified in 10.1.27 connect.json_java_2 : Include file modified in 10.1.29 connect.json_java_3 : Include file modified in 10.1.29 connect.json_mongo_c : Include file modified in 10.1.29 -connect.json_udf : Modified in 10.1.27 -connect.json_udf_bin : Modified in 10.1.27 connect.mongo_c : Include file modified in 10.1.29 connect.mongo_java_2 : Include file modified in 10.1.29 connect.mongo_java_3 : Include file modified in 10.1.29 -connect.mul_new : Added in 10.1.27 -connect.mysql_exec : Modified in 10.1.27 -connect.mysql_new : Modified in 10.1.27 -connect.tbl : MDEV-9844, MDEV-10179 - sporadic crashes, valgrind warnings, wrong results; modified in 10.1.27 -connect.tbl_thread : MDEV-9844, MDEV-10179, MDEV-14214 - sporadic crashes, valgrind warnings, wrong results; added in 10.1.27 -connect.unsigned : Modified in 10.1.27 -connect.upd : Modified in 10.1.27 -connect.xml : Modified in 10.1.27 -connect.xml2 : Added in 10.1.27 -connect.xml2_grant : Added in 10.1.27 -connect.xml2_html : Added in 10.1.27 -connect.xml2_mdev5261 : Added in 10.1.27 -connect.xml2_mult : Added in 10.1.27 -connect.xml2_zip : Added in 10.1.27 -connect.xml_grant : Modified in 10.1.27 -connect.xml_html : Modified in 10.1.27 -connect.xml_mdev5261 : Modified in 10.1.27 -connect.xml_mult : Modified in 10.1.27 -connect.xml_zip : Modified in 10.1.27 -connect.zip : MDEV-13884 - Wrong result; modified in 10.1.27 +connect.tbl : MDEV-9844, MDEV-10179 - sporadic crashes, valgrind warnings, wrong results +connect.tbl_thread : MDEV-9844, MDEV-10179, MDEV-14214 - sporadic crashes, valgrind warnings, wrong results +connect.zip : MDEV-13884 - Wrong result #---------------------------------------------------------------- @@ -166,8 +146,8 @@ encryption.encryption_force : Modified in 10.1.29 encryption.filekeys_encfile : Include file modified in 10.1.29 encryption.filekeys_encfile_file : Include file modified in 10.1.29 encryption.innodb-bad-key-change2 : MDEV-12632 - Valgrind warnings +encryption.innodb-compressed-blob : MDEV-14728 - Unable to get certificate encryption.innodb-discard-import-change : MDEV-12632 - Valgrind warnings -encryption.innodb_encryption : Modified in 10.1.27 encryption.innodb-encryption-alter : Modified in 10.1.29 encryption.innodb_encryption_discard_import : MDEV-12903 - Wrong result encryption.innodb_encryption_filekeys : MDEV-9962 - timeouts @@ -175,7 +155,7 @@ encryption.innodb_encryption-page-compression : MDEV-12630 - crash or assertion encryption.innodb_encryption_tables : MDEV-9359 - Assertion failure encryption.innodb_first_page : MDEV-10689 - crashes encryption.innodb-first-page-read : MDEV-14356 - Timeout on wait condition -encryption.innodb_lotoftables : MDEV-11531 - InnoDB error; modified in 10.1.27 +encryption.innodb_lotoftables : MDEV-11531 - InnoDB error encryption.innodb-missing-key : MDEV-9359 - assertion failure encryption.innodb-page_encryption : MDEV-10641 - mutex problem encryption.innodb-redo-badkey : MDEV-12898 - Server hang on startup @@ -223,44 +203,37 @@ galera.MW-328A : MDEV-13876 - Wrong result #---------------------------------------------------------------- -innodb.alter_rename_existing : Added in 10.1.27 innodb.binlog_consistent : MDEV-10618 - Server fails to start -innodb.create-index-debug : Added in 10.1.27 innodb.doublewrite : MDEV-12905, MDEV-14205 - Lost connection to MySQL server -innodb.index_tree_operation : Added in 10.1.27 +innodb_fts.fulltext2 : MDEV-14727 - Long semaphore wait innodb.innodb-16k : Modified in 10.1.29 innodb.innodb-32k : Modified in 10.1.29 innodb.innodb-64k : Modified in 10.1.29 innodb.innodb-64k-crash : MDEV-13872 - Failure and crash on startup innodb.innodb-alter : Modified in 10.1.29 -innodb.innodb-alter-autoinc : Added in 10.1.27 innodb.innodb-alter-debug : MDEV-13182 - InnoDB: adjusting FSP_SPACE_FLAGS innodb.innodb-alter-table : MDEV-10619 - Testcase timeout; modified in 10.1.29 +innodb.innodb-autoinc : Modified in 10.1.30 innodb.innodb-blob : MDEV-12053 - Client crash innodb.innodb_bug14147491 : MDEV-11808 - wrong error codes innodb.innodb_bug30423 : MDEV-7311 - Wrong number of rows in the plan -innodb.innodb-enlarge-blob : Modified in 10.1.27 +innodb.innodb_bug48024 : MDEV-14352 - Assertion failure innodb.innodb-fk : MDEV-13832 - Assertion failure on shutdown innodb.innodb-get-fk : Modified in 10.1.29 -innodb.innodb-index-debug : Added in 10.1.27 -innodb.innodb-index-online : Added in 10.1.27 -innodb.innodb-index-online-delete : Added in 10.1.27 -innodb.innodb-index-online-fk : Added in 10.1.27 -innodb.innodb-index-online-purge : Added in 10.1.27 innodb.innodb-page_compression_lzma : MDEV-14353 - wrong result on Fedora 25 innodb.innodb-page_compression_tables : Modified in 10.1.29 innodb.innodb-page_compression_zip : MDEV-10641 - mutex problem +innodb.innodb-replace-debug : Added in 10.1.30 innodb.innodb_stats : MDEV-10682 - wrong result innodb.innodb_sys_semaphore_waits : MDEV-10331 - wrong result innodb.innodb-table-online : Modified in 10.1.29 innodb.innodb-wl5522-debug : Modified in 10.1.29 innodb.innodb-wl5980-alter : Modified in 10.1.29 innodb.innodb_zip_innochecksum2 : MDEV-13882 - Warning: difficult to find free blocks -innodb.log_data_file_size : Modified in 10.1.27 -innodb.table_definition_cache_debug : MDEV-14206 - Extra warning; modified in 10.1.29 +innodb.recovery_shutdown : Added in 10.1.30 +innodb.table_definition_cache_debug : MDEV-14206 - Extra warning; opt file modified in 10.1.30 innodb.table_flags : MDEV-14363 - Operating system error number 2 innodb.undo_log : Modified in 10.1.29 -innodb.xa_recovery : Modified in 10.1.27 innodb_fts.concurrent_insert : Added in 10.1.29 innodb_fts.fulltext : Modified in 10.1.29 @@ -271,18 +244,15 @@ innodb_zip.wl5522_debug_zip : Added in 10.1.29 #---------------------------------------------------------------- -maria.maria : Modified in 10.1.29 +maria.maria : MDEV-14430 - Wrong result; modified in 10.1.29 #---------------------------------------------------------------- -mariabackup.apply-log-only : Added in 10.1.27 -mariabackup.apply-log-only-incr : Added in 10.1.27 -mariabackup.auth_plugin_win : Added in 10.1.27 mariabackup.compress_qpress : Added in 10.1.29 mariabackup.data_directory : Added in 10.1.29 mariabackup.incremental_backup : Modified in 10.1.29 +mariabackup.mdev-14447 : Added in 10.1.30 mariabackup.partition_datadir : Added in 10.1.29 -mariabackup.xb_aws_key_management : Modified in 10.1.27 #---------------------------------------------------------------- @@ -297,6 +267,12 @@ mroonga/storage.index_multiple_column_unique_date_32bit_equal : Wrong resul 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 warnings mroonga/storage.repair_table_no_index_file : MDEV-9364 - wrong result +mroonga/storage.variable_query_log_file_disabled_empty_value : Modified in 10.1.30 +mroonga/storage.variable_query_log_file_disabled_null_value : Modified in 10.1.30 +mroonga/storage.variable_query_log_file_enabled_empty_value : Modified in 10.1.30 +mroonga/storage.variable_query_log_file_enabled_null_value : Modified in 10.1.30 +mroonga/storage.variable_query_log_file_new_value : Modified in 10.1.30 +mroonga/storage.variable_query_log_file_same_value : Modified in 10.1.30 #---------------------------------------------------------------- @@ -309,23 +285,18 @@ multi_source.status_vars : MDEV-4632 - failed while waiting for Slave_received_h #---------------------------------------------------------------- -parts.partition_alter_maria : Added in 10.1.29 +parts.partition_alter_innodb : Added in 10.1.30 +parts.partition_alter_maria : Modified in 10.1.30 +parts.partition_alter_myisam : Added in 10.1.30 parts.partition_alter2_2_maria : MDEV-14364 - Lost connection to MySQL server during query -parts.partition_exch_myisam_innodb : Modified in 10.1.27 -parts.partition_exch_qa_10 : Include files modified in 10.1.27 -parts.partition_exch_qa_11 : Include files modified in 10.1.27 -parts.partition_exch_qa_12 : Include files modified in 10.1.27 -parts.partition_exch_qa_14 : Modified in 10.1.27 -parts.partition_exch_qa_15 : Modified in 10.1.27 -parts.partition_exch_qa_2 : Modified in 10.1.27 -parts.partition_exch_qa_3 : Modified in 10.1.27 -parts.partition_exch_qa_6 : Modified in 10.1.27 +parts.partition_auto_increment_maria : MDEV-14430 - Wrong result parts.partition_innodb_status_file : MDEV-12901 - Valgrind #---------------------------------------------------------------- perfschema.func_file_io : MDEV-5708 - fails for s390x perfschema.func_mutex : MDEV-5708 - fails for s390x +perfschema.misc : Modified in 10.1.30 perfschema.privilege_table_io : MDEV-13184 - Extra lines perfschema.setup_actors : MDEV-10679 - rare crash perfschema.socket_summary_by_event_name_func : MDEV-10622 - Socket summary tables do not match @@ -335,6 +306,7 @@ perfschema.threads_mysql : MDEV-10677 - sporadic wrong resul #---------------------------------------------------------------- +plugins.binlog-simple_plugin_check : Added in 10.1.30 plugins.feedback_plugin_send : MDEV-7932 - ssl failed for url plugins.server_audit : MDEV-9562 - crashes on sol10-sparc; modified in 10.1.29 plugins.thread_pool_server_audit : MDEV-9562 - crashes on sol10-sparc; modified in 10.1.29 @@ -342,6 +314,8 @@ plugins.thread_pool_server_audit : MDEV-9562 - crashes on sol10-sparc; modified #---------------------------------------------------------------- roles.definer : Modified in 10.1.29 +roles.flush_roles-12366 : Added in 10.1.30 +roles.set_role-13655 : Added in 10.1.30 #---------------------------------------------------------------- @@ -356,7 +330,9 @@ rpl.rpl_domain_id_filter_io_crash : MDEV-14357 - Wrong result rpl.rpl_domain_id_filter_restart : MDEV-10684 - Wrong result rpl.rpl_gtid_basic : MDEV-10681 - server startup problem rpl.rpl_gtid_crash : MDEV-9501 - Warning: failed registering on master +rpl.rpl_gtid_delete_domain : MDEV-14463 - Timeout in include; added in 10.1.30 rpl.rpl_gtid_mdev9033 : MDEV-10680 - warnings +rpl.rpl_gtid_reconnect : MDEV-14497 - Timeout 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 @@ -366,20 +342,29 @@ rpl.rpl_insert_ignore : MDEV-14365 - Lost connection to MySQL se rpl.rpl_invoked_features : MDEV-10417 - Fails on Mips rpl.rpl_mariadb_slave_capability : MDEV-11018 - sporadic wrong events in binlog rpl.rpl_mdev6020 : MDEV-10630, MDEV-10417 - Timeouts, fails on Mips +rpl.rpl_mixed_mixing_engines : MDEV-14489 - Sync slave with master failed +rpl.rpl_non_direct_mixed_mixing_engines : MDEV-14489 - Sync slave with master failed +rpl.rpl_non_direct_row_mixing_engines : MDEV-14491 - Long semaphore wait +rpl.rpl_non_direct_stm_mixing_engines : MDEV-14489 - Sync slave with master failed rpl.rpl_parallel : MDEV-10653 - Timeouts rpl.rpl_parallel_mdev6589 : MDEV-12979 - Assertion failure -rpl.rpl_parallel_optimistic : MDEV-10511 - timeout +rpl.rpl_parallel_multilevel2 : MDEV-14723 - Timeout +rpl.rpl_parallel_optimistic : MDEV-10511 - Timeout rpl.rpl_parallel_retry : MDEV-11119 - Server crash rpl.rpl_parallel_temptable : MDEV-10356 - Crash in close_thread_tables rpl.rpl_partition_innodb : MDEV-10417 - Fails on Mips rpl.rpl_password_boundaries : MDEV-11534 - Slave IO warnings rpl.rpl_plugin_load : Include files modified in 10.1.29 +rpl.rpl_row_drop_create_temp_table : MDEV-14487 - Wrong result rpl.rpl_row_img_blobs : MDEV-13875 - command "diff_files" failed rpl.rpl_row_img_eng_min : MDEV-13875 - command "diff_files" failed rpl.rpl_row_img_eng_noblob : MDEV-13875 - command "diff_files" failed -rpl.rpl_row_log_innodb : MDEV-10688 - Wrong result +rpl.rpl_row_log : Include file modified in 10.1.30 +rpl.rpl_row_log_innodb : Include file modified in 10.1.30 +rpl.rpl_row_mixing_engines : MDEV-14491 - Long semaphore wait rpl.rpl_row_sp001 : MDEV-9329 - Fails on Ubuntu/s390x rpl.rpl_semi_sync : MDEV-11220 - Wrong result +rpl.rpl_semi_sync_after_sync : MDEV-14366 - Wrong result rpl.rpl_semi_sync_after_sync_row : MDEV-14366 - Wrong result rpl.rpl_semi_sync_event_after_sync : MDEV-11806 - warnings rpl.rpl_semi_sync_uninstall_plugin : MDEV-7140 - Wrong plugin status @@ -387,12 +372,12 @@ rpl.rpl_semi_sync_wait_point : MDEV-11807 - timeout in wait condition rpl.rpl_show_slave_hosts : MDEV-10681 - server startup problem rpl.rpl_skip_replication : MDEV-9268 - Fails with timeout in sync_slave_with_master on Alpha rpl.rpl_slave_grp_exec : MDEV-10514 - Unexpected deadlock -rpl.rpl_sp_variables : Added in 10.1.27 rpl.rpl_start_stop_slave : MDEV-13567 - Replication failure +rpl.rpl_stm_log : Include file modified in 10.1.30 +rpl.rpl_stm_mixing_engines : MDEV-14489 - Sync slave with master failed rpl.rpl_stm_relay_ign_space : MDEV-14360 - Test assertion rpl.rpl_sync : MDEV-10633 - Database page corruption rpl.rpl_table_options : Include files modified in 10.1.29 -rpl.rpl_temporal_format_mariadb53_to_mysql56_dst : Added in 10.1.27 rpl.rpl_temporary_error2 : MDEV-10634 - Wrong number of retries rpl.sec_behind_master-5114 : MDEV-13878 - Wrong result @@ -439,8 +424,6 @@ sys_vars.innodb_buffer_pool_load_now_basic : Modified in 10.1.29 sys_vars.innodb_fatal_semaphore_wait_threshold : MDEV-10513 - crashes sys_vars.log_slow_admin_statements_func : MDEV-12235 - Server crash sys_vars.rpl_init_slave_func : MDEV-10149 - wrong results -sys_vars.sysvars_innodb : MDEV-6958 - error-prone rdiffs -sys_vars.sysvars_server_embedded : MDEV-6958 - error-prone rdiffs sys_vars.sysvars_wsrep : MDEV-12522 - Dependency on specific wsrep_provider sys_vars.thread_cache_size_func : MDEV-11775 - Wrong result sys_vars.wait_timeout_func : MDEV-12896 - Wrong result @@ -453,7 +436,7 @@ tokudb.change_column_char : MDEV-12822 - Lost connection to MySQL ser tokudb.cluster_filter : MDEV-10678 - Wrong execution plan tokudb.cluster_filter_hidden : MDEV-10678 - Wrong execution plan tokudb.cluster_filter_unpack_varchar : MDEV-10636 - Wrong execution plan -tokudb.dir_per_db : MDEV-11537 - Wrong result; modified in 10.1.27 +tokudb.dir_per_db : MDEV-11537 - Wrong result tokudb.dir_per_db_rename_to_nonexisting_schema : MDEV-14359 - Directory not empty tokudb.hotindex-insert-bigchar : MDEV-12640 - Crash tokudb.hotindex-insert-1 : MDEV-13870 - Lost connection to MySQL server @@ -467,6 +450,9 @@ tokudb_bugs.xa : MDEV-11804 - Lock wait timeout tokudb_mariadb.mdev6657 : MDEV-12737 - Wrong plan, valgrind warnings +rpl-tokudb.rpl_tokudb_row_log : Include file modified in 10.1.30 +rpl-tokudb.rpl_tokudb_stm_log : Include file modified in 10.1.30 + #---------------------------------------------------------------- unit.lf : MDEV-12897 - Signal 11 thrown @@ -481,8 +467,8 @@ vcol.vcol_misc : Modified in 10.1.29 #---------------------------------------------------------------- wsrep.binlog_format : MDEV-11532 - WSREP has not yet prepared node -wsrep.mdev_6832 : MDEV-14195 - Failure upon check-testcase; option file changed in 10.1.27 -wsrep.mdev_7798 : Option file changed in 10.1.27 +wsrep.foreign_key : MDEV-14725 - WSREP has not yet prepared node +wsrep.mdev_6832 : MDEV-14195 - Failure upon check-testcase wsrep.pool_of_threads : MDEV-12234 - Library problem on Power wsrep_info.plugin : MDEV-12909 - Wrong result From 1cf28964f50443518d8b665b226c1666274840e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 21 Dec 2017 10:19:49 +0200 Subject: [PATCH 33/69] MDEV-6247 post-fix: Re-enable some debug assertions These assertions were disabled in MariaDB 10.1.1 in commit df4dd593f29aec8e2116aec1775ad4b8833d8c93 with a bogus comment referring to the function wsrep_fake_trx_id() that was introduced in the very same commit. --- storage/innobase/include/trx0sys.ic | 3 --- storage/innobase/trx/trx0sys.cc | 5 ----- storage/xtradb/include/trx0sys.ic | 3 --- storage/xtradb/trx/trx0sys.cc | 5 ----- 4 files changed, 16 deletions(-) diff --git a/storage/innobase/include/trx0sys.ic b/storage/innobase/include/trx0sys.ic index 7265a97ae25..e097e29b551 100644 --- a/storage/innobase/include/trx0sys.ic +++ b/storage/innobase/include/trx0sys.ic @@ -445,10 +445,7 @@ trx_id_t trx_sys_get_new_trx_id(void) /*========================*/ { -#ifndef WITH_WSREP - /* wsrep_fake_trx_id violates this assert */ ut_ad(mutex_own(&trx_sys->mutex)); -#endif /* WITH_WSREP */ /* VERY important: after the database is started, max_trx_id value is divisible by TRX_SYS_TRX_ID_WRITE_MARGIN, and the following if diff --git a/storage/innobase/trx/trx0sys.cc b/storage/innobase/trx/trx0sys.cc index e9443e93140..0246eaf32a8 100644 --- a/storage/innobase/trx/trx0sys.cc +++ b/storage/innobase/trx/trx0sys.cc @@ -180,12 +180,7 @@ trx_sys_flush_max_trx_id(void) mtr_t mtr; trx_sysf_t* sys_header; -#ifndef WITH_WSREP - /* wsrep_fake_trx_id violates this assert - * Copied from trx_sys_get_new_trx_id - */ ut_ad(mutex_own(&trx_sys->mutex)); -#endif /* WITH_WSREP */ if (!srv_read_only_mode) { mtr_start(&mtr); diff --git a/storage/xtradb/include/trx0sys.ic b/storage/xtradb/include/trx0sys.ic index 6024c1dc94e..699148cff6d 100644 --- a/storage/xtradb/include/trx0sys.ic +++ b/storage/xtradb/include/trx0sys.ic @@ -474,10 +474,7 @@ trx_id_t trx_sys_get_new_trx_id(void) /*========================*/ { -#ifndef WITH_WSREP - /* wsrep_fake_trx_id violates this assert */ ut_ad(mutex_own(&trx_sys->mutex)); -#endif /* WITH_WSREP */ /* VERY important: after the database is started, max_trx_id value is divisible by TRX_SYS_TRX_ID_WRITE_MARGIN, and the following if diff --git a/storage/xtradb/trx/trx0sys.cc b/storage/xtradb/trx/trx0sys.cc index 83bb28b3c07..6108ab7ab94 100644 --- a/storage/xtradb/trx/trx0sys.cc +++ b/storage/xtradb/trx/trx0sys.cc @@ -184,12 +184,7 @@ trx_sys_flush_max_trx_id(void) mtr_t mtr; trx_sysf_t* sys_header; -#ifndef WITH_WSREP - /* wsrep_fake_trx_id violates this assert - * Copied from trx_sys_get_new_trx_id - */ ut_ad(mutex_own(&trx_sys->mutex)); -#endif /* WITH_WSREP */ if (!srv_read_only_mode) { mtr_start(&mtr); From 0202e47274eac1ca3a8be98b7089b1ca3bffe8d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 21 Dec 2017 17:19:13 +0200 Subject: [PATCH 34/69] MDEV-12827 Assertion failure when reporting duplicate key error in online table rebuild row_log_table_apply_insert_low(), row_log_table_apply_update(): When reporting the error_key_num, only count the clustered index if it corresponds to a key in the SQL layer. The assertion failure was probably introduced by the (incomplete) MySQL 5.6.28 bug fix Bug #21364096 THE BOGUS DUPLICATE KEY ERROR IN ONLINE DDL WITH INCORRECT KEY NAME which we are improving. Side note: the fix was incorrectly merged to MySQL 5.7.10; incorrect key names will continue to be reported in MySQL 5.7. --- .../suite/innodb/r/innodb-index-debug.result | 22 ++++++++++ .../suite/innodb/t/innodb-index-debug.test | 42 ++++++++++++++++++- storage/innobase/row/row0log.cc | 33 +++++++-------- storage/xtradb/row/row0log.cc | 33 +++++++-------- 4 files changed, 92 insertions(+), 38 deletions(-) diff --git a/mysql-test/suite/innodb/r/innodb-index-debug.result b/mysql-test/suite/innodb/r/innodb-index-debug.result index d78ba68078d..69dd8742b5b 100644 --- a/mysql-test/suite/innodb/r/innodb-index-debug.result +++ b/mysql-test/suite/innodb/r/innodb-index-debug.result @@ -67,3 +67,25 @@ alter table t1 force, algorithm=inplace; 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 SET DEBUG_DBUG = @saved_debug_dbug; drop table t1, t480; +# +# MDEV-12827 Assertion failure when reporting duplicate key error +# in online table rebuild +# +CREATE TABLE t1 (j INT UNIQUE, i INT UNIQUE) ENGINE=InnoDB; +SET DEBUG_SYNC='row_log_table_apply1_before SIGNAL built WAIT_FOR log'; +ALTER TABLE t1 DROP j, FORCE; +SET DEBUG_SYNC='now WAIT_FOR built'; +INSERT INTO t1 (i) VALUES (0),(0); +ERROR 23000: Duplicate entry '0' for key 'i' +SET DEBUG_SYNC='now SIGNAL log'; +ERROR 23000: Duplicate entry '0' for key 'i' +SET DEBUG_SYNC='row_log_table_apply1_before SIGNAL built2 WAIT_FOR log2'; +ALTER TABLE t1 DROP j, FORCE; +SET DEBUG_SYNC='now WAIT_FOR built2'; +INSERT INTO t1 (i) VALUES (0),(1); +UPDATE t1 SET i=0; +ERROR 23000: Duplicate entry '0' for key 'i' +SET DEBUG_SYNC='now SIGNAL log2'; +ERROR 23000: Duplicate entry '0' for key 'i' +SET DEBUG_SYNC='RESET'; +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/innodb-index-debug.test b/mysql-test/suite/innodb/t/innodb-index-debug.test index d4fcda4f160..e179b969a6a 100644 --- a/mysql-test/suite/innodb/t/innodb-index-debug.test +++ b/mysql-test/suite/innodb/t/innodb-index-debug.test @@ -1,7 +1,6 @@ -- source include/have_debug.inc -- source include/have_innodb.inc - -let $MYSQLD_DATADIR= `select @@datadir`; +-- source include/have_debug_sync.inc let $per_table=`select @@innodb_file_per_table`; let $format=`select @@innodb_file_format`; @@ -82,3 +81,42 @@ SET DEBUG_DBUG = '+d,innobase_tmpfile_creation_failure'; alter table t1 force, algorithm=inplace; SET DEBUG_DBUG = @saved_debug_dbug; drop table t1, t480; + +--echo # +--echo # MDEV-12827 Assertion failure when reporting duplicate key error +--echo # in online table rebuild +--echo # + +CREATE TABLE t1 (j INT UNIQUE, i INT UNIQUE) ENGINE=InnoDB; +--connect (con1,localhost,root,,test) +SET DEBUG_SYNC='row_log_table_apply1_before SIGNAL built WAIT_FOR log'; +--send +ALTER TABLE t1 DROP j, FORCE; + +--connection default +SET DEBUG_SYNC='now WAIT_FOR built'; +--error ER_DUP_ENTRY +INSERT INTO t1 (i) VALUES (0),(0); +SET DEBUG_SYNC='now SIGNAL log'; + +--connection con1 +--error ER_DUP_ENTRY +reap; +SET DEBUG_SYNC='row_log_table_apply1_before SIGNAL built2 WAIT_FOR log2'; +--send +ALTER TABLE t1 DROP j, FORCE; + +--connection default +SET DEBUG_SYNC='now WAIT_FOR built2'; +INSERT INTO t1 (i) VALUES (0),(1); +--error ER_DUP_ENTRY +UPDATE t1 SET i=0; +SET DEBUG_SYNC='now SIGNAL log2'; + +--connection con1 +--error ER_DUP_ENTRY +reap; +--disconnect con1 +--connection default +SET DEBUG_SYNC='RESET'; +DROP TABLE t1; diff --git a/storage/innobase/row/row0log.cc b/storage/innobase/row/row0log.cc index 0b7ef86fdd3..bc256c62d96 100644 --- a/storage/innobase/row/row0log.cc +++ b/storage/innobase/row/row0log.cc @@ -1520,13 +1520,10 @@ row_log_table_apply_insert_low( return(error); } - do { - n_index++; - - if (!(index = dict_table_get_next_index(index))) { - break; - } + ut_ad(dict_index_is_clust(index)); + for (n_index += index->type != DICT_CLUSTERED; + (index = dict_table_get_next_index(index)); n_index++) { if (index->type & DICT_FTS) { continue; } @@ -1536,12 +1533,13 @@ row_log_table_apply_insert_low( flags, BTR_MODIFY_TREE, index, offsets_heap, heap, entry, trx_id, thr); - /* Report correct index name for duplicate key error. */ - if (error == DB_DUPLICATE_KEY) { - thr_get_trx(thr)->error_key_num = n_index; + if (error != DB_SUCCESS) { + if (error == DB_DUPLICATE_KEY) { + thr_get_trx(thr)->error_key_num = n_index; + } + break; } - - } while (error == DB_SUCCESS); + } return(error); } @@ -2120,17 +2118,16 @@ func_exit_committed: dtuple_big_rec_free(big_rec); } - while ((index = dict_table_get_next_index(index)) != NULL) { - if (error != DB_SUCCESS) { - break; - } - - n_index++; - + for (n_index += index->type != DICT_CLUSTERED; + (index = dict_table_get_next_index(index)); n_index++) { if (index->type & DICT_FTS) { continue; } + if (error != DB_SUCCESS) { + break; + } + if (!row_upd_changes_ord_field_binary( index, update, thr, old_row, NULL)) { continue; diff --git a/storage/xtradb/row/row0log.cc b/storage/xtradb/row/row0log.cc index 874c0901451..44b22ee84bb 100644 --- a/storage/xtradb/row/row0log.cc +++ b/storage/xtradb/row/row0log.cc @@ -1520,13 +1520,10 @@ row_log_table_apply_insert_low( return(error); } - do { - n_index++; - - if (!(index = dict_table_get_next_index(index))) { - break; - } + ut_ad(dict_index_is_clust(index)); + for (n_index += index->type != DICT_CLUSTERED; + (index = dict_table_get_next_index(index)); n_index++) { if (index->type & DICT_FTS) { continue; } @@ -1536,12 +1533,13 @@ row_log_table_apply_insert_low( flags, BTR_MODIFY_TREE, index, offsets_heap, heap, entry, trx_id, thr); - /* Report correct index name for duplicate key error. */ - if (error == DB_DUPLICATE_KEY) { - thr_get_trx(thr)->error_key_num = n_index; + if (error != DB_SUCCESS) { + if (error == DB_DUPLICATE_KEY) { + thr_get_trx(thr)->error_key_num = n_index; + } + break; } - - } while (error == DB_SUCCESS); + } return(error); } @@ -2120,17 +2118,16 @@ func_exit_committed: dtuple_big_rec_free(big_rec); } - while ((index = dict_table_get_next_index(index)) != NULL) { - if (error != DB_SUCCESS) { - break; - } - - n_index++; - + for (n_index += index->type != DICT_CLUSTERED; + (index = dict_table_get_next_index(index)); n_index++) { if (index->type & DICT_FTS) { continue; } + if (error != DB_SUCCESS) { + break; + } + if (!row_upd_changes_ord_field_binary( index, update, thr, old_row, NULL)) { continue; From 461cf3e5a3c2d346d75b1407b285f8daf9d01f67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 21 Dec 2017 17:40:01 +0200 Subject: [PATCH 35/69] Make a test more robust Sometimes, the test would fail with a result difference for the READ UNCOMMITTED read, because the incremental backup would finish before redo log was written for all the rows that were inserted in the second batch. To fix that, cause a redo log write by creating another transaction. The transaction rollback (which internally does commit) will be flushed to the redo log, and before that, all the preceding changes will be flushed to the redo log as well. --- mysql-test/suite/mariabackup/apply-log-only-incr.result | 4 ++++ mysql-test/suite/mariabackup/apply-log-only-incr.test | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/mysql-test/suite/mariabackup/apply-log-only-incr.result b/mysql-test/suite/mariabackup/apply-log-only-incr.result index 2baed8c1db9..f724d1d1fdc 100644 --- a/mysql-test/suite/mariabackup/apply-log-only-incr.result +++ b/mysql-test/suite/mariabackup/apply-log-only-incr.result @@ -3,6 +3,10 @@ CREATE TABLE t(a INT UNSIGNED PRIMARY KEY) ENGINE INNODB; INSERT INTO t VALUES(0); COMMIT; start transaction; +BEGIN; +DELETE FROM t LIMIT 1; +SET GLOBAL innodb_flush_log_at_trx_commit = 1; +ROLLBACK; NOT FOUND /Rollback of trx with id/ in current_test # expect NOT FOUND NOT FOUND /Rollback of trx with id/ in current_test diff --git a/mysql-test/suite/mariabackup/apply-log-only-incr.test b/mysql-test/suite/mariabackup/apply-log-only-incr.test index aa5110cc51e..81c91d3c452 100644 --- a/mysql-test/suite/mariabackup/apply-log-only-incr.test +++ b/mysql-test/suite/mariabackup/apply-log-only-incr.test @@ -26,6 +26,13 @@ eval INSERT t VALUES(201-$n); dec $n; } --enable_query_log +connect (flush_log,localhost,root,,); +BEGIN; +DELETE FROM t LIMIT 1; +SET GLOBAL innodb_flush_log_at_trx_commit = 1; +ROLLBACK; +disconnect flush_log; +connection default; --disable_result_log exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --ftwrl-wait-timeout=5 --ftwrl-wait-threshold=300 --ftwrl-wait-query-type=all --target-dir=$incremental_dir --incremental-basedir=$basedir ; From 24efee9100f4666ac61e1ac317e3d0fd12a5265c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicen=C8=9Biu=20Ciorbaru?= Date: Thu, 21 Dec 2017 18:00:24 +0200 Subject: [PATCH 36/69] Follow up to MDEV-12366: FLUSH privileges can break hierarchy of roles A suggestion to make role propagation simpler from serg@mariadb.org. Instead of gathering the leaf roles in an array, which for very wide graphs could potentially mean a big part of the whole roles schema, keep the previous logic. When finally merging a role, set its counter to something positive. This will effectively mean that a role has been merged, thus a random pass through roles hash that touches a previously merged role won't cause the problem described in MDEV-12366 any more, as propagate_role_grants_action will stop attempting to merge from that role. --- sql/sql_acl.cc | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 27292105dde..0e4a0cef591 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -5366,6 +5366,8 @@ static int merge_role_privileges(ACL_ROLE *role __attribute__((unused)), if (--grantee->counter) return 1; // don't recurse into grantee just yet + grantee->counter= 1; // Mark the grantee as merged. + /* if we'll do db/table/routine privileges, create a hash of role names */ role_hash_t role_hash(role_key); if (data->what != PRIVS_TO_MERGE::GLOBAL) @@ -6555,14 +6557,16 @@ end_index_init: DBUG_RETURN(return_val); } -static my_bool collect_leaf_roles(void *role_ptr, - void *roles_array) +static my_bool propagate_role_grants_action(void *role_ptr, + void *ptr __attribute__((unused))) { ACL_ROLE *role= static_cast(role_ptr); - Dynamic_array *array= - static_cast *>(roles_array); - if (!role->counter) - array->push(role); + if (role->counter) + return 0; + + mysql_mutex_assert_owner(&acl_cache->lock); + PRIVS_TO_MERGE data= { PRIVS_TO_MERGE::ALL, 0, 0 }; + traverse_role_graph_up(role, &data, NULL, merge_role_privileges); return 0; } @@ -6645,15 +6649,7 @@ my_bool grant_reload(THD *thd) } mysql_mutex_lock(&acl_cache->lock); - Dynamic_array leaf_roles; - my_hash_iterate(&acl_roles, collect_leaf_roles, &leaf_roles); - PRIVS_TO_MERGE data= { PRIVS_TO_MERGE::ALL, 0, 0 }; - for (size_t i= 0; i < leaf_roles.elements(); i++) - { - traverse_role_graph_up(leaf_roles.at(i), &data, NULL, - merge_role_privileges); - } - + my_hash_iterate(&acl_roles, propagate_role_grants_action, NULL); mysql_mutex_unlock(&acl_cache->lock); mysql_rwlock_unlock(&LOCK_grant); From aed781ef7f0a733264f8a87d8c4f02951f03f78e Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Fri, 22 Dec 2017 01:13:43 +0300 Subject: [PATCH 37/69] Cleanup in storage/rocksdb/mysql-test/rocksdb_rpl/t/disabled.def --- storage/rocksdb/mysql-test/rocksdb_rpl/t/disabled.def | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/disabled.def b/storage/rocksdb/mysql-test/rocksdb_rpl/t/disabled.def index e46e89517a9..1a53f8a6f1a 100644 --- a/storage/rocksdb/mysql-test/rocksdb_rpl/t/disabled.def +++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/disabled.def @@ -5,6 +5,7 @@ rpl_no_unique_check_on_lag : unique_check_lag_threshold is not available in MariaDB rpl_no_unique_check_on_lag_mts : unique_check_lag_threshold is not available in MariaDB consistent_snapshot_mixed_engines : Tests START TRANSACTION WITH CONSISTENT $ENGINE_NAME SNAPSHOT +rpl_skip_trx_api_binlog_format : requires @@rpl_skip_tx_api ## ## Tests that are disabled for other reasons @@ -19,7 +20,6 @@ rpl_gtid_rocksdb_sys_header : Didn't try with MariaDB, yet rpl_rocksdb_snapshot : Didn't try with MariaDB, yet rpl_rocksdb_snapshot_without_gtid : Didn't try with MariaDB, yet rpl_rocksdb_stress_crash : Didn't try with MariaDB, yet -rpl_skip_trx_api_binlog_format : Didn't try with MariaDB, yet singledelete_idempotent_recovery : Didn't try with MariaDB, yet singledelete_idempotent_table : Didn't try with MariaDB, yet From ab0a7e13b279bb94b20c8d8010b61c410f8a478f Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Fri, 22 Dec 2017 02:21:27 +0300 Subject: [PATCH 38/69] More fixes in MyRocks' rocksdb_rpl testsuite - Make my.cnf to include rpl_1slave_base.cnf (needed for tests that actually use replication, i.e. need a functioning slave) - Adjust and enable singledelete_idempotent_table.test - More edits in disabled.def --- storage/rocksdb/mysql-test/rocksdb_rpl/my.cnf | 1 + .../r/singledelete_idempotent_table.result | 10 +++++++--- .../rocksdb/mysql-test/rocksdb_rpl/t/disabled.def | 13 +++++++++---- .../rocksdb_rpl/t/singledelete_idempotent_table.cnf | 10 +++------- .../t/singledelete_idempotent_table.test | 2 +- 5 files changed, 21 insertions(+), 15 deletions(-) diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/my.cnf b/storage/rocksdb/mysql-test/rocksdb_rpl/my.cnf index 2beaf514cee..ec7370b65f0 100644 --- a/storage/rocksdb/mysql-test/rocksdb_rpl/my.cnf +++ b/storage/rocksdb/mysql-test/rocksdb_rpl/my.cnf @@ -1,3 +1,4 @@ +!include rpl_1slave_base.cnf !include include/default_my.cnf [server] diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/r/singledelete_idempotent_table.result b/storage/rocksdb/mysql-test/rocksdb_rpl/r/singledelete_idempotent_table.result index 609d4a8821a..979e2cbf6c3 100644 --- a/storage/rocksdb/mysql-test/rocksdb_rpl/r/singledelete_idempotent_table.result +++ b/storage/rocksdb/mysql-test/rocksdb_rpl/r/singledelete_idempotent_table.result @@ -1,16 +1,19 @@ include/master-slave.inc -Warnings: -Note #### Sending passwords in plain text without SSL/TLS is extremely insecure. -Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information. [connection master] +connection master; drop table if exists r1; create table r1 (id1 int, id2 int, primary key (id1, id2), index i (id2)) engine=rocksdb; insert into r1 values (1, 1000); set sql_log_bin=0; delete from r1 where id1=1 and id2=1000; set sql_log_bin=1; +connection slave; +connection slave; set global rocksdb_force_flush_memtable_now=1; +connection master; insert into r1 values (1, 1000); +connection slave; +connection slave; delete r1 from r1 force index (i) where id2=1000; select id1,id2 from r1 force index (primary); id1 id2 @@ -21,5 +24,6 @@ select id1,id2 from r1 force index (primary); id1 id2 select id2 from r1 force index (i); id2 +connection master; drop table r1; include/rpl_end.inc diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/disabled.def b/storage/rocksdb/mysql-test/rocksdb_rpl/t/disabled.def index 1a53f8a6f1a..a082a4a16be 100644 --- a/storage/rocksdb/mysql-test/rocksdb_rpl/t/disabled.def +++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/disabled.def @@ -6,6 +6,15 @@ rpl_no_unique_check_on_lag : unique_check_lag_threshold is not available in Mar rpl_no_unique_check_on_lag_mts : unique_check_lag_threshold is not available in MariaDB consistent_snapshot_mixed_engines : Tests START TRANSACTION WITH CONSISTENT $ENGINE_NAME SNAPSHOT rpl_skip_trx_api_binlog_format : requires @@rpl_skip_tx_api +rpl_ddl_high_priority : DDL commands with HIGH_PRIORITY syntax are not in MariaDB +rpl_gtid_rocksdb_sys_header : MariaDB doesn't support printing "RocksDB: Last MySQL Gtid UUID" into server stderr on startup + + +## +## Tests that do not fit MariaDB's test environment (Functional tests only, +## can't have stress tests) +## +rpl_rocksdb_stress_crash : Stress test ## ## Tests that are disabled for other reasons @@ -13,13 +22,9 @@ rpl_skip_trx_api_binlog_format : requires @@rpl_skip_tx_api multiclient_2pc : Didn't try with MariaDB, yet rpl_crash_safe_wal_corrupt : Didn't try with MariaDB, yet -rpl_ddl_high_priority : Didn't try with MariaDB, yet rpl_gtid_crash_safe : Didn't try with MariaDB, yet rpl_gtid_crash_safe_wal_corrupt : Didn't try with MariaDB, yet -rpl_gtid_rocksdb_sys_header : Didn't try with MariaDB, yet rpl_rocksdb_snapshot : Didn't try with MariaDB, yet rpl_rocksdb_snapshot_without_gtid : Didn't try with MariaDB, yet -rpl_rocksdb_stress_crash : Didn't try with MariaDB, yet singledelete_idempotent_recovery : Didn't try with MariaDB, yet -singledelete_idempotent_table : Didn't try with MariaDB, yet diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/singledelete_idempotent_table.cnf b/storage/rocksdb/mysql-test/rocksdb_rpl/t/singledelete_idempotent_table.cnf index ad4894f5b38..5f1f87d762f 100644 --- a/storage/rocksdb/mysql-test/rocksdb_rpl/t/singledelete_idempotent_table.cnf +++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/singledelete_idempotent_table.cnf @@ -2,14 +2,10 @@ [mysqld.1] log_slave_updates -gtid_mode=ON -enforce_gtid_consistency=ON [mysqld.2] relay_log_recovery=1 -relay_log_info_repository=FILE +#relay_log_info_repository=FILE log_slave_updates -gtid_mode=ON -enforce_gtid_consistency=ON -rbr_idempotent_tables='r1' - +#rbr_idempotent_tables='r1' +slave_exec_mode=IDEMPOTENT diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/singledelete_idempotent_table.test b/storage/rocksdb/mysql-test/rocksdb_rpl/t/singledelete_idempotent_table.test index 23d335d6b57..00dce7c2ca9 100644 --- a/storage/rocksdb/mysql-test/rocksdb_rpl/t/singledelete_idempotent_table.test +++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/singledelete_idempotent_table.test @@ -2,7 +2,7 @@ --source include/have_binlog_format_row.inc --source include/have_rocksdb.inc --source include/master-slave.inc ---source include/have_gtid.inc +#--source include/have_gtid.inc --source include/not_valgrind.inc # This is a test case for issue#655 -- SingleDelete on Primary Key may From 5426f6e30fced3087d7851bfbec10a74cc0b3a5b Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Fri, 22 Dec 2017 02:30:32 +0300 Subject: [PATCH 39/69] Better comments: explain why slave_use_idempotent_for_recovery is disabled --- storage/rocksdb/mysql-test/rocksdb_rpl/t/disabled.def | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/disabled.def b/storage/rocksdb/mysql-test/rocksdb_rpl/t/disabled.def index a082a4a16be..4f739a558e8 100644 --- a/storage/rocksdb/mysql-test/rocksdb_rpl/t/disabled.def +++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/disabled.def @@ -8,7 +8,7 @@ consistent_snapshot_mixed_engines : Tests START TRANSACTION WITH CONSISTENT $ENG rpl_skip_trx_api_binlog_format : requires @@rpl_skip_tx_api rpl_ddl_high_priority : DDL commands with HIGH_PRIORITY syntax are not in MariaDB rpl_gtid_rocksdb_sys_header : MariaDB doesn't support printing "RocksDB: Last MySQL Gtid UUID" into server stderr on startup - +slave_use_idempotent_for_recovery: MariaDB doesn't support --slave-use-idempotent-for-recovery ## ## Tests that do not fit MariaDB's test environment (Functional tests only, @@ -26,5 +26,4 @@ rpl_gtid_crash_safe : Didn't try with MariaDB, yet rpl_gtid_crash_safe_wal_corrupt : Didn't try with MariaDB, yet rpl_rocksdb_snapshot : Didn't try with MariaDB, yet rpl_rocksdb_snapshot_without_gtid : Didn't try with MariaDB, yet -singledelete_idempotent_recovery : Didn't try with MariaDB, yet From a76a2522ec4f8c069827e038997387a8b8eb3a3a Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Fri, 22 Dec 2017 08:22:10 +0400 Subject: [PATCH 40/69] MDEV-14426 Assertion in Diagnostics_area::set_error_status when using a bad datetime with PS and SP --- mysql-test/r/ps.result | 29 +++++++++++++++++++++++++++++ mysql-test/t/ps.test | 34 ++++++++++++++++++++++++++++++++++ sql/sql_prepare.cc | 12 ++++++++++++ 3 files changed, 75 insertions(+) diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result index 6857ebc68af..5ddc52579bc 100644 --- a/mysql-test/r/ps.result +++ b/mysql-test/r/ps.result @@ -5074,3 +5074,32 @@ t1 CREATE TABLE `t1` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 DROP TABLE t1; DROP PROCEDURE p1; +# +# MDEV-14426 Assertion in Diagnostics_area::set_error_status when using a bad datetime with PS and SP +# +CREATE PROCEDURE p1(OUT a VARCHAR(20)) +BEGIN +SET a=10; +END; +$$ +BEGIN NOT ATOMIC +DECLARE a DATETIME; +CALL p1(a); +END; +$$ +ERROR 22007: Incorrect datetime value: '10' for column 'a' at row 1 +BEGIN NOT ATOMIC +DECLARE a DATETIME; +EXECUTE IMMEDIATE 'CALL p1(?)' USING a; +END; +$$ +ERROR 22007: Incorrect datetime value: '10' for column 'a' at row 1 +BEGIN NOT ATOMIC +DECLARE a DATETIME; +PREPARE stmt FROM 'CALL p1(?)'; +EXECUTE stmt USING a; +DEALLOCATE PREPARE stmt; +END; +$$ +ERROR 22007: Incorrect datetime value: '10' for column 'a' at row 1 +DROP PROCEDURE p1; diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test index a7683b5aae6..f147f4b7e1e 100644 --- a/mysql-test/t/ps.test +++ b/mysql-test/t/ps.test @@ -4529,3 +4529,37 @@ CREATE TABLE t1 AS SELECT @a AS a, @b AS b; SHOW CREATE TABLE t1; DROP TABLE t1; DROP PROCEDURE p1; + + +--echo # +--echo # MDEV-14426 Assertion in Diagnostics_area::set_error_status when using a bad datetime with PS and SP +--echo # + +DELIMITER $$; +CREATE PROCEDURE p1(OUT a VARCHAR(20)) +BEGIN + SET a=10; +END; +$$ +--error ER_TRUNCATED_WRONG_VALUE +BEGIN NOT ATOMIC + DECLARE a DATETIME; + CALL p1(a); +END; +$$ +--error ER_TRUNCATED_WRONG_VALUE +BEGIN NOT ATOMIC + DECLARE a DATETIME; + EXECUTE IMMEDIATE 'CALL p1(?)' USING a; +END; +$$ +--error ER_TRUNCATED_WRONG_VALUE +BEGIN NOT ATOMIC + DECLARE a DATETIME; + PREPARE stmt FROM 'CALL p1(?)'; + EXECUTE stmt USING a; + DEALLOCATE PREPARE stmt; +END; +$$ +DELIMITER ;$$ +DROP PROCEDURE p1; diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 19c714cfc01..ae6f0e8f63d 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -4786,7 +4786,19 @@ bool Prepared_statement::execute(String *expanded_query, bool open_cursor) if (error == 0 && this->lex->sql_command == SQLCOM_CALL) { if (is_sql_prepare()) + { + /* + Here we have the diagnostics area status already set to DA_OK. + sent_out_parameters() can raise errors when assigning OUT parameters: + DECLARE a DATETIME; + EXECUTE IMMEDIATE 'CALL p1(?)' USING a; + when the procedure p1 assigns a DATETIME-incompatible value (e.g. 10) + to the out parameter. Allow to overwrite status (to DA_ERROR). + */ + thd->get_stmt_da()->set_overwrite_status(true); thd->protocol_text.send_out_parameters(&this->lex->param_list); + thd->get_stmt_da()->set_overwrite_status(false); + } else thd->protocol->send_out_parameters(&this->lex->param_list); } From 4b8cd4536a2c6376284288cd4617369a5e48236a Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Fri, 22 Dec 2017 14:03:25 +0400 Subject: [PATCH 41/69] MDEV-13626 Merge InnoDB test cases from MySQL 5.7 Coverage for temporary tables modifications in read-only transactions. Introduced in 5.7 by 325cdf426 --- mysql-test/suite/innodb/r/innodb.result | 80 +++++++++++++++++++++++++ mysql-test/suite/innodb/t/innodb.test | 70 ++++++++++++++++++++++ 2 files changed, 150 insertions(+) diff --git a/mysql-test/suite/innodb/r/innodb.result b/mysql-test/suite/innodb/r/innodb.result index cded1f98fb3..159043a7170 100644 --- a/mysql-test/suite/innodb/r/innodb.result +++ b/mysql-test/suite/innodb/r/innodb.result @@ -3143,3 +3143,83 @@ show status like "handler_read_key"; Variable_name Value Handler_read_key 0 drop table t1; +CREATE TABLE t1 (c1 INT) ENGINE=InnoDB; +CREATE TEMPORARY TABLE t2 (c1 INT) ENGINE=InnoDB; +START TRANSACTION READ ONLY; +INSERT INTO t2 VALUES(0); +INSERT INTO t1 VALUES(0); +ERROR 25006: Cannot execute statement in a READ ONLY transaction. +ROLLBACK; +SELECT * FROM t1; +c1 +SELECT * FROM t2; +c1 +START TRANSACTION READ ONLY; +INSERT INTO t1 VALUES(0); +ERROR 25006: Cannot execute statement in a READ ONLY transaction. +INSERT INTO t2 VALUES(1); +COMMIT; +SET TRANSACTION READ ONLY; +START TRANSACTION; +INSERT INTO t2 VALUES(3); +INSERT INTO t1 VALUES(0); +ERROR 25006: Cannot execute statement in a READ ONLY transaction. +COMMIT; +SELECT * FROM t1; +c1 +SELECT * FROM t2; +c1 +1 +3 +DROP TABLE t2; +CREATE TEMPORARY TABLE t2 ( +c1 INT AUTO_INCREMENT PRIMARY KEY, +c2 INT, INDEX idx(c2)) ENGINE=InnoDB; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TEMPORARY TABLE `t2` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + `c2` int(11) DEFAULT NULL, + PRIMARY KEY (`c1`), + KEY `idx` (`c2`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +START TRANSACTION READ ONLY; +INSERT INTO t2 VALUES(NULL,1),(NULL,2),(NULL,3); +INSERT INTO t1 VALUES(0); +ERROR 25006: Cannot execute statement in a READ ONLY transaction. +ROLLBACK; +SELECT * FROM t1; +c1 +SELECT * FROM t2; +c1 c2 +START TRANSACTION READ ONLY; +INSERT INTO t1 VALUES(0); +ERROR 25006: Cannot execute statement in a READ ONLY transaction. +INSERT INTO t2 VALUES(NULL,1),(NULL,2),(NULL,3); +COMMIT; +SET TRANSACTION READ ONLY; +START TRANSACTION; +INSERT INTO t2 VALUES(NULL,1),(NULL,2),(NULL,3); +INSERT INTO t1 VALUES(0); +ERROR 25006: Cannot execute statement in a READ ONLY transaction. +COMMIT; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TEMPORARY TABLE `t2` ( + `c1` int(11) NOT NULL AUTO_INCREMENT, + `c2` int(11) DEFAULT NULL, + PRIMARY KEY (`c1`), + KEY `idx` (`c2`) +) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=latin1 +SELECT * FROM t1; +c1 +SELECT * FROM t2; +c1 c2 +4 1 +7 1 +5 2 +8 2 +6 3 +9 3 +DROP TABLE t1; +DROP TABLE t2; diff --git a/mysql-test/suite/innodb/t/innodb.test b/mysql-test/suite/innodb/t/innodb.test index b519c48b23d..c3b6ed7d0a7 100644 --- a/mysql-test/suite/innodb/t/innodb.test +++ b/mysql-test/suite/innodb/t/innodb.test @@ -2528,6 +2528,76 @@ select f1 from t1; show status like "handler_read_key"; drop table t1; +# +# Test handling of writes to TEMPORARY tables for read-only transactions +# +CREATE TABLE t1 (c1 INT) ENGINE=InnoDB; +CREATE TEMPORARY TABLE t2 (c1 INT) ENGINE=InnoDB; + +# Check that the rollback works +START TRANSACTION READ ONLY; +INSERT INTO t2 VALUES(0); +--error ER_CANT_EXECUTE_IN_READ_ONLY_TRANSACTION +INSERT INTO t1 VALUES(0); +ROLLBACK; + +SELECT * FROM t1; +SELECT * FROM t2; + +START TRANSACTION READ ONLY; +--error ER_CANT_EXECUTE_IN_READ_ONLY_TRANSACTION +INSERT INTO t1 VALUES(0); +INSERT INTO t2 VALUES(1); +COMMIT; + +SET TRANSACTION READ ONLY; +START TRANSACTION; +INSERT INTO t2 VALUES(3); +--error ER_CANT_EXECUTE_IN_READ_ONLY_TRANSACTION +INSERT INTO t1 VALUES(0); +COMMIT; + +SELECT * FROM t1; +SELECT * FROM t2; + +DROP TABLE t2; + +# This time with some indexes +CREATE TEMPORARY TABLE t2 ( + c1 INT AUTO_INCREMENT PRIMARY KEY, + c2 INT, INDEX idx(c2)) ENGINE=InnoDB; + +SHOW CREATE TABLE t2; + +# Check that the rollback works +START TRANSACTION READ ONLY; +INSERT INTO t2 VALUES(NULL,1),(NULL,2),(NULL,3); +--error ER_CANT_EXECUTE_IN_READ_ONLY_TRANSACTION +INSERT INTO t1 VALUES(0); +ROLLBACK; + +SELECT * FROM t1; +SELECT * FROM t2; + +START TRANSACTION READ ONLY; +--error ER_CANT_EXECUTE_IN_READ_ONLY_TRANSACTION +INSERT INTO t1 VALUES(0); +INSERT INTO t2 VALUES(NULL,1),(NULL,2),(NULL,3); +COMMIT; + +SET TRANSACTION READ ONLY; +START TRANSACTION; +INSERT INTO t2 VALUES(NULL,1),(NULL,2),(NULL,3); +--error ER_CANT_EXECUTE_IN_READ_ONLY_TRANSACTION +INSERT INTO t1 VALUES(0); +COMMIT; + +SHOW CREATE TABLE t2; +SELECT * FROM t1; +SELECT * FROM t2; + +DROP TABLE t1; +DROP TABLE t2; ####################################################################### # # # Please, DO NOT TOUCH this file as well as the innodb.result file. # From 8c3a1b15e67869f987349b393b368a503ff6e600 Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Fri, 22 Dec 2017 13:22:59 +0300 Subject: [PATCH 42/69] Fix a typo in previous commit --- storage/rocksdb/mysql-test/rocksdb_rpl/t/disabled.def | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/rocksdb/mysql-test/rocksdb_rpl/t/disabled.def b/storage/rocksdb/mysql-test/rocksdb_rpl/t/disabled.def index 4f739a558e8..956355dceee 100644 --- a/storage/rocksdb/mysql-test/rocksdb_rpl/t/disabled.def +++ b/storage/rocksdb/mysql-test/rocksdb_rpl/t/disabled.def @@ -8,7 +8,7 @@ consistent_snapshot_mixed_engines : Tests START TRANSACTION WITH CONSISTENT $ENG rpl_skip_trx_api_binlog_format : requires @@rpl_skip_tx_api rpl_ddl_high_priority : DDL commands with HIGH_PRIORITY syntax are not in MariaDB rpl_gtid_rocksdb_sys_header : MariaDB doesn't support printing "RocksDB: Last MySQL Gtid UUID" into server stderr on startup -slave_use_idempotent_for_recovery: MariaDB doesn't support --slave-use-idempotent-for-recovery +singledelete_idempotent_recovery: MariaDB doesn't support --slave-use-idempotent-for-recovery ## ## Tests that do not fit MariaDB's test environment (Functional tests only, From db3bdca7c2982aeb6848eb3517a669686381c760 Mon Sep 17 00:00:00 2001 From: Daniel Bartholomew Date: Fri, 22 Dec 2017 16:45:20 -0500 Subject: [PATCH 43/69] bump the VERSION --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 466fdaeb91d..244d28b6ba5 100644 --- a/VERSION +++ b/VERSION @@ -1,3 +1,3 @@ MYSQL_VERSION_MAJOR=10 MYSQL_VERSION_MINOR=1 -MYSQL_VERSION_PATCH=30 +MYSQL_VERSION_PATCH=31 From 6e7ca6b0b29a732390f2d50902ef7f6db66989ce Mon Sep 17 00:00:00 2001 From: Monty Date: Sat, 23 Dec 2017 14:53:12 +0200 Subject: [PATCH 44/69] MDEV-13719 Assertion `bit < (map)->n_bits' failed in bitmap_is_set Problem was that MAX_SLAVE_ERROR didn't cover all possible errors. --- sql/slave.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/slave.h b/sql/slave.h index ded9d76e49d..d3cbaae03df 100644 --- a/sql/slave.h +++ b/sql/slave.h @@ -51,7 +51,7 @@ #define SLAVE_NET_TIMEOUT 60 -#define MAX_SLAVE_ERROR 2000 +#define MAX_SLAVE_ERROR ER_ERROR_LAST+1 #define MAX_REPLICATION_THREAD 64 From f0f3b6549a5924a194e8ce56a0c47443acbb506e Mon Sep 17 00:00:00 2001 From: Alexey Botchkov Date: Mon, 25 Dec 2017 08:10:48 +0400 Subject: [PATCH 45/69] MDEV-13970 crash in Item_func_json_extract::read_json. Item_func_json_extract::val_int fixed. It wasn't tested yet as it's called in exotic cases only. --- mysql-test/r/func_json.result | 5 +++++ mysql-test/t/func_json.test | 9 +++++++++ sql/item_jsonfunc.cc | 6 +++--- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/func_json.result b/mysql-test/r/func_json.result index 55e64ea38e3..b60f6e970e1 100644 --- a/mysql-test/r/func_json.result +++ b/mysql-test/r/func_json.result @@ -731,3 +731,8 @@ Warning 4042 Syntax error in JSON path in argument 3 to function 'json_contains_ select JSON_VALID(0x36f0c8dccd83c5eac156da); JSON_VALID(0x36f0c8dccd83c5eac156da) 0 +create table t1(a double not null); +insert into t1 values (2),(1); +select 1 from t1 where json_extract(a,'$','$[81]'); +1 +drop table t1; diff --git a/mysql-test/t/func_json.test b/mysql-test/t/func_json.test index c6c7c8d3976..0b3cb938098 100644 --- a/mysql-test/t/func_json.test +++ b/mysql-test/t/func_json.test @@ -383,3 +383,12 @@ select json_contains_path('{"foo":"bar"}', 'one', '$[]'); # MDEV-13971 crash in skip_num_constant. # select JSON_VALID(0x36f0c8dccd83c5eac156da); + +# +# MDEV-13970 crash in Item_func_json_extract::read_json. +# +create table t1(a double not null); +insert into t1 values (2),(1); +select 1 from t1 where json_extract(a,'$','$[81]'); +drop table t1; + diff --git a/sql/item_jsonfunc.cc b/sql/item_jsonfunc.cc index ff062b81a2e..794831ae1a5 100644 --- a/sql/item_jsonfunc.cc +++ b/sql/item_jsonfunc.cc @@ -781,10 +781,10 @@ String *Item_func_json_extract::read_json(String *str, { str->set_charset(js->charset()); str->length(0); - } - if (possible_multiple_values && str->append("[", 1)) - goto error; + if (possible_multiple_values && str->append("[", 1)) + goto error; + } json_get_path_start(&je, js->charset(),(const uchar *) js->ptr(), (const uchar *) js->ptr() + js->length(), &p); From 2fe6186124abeda19f2ae01cd41dd1907ba611b8 Mon Sep 17 00:00:00 2001 From: Sachin Setiya Date: Mon, 25 Dec 2017 05:09:49 +0530 Subject: [PATCH 46/69] MDEV-10715 Galera: Replicate MariaDB GTID to other nodes in the cluster Problem:- Gtid are not transferred in Galera Cluster. Solution:- We need to transfer gtid in the case on either when cluster is slave/master in async replication. In normal Gtid replication gtid are generated on recieving node itself and it is always on sync with other nodes. Because galera keeps node in sync , So all nodes get same no of event groups. So the issue arises when say galera is slave in async replication. A | (Async replication) D <-> E <-> F {Galera replication} So what should happen is that all node should apply the master gtid but this does node happen, becuase node E, F does not recieve gtid from D in write set , So what E(or F) does is that it applies wsrep_gtid_domain_id, D server-id , E gtid next seq no. This generated gtid does not always work when say A has different domain id. So In this commit, on galera node when we see that this event is recieved from master we simply write Gtid_Log_Event in write_set and send it to other nodes. --- .../suite/galera/r/galera_gtid_slave.result | 26 ++ .../r/galera_gtid_slave_sst_rsync.result | 130 ++++++++ .../suite/galera/t/galera_gtid_slave.cnf | 18 ++ .../suite/galera/t/galera_gtid_slave.test | 78 +++++ .../galera/t/galera_gtid_slave_sst_rsync.cnf | 18 ++ .../galera/t/galera_gtid_slave_sst_rsync.test | 207 +++++++++++++ .../suite/galera_3nodes/galera_2x3nodes.cnf | 122 ++++++++ .../r/galera_gtid_2_cluster.result | 231 ++++++++++++++ .../galera_3nodes/t/galera_gtid_2_cluster.cnf | 28 ++ .../t/galera_gtid_2_cluster.test | 292 ++++++++++++++++++ sql/log.cc | 88 +++++- sql/log.h | 8 +- sql/wsrep_mysqld.cc | 10 + 13 files changed, 1253 insertions(+), 3 deletions(-) create mode 100644 mysql-test/suite/galera/r/galera_gtid_slave.result create mode 100644 mysql-test/suite/galera/r/galera_gtid_slave_sst_rsync.result create mode 100644 mysql-test/suite/galera/t/galera_gtid_slave.cnf create mode 100644 mysql-test/suite/galera/t/galera_gtid_slave.test create mode 100644 mysql-test/suite/galera/t/galera_gtid_slave_sst_rsync.cnf create mode 100644 mysql-test/suite/galera/t/galera_gtid_slave_sst_rsync.test create mode 100644 mysql-test/suite/galera_3nodes/galera_2x3nodes.cnf create mode 100644 mysql-test/suite/galera_3nodes/r/galera_gtid_2_cluster.result create mode 100644 mysql-test/suite/galera_3nodes/t/galera_gtid_2_cluster.cnf create mode 100644 mysql-test/suite/galera_3nodes/t/galera_gtid_2_cluster.test diff --git a/mysql-test/suite/galera/r/galera_gtid_slave.result b/mysql-test/suite/galera/r/galera_gtid_slave.result new file mode 100644 index 00000000000..40f3f1c0d53 --- /dev/null +++ b/mysql-test/suite/galera/r/galera_gtid_slave.result @@ -0,0 +1,26 @@ +START SLAVE; +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; +CREATE TABLE t2 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES(1); +begin; +insert into t2 values(21); +insert into t2 values(22); +commit; +SELECT @@global.gtid_binlog_state; +@@global.gtid_binlog_state +1-1-4 +INSERT INTO t1 VALUES(2); +INSERT INTO t1 VALUES(3); +SELECT @@global.gtid_binlog_state; +@@global.gtid_binlog_state +1-1-4,2-2-2 +INSERT INTO t1 VALUES(4); +SELECT @@global.gtid_binlog_state; +@@global.gtid_binlog_state +1-1-4,2-2-2,2-3-3 +DROP TABLE t1,t2; +reset master; +STOP SLAVE; +RESET SLAVE ALL; +reset master; +reset master; diff --git a/mysql-test/suite/galera/r/galera_gtid_slave_sst_rsync.result b/mysql-test/suite/galera/r/galera_gtid_slave_sst_rsync.result new file mode 100644 index 00000000000..81fae57d731 --- /dev/null +++ b/mysql-test/suite/galera/r/galera_gtid_slave_sst_rsync.result @@ -0,0 +1,130 @@ +#Connection 2 +START SLAVE; +#Connection 1 +CREATE TABLE t2 (f1 INTEGER PRIMARY KEY, f2 int unique) ENGINE=InnoDB; +INSERT INTO t2 VALUES(1,11); +INSERT INTO t2 VALUES(2,22); +INSERT INTO t2 VALUES(3,33); +SELECT @@global.gtid_binlog_state; +@@global.gtid_binlog_state +1-1-4 +include/save_master_gtid.inc +#Connection 2 +include/sync_with_master_gtid.inc +SELECT @@global.gtid_binlog_state; +@@global.gtid_binlog_state +1-1-4 +INSERT INTO t2 VALUES(4,44); +INSERT INTO t2 VALUES(5,55); +INSERT INTO t2 VALUES(6,66); +SELECT @@global.gtid_binlog_state; +@@global.gtid_binlog_state +1-1-4,2-2-3 +#Connection 3 +INSERT INTO t2 VALUES(7,77); +INSERT INTO t2 VALUES(8,88); +SELECT @@global.gtid_binlog_state; +@@global.gtid_binlog_state +1-1-4,2-2-3,2-3-5 +#Connection 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'); +COMMIT; +include/save_master_gtid.inc +#Connection 2 +include/sync_with_master_gtid.inc +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node2_committed_before'); +INSERT INTO t1 VALUES ('node2_committed_before'); +COMMIT; +#Connection 3 +Shutting down server ... +#Connection 2 +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node1_committed_during'); +INSERT INTO t1 VALUES ('node1_committed_during'); +COMMIT; +#Connection 3 +Starting server ... +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node3_committed_after'); +INSERT INTO t1 VALUES ('node3_committed_after'); +COMMIT; +#Connection 2 +Select * from t1 order by f1; +f1 +node1_committed_before +node1_committed_before +node1_committed_during +node1_committed_during +node2_committed_before +node2_committed_before +node3_committed_after +node3_committed_after +#Connection 3 +Select * from t1 order by f1; +f1 +node1_committed_before +node1_committed_before +node1_committed_during +node1_committed_during +node2_committed_before +node2_committed_before +node3_committed_after +node3_committed_after +#Connection 2 +SELECT @@global.gtid_binlog_state; +@@global.gtid_binlog_state +1-1-6,2-2-7,2-3-8 +#Connection 3 +SELECT @@global.gtid_binlog_state; +@@global.gtid_binlog_state +1-1-6,2-2-7,2-3-8 +#Connection 1 +SET AUTOCOMMIT=ON; +#Connection 2 +SET AUTOCOMMIT=ON; +#Connection 3 +SET AUTOCOMMIT=ON; +#Connection 2 +STOP slave; +INSERT INTO t1 VALUES ('node2_slave_stoped'); +#Connection 1 +INSERT INTO t1 VALUES ('node1_normal_entry'); +include/save_master_gtid.inc +#Connection 2 +INSERT INTO t1 VALUES ('node2_slave_stoped_inserted'); +start slave; +include/sync_with_master_gtid.inc +INSERT INTO t1 VALUES ('node2_slave_started'); +SELECT count(*) from t1; +count(*) +12 +SELECT @@global.gtid_binlog_state; +@@global.gtid_binlog_state +1-1-7,2-3-8,2-2-11 +#Connection 3 +SELECT count(*) from t1; +count(*) +12 +SELECT @@global.gtid_binlog_state; +@@global.gtid_binlog_state +1-1-7,2-3-8,2-2-11 +#Connection 1 +DROP TABLE t2,t1; +#Connection 2 +#Connection 3 +#Connection 2 +STOP SLAVE; +RESET SLAVE ALL; +reset master; +#Connection 3 +reset master; +#Connection 1 +reset master; diff --git a/mysql-test/suite/galera/t/galera_gtid_slave.cnf b/mysql-test/suite/galera/t/galera_gtid_slave.cnf new file mode 100644 index 00000000000..409d0d1609a --- /dev/null +++ b/mysql-test/suite/galera/t/galera_gtid_slave.cnf @@ -0,0 +1,18 @@ +!include ../galera_2nodes_as_slave.cnf + +[mysqld] +log-bin=mysqld-bin +log-slave-updates +binlog-format=ROW + +[mysqld.1] +gtid-domain-id=1 +[mysqld.2] +gtid-domain-id=2 +wsrep_gtid_mode=1 +wsrep_gtid_domain_id=2 +[mysqld.3] +gtid-domain-id=2 +wsrep_gtid_mode=1 +wsrep_gtid_domain_id=2 + diff --git a/mysql-test/suite/galera/t/galera_gtid_slave.test b/mysql-test/suite/galera/t/galera_gtid_slave.test new file mode 100644 index 00000000000..8ef87452a5b --- /dev/null +++ b/mysql-test/suite/galera/t/galera_gtid_slave.test @@ -0,0 +1,78 @@ +# +# Test Galera as a slave to a MariaDB master using GTIDs +# +# suite/galera/galera_2nodes_as_slave.cnf describes the setup of the nodes +# suite/galera/t/galera_as_slave_gtid.cnf has the GTID options +# +# In addition to performing DDL and DML, we check that the gtid of the master is preserved inside the cluster +# + +--source include/have_innodb.inc + +# As node #1 is not a Galera node, we connect to node #2 in order to run include/galera_cluster.inc +--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2 +--source include/galera_cluster.inc + +--connection node_2 +--disable_query_log +--eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_USER='root', MASTER_PORT=$NODE_MYPORT_1; +--enable_query_log +START SLAVE; + +--connection node_1 +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; +CREATE TABLE t2 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES(1); + +#multi stmt trans +begin; +insert into t2 values(21); +insert into t2 values(22); +commit; + +SELECT @@global.gtid_binlog_state; + +--connection node_2 +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; +--source include/wait_condition.inc + +--let $wait_condition = SELECT COUNT(*) = 1 FROM t1; +--source include/wait_condition.inc +--sleep 1 +INSERT INTO t1 VALUES(2); +INSERT INTO t1 VALUES(3); +SELECT @@global.gtid_binlog_state; + +--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3 +--let $wait_condition = SELECT COUNT(*) = 3 FROM t1; +--source include/wait_condition.inc + +INSERT INTO t1 VALUES(4); +SELECT @@global.gtid_binlog_state; + +--connection node_1 +DROP TABLE t1,t2; +reset master; +# +# Unfortunately without the sleep below the following statement fails with "query returned no rows", which +# is difficult to understand given that it is an aggregate query. A "query execution was interrupted" +# warning is also reported by MTR, which is also weird. +# + +--sleep 1 + +--connection node_2 +--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; +--source include/wait_condition.inc + +--connection node_3 +--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; +--source include/wait_condition.inc + +--connection node_2 +STOP SLAVE; +RESET SLAVE ALL; +reset master; + +--connection node_3 +reset master; diff --git a/mysql-test/suite/galera/t/galera_gtid_slave_sst_rsync.cnf b/mysql-test/suite/galera/t/galera_gtid_slave_sst_rsync.cnf new file mode 100644 index 00000000000..bb9c8e84f1b --- /dev/null +++ b/mysql-test/suite/galera/t/galera_gtid_slave_sst_rsync.cnf @@ -0,0 +1,18 @@ +!include ../galera_2nodes_as_slave.cnf + +[mysqld] +log-bin=mysqld-bin +log-slave-updates +binlog-format=ROW +wsrep_sst_method=rsync +[mysqld.1] +gtid-domain-id=1 +[mysqld.2] +gtid-domain-id=2 +wsrep_gtid_mode=1 +wsrep_gtid_domain_id=2 +[mysqld.3] +gtid-domain-id=2 +wsrep_gtid_mode=1 +wsrep_gtid_domain_id=2 + diff --git a/mysql-test/suite/galera/t/galera_gtid_slave_sst_rsync.test b/mysql-test/suite/galera/t/galera_gtid_slave_sst_rsync.test new file mode 100644 index 00000000000..3fe94ad16b7 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_gtid_slave_sst_rsync.test @@ -0,0 +1,207 @@ +# +# Test Galera as a slave to a MariaDB master using GTIDs +# +# suite/galera/galera_2nodes_as_slave.cnf describes the setup of the nodes +# +# In addition to performing DDL and DML, we check that the gtid of the master is preserved inside the cluster +# + +--source include/big_test.inc +--source include/have_innodb.inc +# As node #1 is not a Galera node, we connect to node #2 in order to run include/galera_cluster.inc +--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2 +--source include/galera_cluster.inc + +--echo #Connection 2 +--connection node_2 +--disable_query_log +--eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_USER='root', MASTER_PORT=$NODE_MYPORT_1,master_use_gtid=slave_pos; +--enable_query_log +START SLAVE; +--sleep 1 + + +--echo #Connection 1 +--connection node_1 +CREATE TABLE t2 (f1 INTEGER PRIMARY KEY, f2 int unique) ENGINE=InnoDB; +INSERT INTO t2 VALUES(1,11); +INSERT INTO t2 VALUES(2,22); +INSERT INTO t2 VALUES(3,33); + +SELECT @@global.gtid_binlog_state; +--source include/save_master_gtid.inc + +--echo #Connection 2 +--connection node_2 +--source include/sync_with_master_gtid.inc +SELECT @@global.gtid_binlog_state; + +INSERT INTO t2 VALUES(4,44); +INSERT INTO t2 VALUES(5,55); +INSERT INTO t2 VALUES(6,66); +SELECT @@global.gtid_binlog_state; + +--echo #Connection 3 +--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3 +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME= 't2'; +--source include/wait_condition.inc +--let $wait_condition = SELECT COUNT(*) = 6 FROM t2; +--source include/wait_condition.inc + +INSERT INTO t2 VALUES(7,77); +INSERT INTO t2 VALUES(8,88); +SELECT @@global.gtid_binlog_state; + +#Perform SST +--echo #Connection 1 +--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'); +COMMIT; +--source include/save_master_gtid.inc + +--echo #Connection 2 +--connection node_2 +--source include/sync_with_master_gtid.inc +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node2_committed_before'); +INSERT INTO t1 VALUES ('node2_committed_before'); +COMMIT; + +--echo #Connection 3 +--connection node_3 +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME= 't1'; +--source include/wait_condition.inc +--let $wait_condition = SELECT COUNT(*) = 4 FROM t1; +--source include/wait_condition.inc +--let $node_1= node_2 +--let $node_2= node_3 +--source include/auto_increment_offset_save.inc +--echo Shutting down server ... +--source include/shutdown_mysqld.inc + + +--echo #Connection 2 +--connection node_2 +--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' +--source include/wait_condition.inc +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node1_committed_during'); +INSERT INTO t1 VALUES ('node1_committed_during'); +COMMIT; + +--echo #Connection 3 +--connection node_3 +--echo Starting server ... +--source include/start_mysqld.inc +--source include/wait_until_ready.inc +--source include/auto_increment_offset_restore.inc + +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node3_committed_after'); +INSERT INTO t1 VALUES ('node3_committed_after'); +COMMIT; + +--echo #Connection 2 +--connection node_2 +--let $wait_condition = SELECT COUNT(*) = 8 FROM t1; +--source include/wait_condition.inc +Select * from t1 order by f1; + +--echo #Connection 3 +--connection node_3 +Select * from t1 order by f1; + +#SST Done +--sleep 1 +--echo #Connection 2 +--connection node_2 +SELECT @@global.gtid_binlog_state; + +--echo #Connection 3 +--connection node_3 +SELECT @@global.gtid_binlog_state; + +--echo #Connection 1 +--connection node_1 +SET AUTOCOMMIT=ON; +#drop table t1; +#CREATE TABLE t1 (f1 CHAR(255)) ENGINE=InnoDB; + +--echo #Connection 2 +--connection node_2 +SET AUTOCOMMIT=ON; +--echo #Connection 3 +--connection node_3 +SET AUTOCOMMIT=ON; + +# +#stop slave on node 2 +--echo #Connection 2 +--connection node_2 +STOP slave; +--sleep 1 +INSERT INTO t1 VALUES ('node2_slave_stoped'); + +--echo #Connection 1 +--connection node_1 +INSERT INTO t1 VALUES ('node1_normal_entry'); +--source include/save_master_gtid.inc + +#start slave +--echo #Connection 2 +--connection node_2 +INSERT INTO t1 VALUES ('node2_slave_stoped_inserted'); +start slave; +--source include/sync_with_master_gtid.inc +INSERT INTO t1 VALUES ('node2_slave_started'); +SELECT count(*) from t1; +SELECT @@global.gtid_binlog_state; + +--echo #Connection 3 +--connection node_3 +--let $wait_condition = SELECT COUNT(*) = 12 FROM t1; +--source include/wait_condition.inc +SELECT count(*) from t1; +SELECT @@global.gtid_binlog_state; + +--echo #Connection 1 +--connection node_1 +DROP TABLE t2,t1; + +# Unfortunately without the sleep below the following statement fails with "query returned no rows", which +# is difficult to understand given that it is an aggregate query. A "query execution was interrupted" +# warning is also reported by MTR, which is also weird. +# + +--sleep 3 + +--echo #Connection 2 +--connection node_2 +--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't2'; +--source include/wait_condition.inc + +--echo #Connection 3 +--connection node_3 +--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; +--source include/wait_condition.inc + +--echo #Connection 2 +--connection node_2 +STOP SLAVE; +RESET SLAVE ALL; +reset master; + +--echo #Connection 3 +--connection node_3 +reset master; + +--echo #Connection 1 +--connection node_1 +reset master; diff --git a/mysql-test/suite/galera_3nodes/galera_2x3nodes.cnf b/mysql-test/suite/galera_3nodes/galera_2x3nodes.cnf new file mode 100644 index 00000000000..3f39b82f7b7 --- /dev/null +++ b/mysql-test/suite/galera_3nodes/galera_2x3nodes.cnf @@ -0,0 +1,122 @@ +# Use default setting for mysqld processes +!include include/default_mysqld.cnf + +[mysqld] +log-bin +log-slave-updates +binlog-format=row +innodb-autoinc-lock-mode=2 +default-storage-engine=innodb +wsrep_gtid_mode=1 +gtid_ignore_duplicates + +wsrep-on=1 +wsrep-provider=@ENV.WSREP_PROVIDER +wsrep_node_address=127.0.0.1 +# enforce read-committed characteristics across the cluster +# wsrep-causal-reads=ON +# wsrep-sync-wait=15 + +[mysqld.1] +#galera_port=@OPT.port +#ist_port=@OPT.port +#sst_port=@OPT.port +wsrep-cluster-address='gcomm://' +wsrep_provider_options='base_port=@mysqld.1.#galera_port;evs.suspect_timeout=PT300S;evs.inactive_timeout=PT1000M;evs.install_timeout=PT155S;evs.keepalive_period = PT100S' + +wsrep_sst_receive_address=127.0.0.2:@mysqld.1.#sst_port +wsrep_node_incoming_address=127.0.0.1:@mysqld.1.port +wsrep_sst_receive_address='127.0.0.1:@mysqld.1.#sst_port' + +[mysqld.2] +#galera_port=@OPT.port +#ist_port=@OPT.port +#sst_port=@OPT.port +wsrep_cluster_address='gcomm://127.0.0.1:@mysqld.1.#galera_port' +wsrep_provider_options='base_port=@mysqld.2.#galera_port;evs.suspect_timeout=PT300S;evs.inactive_timeout=PT1000M;evs.install_timeout=PT155S;evs.keepalive_period = PT100S' + +wsrep_sst_receive_address=127.0.0.2:@mysqld.2.#sst_port +wsrep_node_incoming_address=127.0.0.1:@mysqld.2.port +wsrep_sst_receive_address='127.0.0.1:@mysqld.2.#sst_port' + +[mysqld.3] +#galera_port=@OPT.port +#ist_port=@OPT.port +#sst_port=@OPT.port +wsrep_cluster_address='gcomm://127.0.0.1:@mysqld.1.#galera_port' +wsrep_provider_options='base_port=@mysqld.3.#galera_port;evs.suspect_timeout=PT300S;evs.inactive_timeout=PT1000M;evs.install_timeout=PT155S;evs.keepalive_period = PT100S' + +wsrep_sst_receive_address=127.0.0.2:@mysqld.3.#sst_port +wsrep_node_incoming_address=127.0.0.1:@mysqld.3.port +wsrep_sst_receive_address='127.0.0.1:@mysqld.3.#sst_port' + + +[mysqld.4] +wsrep_cluster_name=cluster2 +#galera_port=@OPT.port +#ist_port=@OPT.port +#sst_port=@OPT.port + +wsrep-cluster-address='gcomm://' +wsrep_provider_options='base_port=@mysqld.4.#galera_port;evs.suspect_timeout=PT300S;evs.inactive_timeout=PT1000M;evs.install_timeout=PT155S;evs.keepalive_period = PT100S' + +wsrep_sst_receive_address=127.0.0.2:@mysqld.4.#sst_port +wsrep_node_incoming_address=127.0.0.1:@mysqld.4.port +wsrep_sst_receive_address='127.0.0.1:@mysqld.4.#sst_port' + +[mysqld.5] +wsrep_cluster_name=cluster2 +#galera_port=@OPT.port +#ist_port=@OPT.port +#sst_port=@OPT.port +wsrep_cluster_address='gcomm://127.0.0.1:@mysqld.4.#galera_port' +wsrep_provider_options='base_port=@mysqld.5.#galera_port;evs.suspect_timeout=PT300S;evs.inactive_timeout=PT1000M;evs.install_timeout=PT155S;evs.keepalive_period = PT100S' + +wsrep_sst_receive_address=127.0.0.2:@mysqld.5.#sst_port +wsrep_node_incoming_address=127.0.0.1:@mysqld.5.port +wsrep_sst_receive_address='127.0.0.1:@mysqld.5.#sst_port' + +[mysqld.6] +wsrep_cluster_name=cluster2 +#galera_port=@OPT.port +#ist_port=@OPT.port +#sst_port=@OPT.port +wsrep_cluster_address='gcomm://127.0.0.1:@mysqld.4.#galera_port' +wsrep_provider_options='base_port=@mysqld.6.#galera_port;evs.suspect_timeout=PT300S;evs.inactive_timeout=PT1000M;evs.install_timeout=PT155S;evs.keepalive_period = PT100S' + +wsrep_sst_receive_address=127.0.0.2:@mysqld.6.#sst_port +wsrep_node_incoming_address=127.0.0.1:@mysqld.6.port +wsrep_sst_receive_address='127.0.0.1:@mysqld.6.#sst_port' + +[ENV] +NODE_MYPORT_1= @mysqld.1.port +NODE_MYSOCK_1= @mysqld.1.socket + +NODE_MYPORT_2= @mysqld.2.port +NODE_MYSOCK_2= @mysqld.2.socket + +NODE_MYPORT_3= @mysqld.3.port +NODE_MYSOCK_3= @mysqld.3.socket + +NODE_MYPORT_4= @mysqld.4.port +NODE_MYSOCK_4= @mysqld.4.socket + +NODE_MYPORT_5= @mysqld.5.port +NODE_MYSOCK_5= @mysqld.5.socket + +NODE_MYPORT_6= @mysqld.6.port +NODE_MYSOCK_6= @mysqld.6.socket + +NODE_GALERAPORT_1= @mysqld.1.#galera_port +NODE_GALERAPORT_2= @mysqld.2.#galera_port +NODE_GALERAPORT_3= @mysqld.3.#galera_port +NODE_GALERAPORT_4= @mysqld.4.#galera_port +NODE_GALERAPORT_5= @mysqld.5.#galera_port +NODE_GALERAPORT_6= @mysqld.6.#galera_port + +NODE_SSTPORT_1= @mysqld.1.#sst_port +NODE_SSTPORT_2= @mysqld.2.#sst_port +NODE_SSTPORT_3= @mysqld.3.#sst_port +NODE_SSTPORT_4= @mysqld.4.#sst_port +NODE_SSTPORT_5= @mysqld.5.#sst_port +NODE_SSTPORT_6= @mysqld.6.#sst_port diff --git a/mysql-test/suite/galera_3nodes/r/galera_gtid_2_cluster.result b/mysql-test/suite/galera_3nodes/r/galera_gtid_2_cluster.result new file mode 100644 index 00000000000..35ca84119e7 --- /dev/null +++ b/mysql-test/suite/galera_3nodes/r/galera_gtid_2_cluster.result @@ -0,0 +1,231 @@ +cluster 1 node 1 +SHOW STATUS LIKE 'wsrep_cluster_size'; +Variable_name Value +wsrep_cluster_size 3 +cluster 1 node 2 +SHOW STATUS LIKE 'wsrep_cluster_size'; +Variable_name Value +wsrep_cluster_size 3 +cluster 1 node 3 +SHOW STATUS LIKE 'wsrep_cluster_size'; +Variable_name Value +wsrep_cluster_size 3 +cluster 2 node 1 +SHOW STATUS LIKE 'wsrep_cluster_size'; +Variable_name Value +wsrep_cluster_size 3 +cluster 2 node 2 +SHOW STATUS LIKE 'wsrep_cluster_size'; +Variable_name Value +wsrep_cluster_size 3 +cluster 2 node 3 +SHOW STATUS LIKE 'wsrep_cluster_size'; +Variable_name Value +wsrep_cluster_size 3 +change master to master_host='127.0.0.1', master_user='root', master_port=NODE_MYPORT_4, master_use_gtid=current_pos, ignore_server_ids=(12,13);; +start slave; +include/wait_for_slave_to_start.inc +select @@gtid_binlog_state; +@@gtid_binlog_state + +select @@gtid_slave_pos; +@@gtid_slave_pos + +change master to master_host='127.0.0.1', master_user='root', master_port=NODE_MYPORT_1, master_use_gtid=current_pos, ignore_server_ids=(22,23);; +start slave; +include/wait_for_slave_to_start.inc +select @@gtid_binlog_state; +@@gtid_binlog_state + +select @@gtid_slave_pos; +@@gtid_slave_pos + +cluster 1 node 1 +create table t1 (cluster_domain_id int ,node_server_id int, seq_no int); +insert into t1 values (1, 11, 2); +select @@gtid_binlog_state; +@@gtid_binlog_state +1-11-2 +#wait for sync cluster 1 and 2 +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +cluster 2 node 1 +select @@gtid_binlog_state; +@@gtid_binlog_state +1-11-2 +insert into t1 values (2, 21, 1); +select @@gtid_binlog_state; +@@gtid_binlog_state +1-11-2,2-21-1 +select * from t1; +cluster_domain_id node_server_id seq_no +1 11 2 +2 21 1 +#wait for sync cluster 1 and 2 +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +cluster 1 node 2 +select @@gtid_binlog_state; +@@gtid_binlog_state +1-11-2,2-21-1 +insert into t1 values (1, 12, 3); +select @@gtid_binlog_state; +@@gtid_binlog_state +1-11-2,1-12-3,2-21-1 +#wait for sync cluster 1 and 2 +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +cluster 1 node 3 +select @@gtid_binlog_state; +@@gtid_binlog_state +1-11-2,1-12-3,2-21-1 +insert into t1 values (1, 13, 4); +select @@gtid_binlog_state; +@@gtid_binlog_state +1-12-3,1-11-2,1-13-4,2-21-1 +#wait for sync cluster 1 and 2 +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +cluster 2 node 2 +select @@gtid_binlog_state; +@@gtid_binlog_state +1-12-3,1-11-2,1-13-4,2-21-1 +insert into t1 values (2, 22, 2); +select @@gtid_binlog_state; +@@gtid_binlog_state +1-12-3,1-11-2,1-13-4,2-21-1,2-22-2 +#wait for sync cluster 2 and 1 +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +cluster 2 node 3 +select @@gtid_binlog_state; +@@gtid_binlog_state +1-12-3,1-11-2,1-13-4,2-21-1,2-22-2 +insert into t1 values (2, 23, 3); +select @@gtid_binlog_state; +@@gtid_binlog_state +1-12-3,1-11-2,1-13-4,2-21-1,2-22-2,2-23-3 +#wait for sync cluster 2 and 1 +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +cluster 1 node 1 +select @@gtid_binlog_state; +@@gtid_binlog_state +1-12-3,1-11-2,1-13-4,2-21-1,2-22-2,2-23-3 +drop table t1; +stop slave; +reset slave; +change master to master_use_gtid=no, ignore_server_ids=(); +reset master; +set global GTID_SLAVE_POS=""; +cluster 2 node 1 +stop slave; +reset slave; +change master to master_use_gtid=no, ignore_server_ids=(); +reset master; +set global GTID_SLAVE_POS=""; +reset master; +reset master; +reset master; +reset master; +change master to master_host='127.0.0.1', master_user='root', master_port=NODE_MYPORT_6, master_use_gtid=current_pos, ignore_server_ids=(12,13);; +start slave; +include/wait_for_slave_to_start.inc +select @@gtid_binlog_state; +@@gtid_binlog_state + +select @@gtid_slave_pos; +@@gtid_slave_pos + +change master to master_host='127.0.0.1', master_user='root', master_port=NODE_MYPORT_3, master_use_gtid=current_pos, ignore_server_ids=(22,23);; +start slave; +include/wait_for_slave_to_start.inc +select @@gtid_binlog_state; +@@gtid_binlog_state + +select @@gtid_slave_pos; +@@gtid_slave_pos + +cluster 1 node 1 +create table t1 (cluster_domain_id int ,node_server_id int, seq_no int); +insert into t1 values (1, 11, 2); +select @@gtid_binlog_state; +@@gtid_binlog_state +1-11-2 +#wait for sync cluster 1 and 2 +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +cluster 2 node 1 +insert into t1 values (2, 21, 1); +select @@gtid_binlog_state; +@@gtid_binlog_state +1-11-2,2-21-1 +select * from t1; +cluster_domain_id node_server_id seq_no +1 11 2 +2 21 1 +#wait for sync cluster 1 and 2 +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +cluster 1 node 2 +select @@gtid_binlog_state; +@@gtid_binlog_state +1-11-2,2-21-1 +insert into t1 values (1, 12, 3); +select @@gtid_binlog_state; +@@gtid_binlog_state +1-11-2,1-12-3,2-21-1 +#wait for sync cluster 1 and 2 +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +cluster 1 node 3 +select @@gtid_binlog_state; +@@gtid_binlog_state +1-11-2,1-12-3,2-21-1 +insert into t1 values (1, 13, 4); +select @@gtid_binlog_state; +@@gtid_binlog_state +1-12-3,1-11-2,1-13-4,2-21-1 +#wait for sync cluster 1 and 2 +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +cluster 2 node 2 +select @@gtid_binlog_state; +@@gtid_binlog_state +1-12-3,1-11-2,1-13-4,2-21-1 +insert into t1 values (2, 22, 2); +select @@gtid_binlog_state; +@@gtid_binlog_state +1-12-3,1-11-2,1-13-4,2-21-1,2-22-2 +#wait for sync cluster 2 and 1 +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +cluster 2 node 3 +select @@gtid_binlog_state; +@@gtid_binlog_state +1-12-3,1-11-2,1-13-4,2-21-1,2-22-2 +insert into t1 values (2, 23, 3); +select @@gtid_binlog_state; +@@gtid_binlog_state +1-12-3,1-11-2,1-13-4,2-21-1,2-22-2,2-23-3 +#wait for sync cluster 2 and 1 +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +cluster 1 node 1 +select @@gtid_binlog_state; +@@gtid_binlog_state +1-12-3,1-11-2,1-13-4,2-21-1,2-22-2,2-23-3 +drop table t1; +stop slave; +change master to master_use_gtid=no, ignore_server_ids=(); +reset master; +set global GTID_SLAVE_POS=""; +cluster 2 node 1 +stop slave; +change master to master_use_gtid=no, ignore_server_ids=(); +reset master; +set global GTID_SLAVE_POS=""; +reset master; +reset master; +reset master; +reset master; diff --git a/mysql-test/suite/galera_3nodes/t/galera_gtid_2_cluster.cnf b/mysql-test/suite/galera_3nodes/t/galera_gtid_2_cluster.cnf new file mode 100644 index 00000000000..dc5535ef34a --- /dev/null +++ b/mysql-test/suite/galera_3nodes/t/galera_gtid_2_cluster.cnf @@ -0,0 +1,28 @@ +# We need a dedicated .cnf file, even if empty, in order to force this test to run +# alone on a freshly started cluster. Otherwise there are adverse interactions with +# following tests such as galera_3nodes.galera_var_dirty_reads2 + +!include ../galera_2x3nodes.cnf +[mysqld.1] +wsrep_gtid_domain_id=1 +server-id=11 + +[mysqld.2] +wsrep_gtid_domain_id=1 +server-id=12 + +[mysqld.3] +wsrep_gtid_domain_id=1 +server-id=13 + +[mysqld.4] +wsrep_gtid_domain_id=2 +server-id=21 + +[mysqld.5] +wsrep_gtid_domain_id=2 +server-id=22 + +[mysqld.6] +wsrep_gtid_domain_id=2 +server-id=23 diff --git a/mysql-test/suite/galera_3nodes/t/galera_gtid_2_cluster.test b/mysql-test/suite/galera_3nodes/t/galera_gtid_2_cluster.test new file mode 100644 index 00000000000..c679db1305d --- /dev/null +++ b/mysql-test/suite/galera_3nodes/t/galera_gtid_2_cluster.test @@ -0,0 +1,292 @@ +# +# This test creates 2x 3 nodes galera cluster. +# The whole test case +# A <-> B <-> C {Galera cluster 1} +# | {Circular Async replication} +# D <-> E <-> F {Galera cluster 2} +# We will write on any random node to see if gtid is consitent or not +# Then we will kill node D and set up the replication between A and E +# To see whether fail over works or not. + +--source include/big_test.inc +--source include/galera_cluster.inc +--source include/have_innodb.inc + +--connection node_1 +--echo cluster 1 node 1 +SHOW STATUS LIKE 'wsrep_cluster_size'; + +--connection node_2 +--echo cluster 1 node 2 +SHOW STATUS LIKE 'wsrep_cluster_size'; + +--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3 +--connection node_3 +--echo cluster 1 node 3 +SHOW STATUS LIKE 'wsrep_cluster_size'; + +--connect node_4, 127.0.0.1, root, , test, $NODE_MYPORT_4 +--connection node_4 +--echo cluster 2 node 1 +SHOW STATUS LIKE 'wsrep_cluster_size'; + +--connect node_5, 127.0.0.1, root, , test, $NODE_MYPORT_5 +--connection node_5 +--echo cluster 2 node 2 +SHOW STATUS LIKE 'wsrep_cluster_size'; + +--connect node_6, 127.0.0.1, root, , test, $NODE_MYPORT_6 +--connection node_6 +--echo cluster 2 node 3 +SHOW STATUS LIKE 'wsrep_cluster_size'; +#--disable_parsing +--connection node_1 +--replace_result $NODE_MYPORT_4 NODE_MYPORT_4 +--eval change master to master_host='127.0.0.1', master_user='root', master_port=$NODE_MYPORT_4, master_use_gtid=current_pos, ignore_server_ids=(12,13); +start slave; +--source include/wait_for_slave_to_start.inc +select @@gtid_binlog_state; +select @@gtid_slave_pos; +#--query_vertical SHOW SLAVE STATUS; + +--connection node_4 +--replace_result $NODE_MYPORT_1 NODE_MYPORT_1 +--eval change master to master_host='127.0.0.1', master_user='root', master_port=$NODE_MYPORT_1, master_use_gtid=current_pos, ignore_server_ids=(22,23); +start slave; +--source include/wait_for_slave_to_start.inc +select @@gtid_binlog_state; +select @@gtid_slave_pos; +#--query_vertical SHOW SLAVE STATUS; + +--echo cluster 1 node 1 +--connection node_1 +create table t1 (cluster_domain_id int ,node_server_id int, seq_no int); +insert into t1 values (1, 11, 2); +select @@gtid_binlog_state; + +--echo #wait for sync cluster 1 and 2 +--connection node_1 +--source include/save_master_gtid.inc +--connection node_4 +--source include/sync_with_master_gtid.inc + +--echo cluster 2 node 1 +--connection node_4 +select @@gtid_binlog_state; +insert into t1 values (2, 21, 1); +select @@gtid_binlog_state; +select * from t1; +--echo #wait for sync cluster 1 and 2 +--connection node_1 +--source include/save_master_gtid.inc +--connection node_4 +--source include/sync_with_master_gtid.inc + + +--echo cluster 1 node 2 +--connection node_2 +select @@gtid_binlog_state; +insert into t1 values (1, 12, 3); +select @@gtid_binlog_state; + +--echo #wait for sync cluster 1 and 2 +--connection node_1 +--source include/save_master_gtid.inc +--connection node_4 +--source include/sync_with_master_gtid.inc + +--echo cluster 1 node 3 +--connection node_3 +select @@gtid_binlog_state; +insert into t1 values (1, 13, 4); +select @@gtid_binlog_state; + +--echo #wait for sync cluster 1 and 2 +--connection node_1 +--source include/save_master_gtid.inc +--connection node_4 +--source include/sync_with_master_gtid.inc + +--echo cluster 2 node 2 +--connection node_5 +select @@gtid_binlog_state; +insert into t1 values (2, 22, 2); +select @@gtid_binlog_state; + +--echo #wait for sync cluster 2 and 1 +--connection node_4 +--source include/save_master_gtid.inc +--connection node_1 +--source include/sync_with_master_gtid.inc + +--echo cluster 2 node 3 +--connection node_6 +select @@gtid_binlog_state; +insert into t1 values (2, 23, 3); +select @@gtid_binlog_state; + +--echo #wait for sync cluster 2 and 1 +--connection node_4 +--source include/save_master_gtid.inc +--connection node_1 +--source include/sync_with_master_gtid.inc + + +--echo cluster 1 node 1 +--connection node_1 +select @@gtid_binlog_state; +drop table t1; +stop slave; +reset slave; +change master to master_use_gtid=no, ignore_server_ids=(); +reset master; +set global GTID_SLAVE_POS=""; +--sleep 2 + +--echo cluster 2 node 1 +--connection node_4 +stop slave; +reset slave; +change master to master_use_gtid=no, ignore_server_ids=(); +reset master; +set global GTID_SLAVE_POS=""; + +--connection node_2 +reset master; +--connection node_3 +reset master; +--connection node_5 +reset master; +--connection node_6 +reset master; +#--enable_parsing +# +# This test creates 2x 3 nodes galera cluster. +# The whole test case +# A <-> B <-> C {Galera cluster 1} +# \ / +# \ / +# / {C->D, F->A , Async normal slave repl} +# / \ +# | \ +# D <-> E <-> F {Galera cluster 2} +# We will write on any random node to see if gtid is consitent or not +# Then we will kill node D and set up the replication between A and E +# To see whether fail over works or not. +--connection node_1 +--replace_result $NODE_MYPORT_6 NODE_MYPORT_6 +--eval change master to master_host='127.0.0.1', master_user='root', master_port=$NODE_MYPORT_6, master_use_gtid=current_pos, ignore_server_ids=(12,13); +start slave; +--source include/wait_for_slave_to_start.inc +select @@gtid_binlog_state; +select @@gtid_slave_pos; +#--query_vertical SHOW SLAVE STATUS; + +--connection node_4 +--replace_result $NODE_MYPORT_3 NODE_MYPORT_3 +--eval change master to master_host='127.0.0.1', master_user='root', master_port=$NODE_MYPORT_3, master_use_gtid=current_pos, ignore_server_ids=(22,23); +start slave; +--source include/wait_for_slave_to_start.inc +select @@gtid_binlog_state; +select @@gtid_slave_pos; +#--query_vertical SHOW SLAVE STATUS; + +--echo cluster 1 node 1 +--connection node_1 +create table t1 (cluster_domain_id int ,node_server_id int, seq_no int); +insert into t1 values (1, 11, 2); + +select @@gtid_binlog_state; + +--echo #wait for sync cluster 1 and 2 +--connection node_1 +--source include/save_master_gtid.inc +--connection node_4 +--source include/sync_with_master_gtid.inc +--sleep 2 +--echo cluster 2 node 1 +--connection node_4 +insert into t1 values (2, 21, 1); +select @@gtid_binlog_state; +select * from t1; + +--echo #wait for sync cluster 1 and 2 +--connection node_1 +--source include/save_master_gtid.inc +--connection node_4 +--source include/sync_with_master_gtid.inc + + +--echo cluster 1 node 2 +--connection node_2 +select @@gtid_binlog_state; +insert into t1 values (1, 12, 3); +select @@gtid_binlog_state; + +--echo #wait for sync cluster 1 and 2 +--connection node_1 +--source include/save_master_gtid.inc +--connection node_4 +--source include/sync_with_master_gtid.inc + +--echo cluster 1 node 3 +--connection node_3 +select @@gtid_binlog_state; +insert into t1 values (1, 13, 4); +select @@gtid_binlog_state; + +--echo #wait for sync cluster 1 and 2 +--connection node_1 +--source include/save_master_gtid.inc +--connection node_4 +--source include/sync_with_master_gtid.inc + +--echo cluster 2 node 2 +--connection node_5 +select @@gtid_binlog_state; +insert into t1 values (2, 22, 2); +select @@gtid_binlog_state; + +--echo #wait for sync cluster 2 and 1 +--connection node_4 +--source include/save_master_gtid.inc +--connection node_1 +--source include/sync_with_master_gtid.inc + +--echo cluster 2 node 3 +--connection node_6 +select @@gtid_binlog_state; +insert into t1 values (2, 23, 3); +select @@gtid_binlog_state; + +--echo #wait for sync cluster 2 and 1 +--connection node_4 +--source include/save_master_gtid.inc +--connection node_1 +--source include/sync_with_master_gtid.inc + + +--echo cluster 1 node 1 +--connection node_1 +select @@gtid_binlog_state; +drop table t1; +stop slave; +change master to master_use_gtid=no, ignore_server_ids=(); +reset master; +set global GTID_SLAVE_POS=""; + +--echo cluster 2 node 1 +--connection node_4 +stop slave; +change master to master_use_gtid=no, ignore_server_ids=(); +reset master; +set global GTID_SLAVE_POS=""; + +--connection node_2 +reset master; +--connection node_3 +reset master; +--connection node_5 +reset master; +--connection node_6 +reset master; diff --git a/sql/log.cc b/sql/log.cc index 07d4074c3d4..29f8c5639cf 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -4947,7 +4947,55 @@ MYSQL_BIN_LOG::is_xidlist_idle_nolock() return true; } +#ifdef WITH_WSREP +inline bool +is_gtid_cached_internal(IO_CACHE *file) +{ + uchar data[EVENT_TYPE_OFFSET+1]; + bool result= false; + my_off_t write_pos= my_b_tell(file); + if (reinit_io_cache(file, READ_CACHE, 0, 0, 0)) + return false; + /* + In the cache we have gtid event if , below condition is true, + */ + my_b_read(file, data, sizeof(data)); + uint event_type= (uchar)data[EVENT_TYPE_OFFSET]; + if (event_type == GTID_LOG_EVENT) + result= true; + /* + Cleanup , Why because we have not read the full buffer + and this will cause next to next reinit_io_cache(called in write_cache) + to make cache empty. + */ + file->read_pos= file->read_end; + if (reinit_io_cache(file, WRITE_CACHE, write_pos, 0, 0)) + return false; + return result; +} +#endif +#ifdef WITH_WSREP +inline bool +MYSQL_BIN_LOG::is_gtid_cached(THD *thd) +{ + binlog_cache_mngr *mngr= (binlog_cache_mngr *) thd_get_ha_data( + thd, binlog_hton); + if (!mngr) + return false; + binlog_cache_data *cache_trans= mngr->get_binlog_cache_data( + use_trans_cache(thd, true)); + binlog_cache_data *cache_stmt= mngr->get_binlog_cache_data( + use_trans_cache(thd, false)); + if (cache_trans && !cache_trans->empty() && + is_gtid_cached_internal(&cache_trans->cache_log)) + return true; + if (cache_stmt && !cache_stmt->empty() && + is_gtid_cached_internal(&cache_stmt->cache_log)) + return true; + return false; +} +#endif /** Create a new log file name. @@ -5544,7 +5592,37 @@ THD::binlog_start_trans_and_stmt() cache_mngr->trx_cache.get_prev_position() == MY_OFF_T_UNDEF) { this->binlog_set_stmt_begin(); - if (in_multi_stmt_transaction_mode()) + bool mstmt_mode= in_multi_stmt_transaction_mode(); +#ifdef WITH_WSREP + /* Write Gtid + Get domain id only when gtid mode is set + If this event is replicate through a master then , + we will forward the same gtid another nodes + We have to do this only one time in mysql transaction. + Since this function is called multiple times , We will check for + ha_info->is_started() + */ + Ha_trx_info *ha_info; + ha_info= this->ha_data[binlog_hton->slot].ha_info + (mstmt_mode ? 1 : 0); + + if (!ha_info->is_started() && wsrep_gtid_mode + && this->variables.gtid_seq_no) + { + binlog_cache_mngr *const cache_mngr= + (binlog_cache_mngr*) thd_get_ha_data(this, binlog_hton); + + IO_CACHE *file= + cache_mngr->get_binlog_cache_log(use_trans_cache(this, true)); + Log_event_writer writer(file); + Gtid_log_event gtid_event(this, this->variables.gtid_seq_no, + this->variables.gtid_domain_id, + true, LOG_EVENT_SUPPRESS_USE_F, + true, 0); + gtid_event.server_id= this->variables.server_id; + writer.write(>id_event); + } +#endif + if (mstmt_mode) trans_register_ha(this, TRUE, binlog_hton); trans_register_ha(this, FALSE, binlog_hton); /* @@ -5826,7 +5904,7 @@ MYSQL_BIN_LOG::write_gtid_event(THD *thd, bool standalone, DBUG_PRINT("enter", ("standalone: %d", standalone)); #ifdef WITH_WSREP - if (WSREP(thd) && thd->wsrep_trx_meta.gtid.seqno != -1 && wsrep_gtid_mode) + if (WSREP(thd) && thd->wsrep_trx_meta.gtid.seqno != -1 && wsrep_gtid_mode && !thd->variables.gtid_seq_no) { domain_id= wsrep_gtid_domain_id; } else { @@ -5878,6 +5956,12 @@ MYSQL_BIN_LOG::write_gtid_event(THD *thd, bool standalone, /* Write the event to the binary log. */ DBUG_ASSERT(this == &mysql_bin_log); + +#ifdef WITH_WSREP + if (wsrep_gtid_mode && is_gtid_cached(thd)) + DBUG_RETURN(false); +#endif + if (write_event(>id_event)) DBUG_RETURN(true); status_var_add(thd->status_var.binlog_bytes_written, gtid_event.data_written); diff --git a/sql/log.h b/sql/log.h index 3026ca11e31..2118bd7a059 100644 --- a/sql/log.h +++ b/sql/log.h @@ -559,7 +559,13 @@ class MYSQL_BIN_LOG: public TC_LOG, private MYSQL_LOG bool write_transaction_to_binlog_events(group_commit_entry *entry); void trx_group_commit_leader(group_commit_entry *leader); bool is_xidlist_idle_nolock(); - +#ifdef WITH_WSREP + /* + When this mariadb node is slave and galera enabled. So in this case + we write the gtid in wsrep_run_commit itself. + */ + inline bool is_gtid_cached(THD *thd); +#endif public: /* A list of struct xid_count_per_binlog is used to keep track of how many diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index bdc8491080d..285bb520b87 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -1227,6 +1227,16 @@ int wsrep_to_buf_helper( if (!ret && writer.write(>id_ev)) ret= 1; } #endif /* GTID_SUPPORT */ + if (wsrep_gtid_mode && thd->variables.gtid_seq_no) + { + Gtid_log_event gtid_event(thd, thd->variables.gtid_seq_no, + thd->variables.gtid_domain_id, + true, LOG_EVENT_SUPPRESS_USE_F, + true, 0); + gtid_event.server_id= thd->variables.server_id; + if (!gtid_event.is_valid()) ret= 0; + ret= writer.write(>id_event); + } /* if there is prepare query, add event for it */ if (!ret && thd->wsrep_TOI_pre_query) From 9631d933fbc2ec998746d49e1c2134d57947705a Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sun, 3 Dec 2017 02:17:12 +0100 Subject: [PATCH 47/69] debian: don't be smart about skipping plugins --- debian/rules | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/debian/rules b/debian/rules index 2f385b26455..2041371a409 100755 --- a/debian/rules +++ b/debian/rules @@ -45,11 +45,6 @@ else TESTSUITE_FAIL_CMD:=exit 1 endif -# Skip TokuDB if arch is not amd64 -ifneq ($(ARCH), amd64) - CMAKEFLAGS += -DWITHOUT_TOKUDB=true -endif - # Add support for verbose builds MAKEFLAGS += VERBOSE=1 @@ -119,20 +114,16 @@ override_dh_auto_install: dh_testdir dh_testroot - # If TokuDB plugin was not built skip the package - [ -f $(BUILDDIR)/storage/tokudb/ha_tokudb.so ] || sed -i -e "/Package: mariadb-plugin-tokudb/,+14d" debian/control - - # If Mroonga plugin was not built skip the package - [ -f $(BUILDDIR)/storage/mroonga/ha_mroonga.so ] || sed -i -e "/Package: mariadb-plugin-mroonga/,+13d" debian/control +# Skip TokuDB if arch is not amd64 +ifneq ($(ARCH), amd64) + sed -i -e "/Package: mariadb-plugin-tokudb/,+14d" debian/control +endif # If libthrift-dev was available (manually installed, as it is # not in Debian) and ha_cassandra.so was thus built, create package, # otherwise skip it. [ -f $(BUILDDIR)/storage/cassandra/ha_cassandra.so ] || sed -i -e "/Package: mariadb-plugin-cassandra/,+16d" debian/control - # If Spider plugin was not built skip the package - [ -f $(BUILDDIR)/storage/spider/ha_spider.so ] || sed -i -e "/Package: mariadb-plugin-spider/,+14d" debian/control - # Copy systemd files to a location available for dh_installinit cp $(BUILDDIR)/support-files/mariadb.service debian/mariadb-server-10.2.mariadb.service cp $(BUILDDIR)/support-files/mariadb@.service debian/mariadb-server-10.2.mariadb@.service From 76056559ac7cacfe176f6e131ce3bc7bfc749890 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 29 Nov 2017 18:36:17 +0100 Subject: [PATCH 48/69] MDEV-9869 INSTALL SONAME 'ha_connect' fix 011497bd603 in RPM and DEB: storage engine packages must require the server package of exactly correct version. --- cmake/plugin.cmake | 2 +- debian/autobake-deb.sh | 2 +- debian/control | 27 ++++++++++++++++++++------- debian/rules | 4 ++-- 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/cmake/plugin.cmake b/cmake/plugin.cmake index 2a2f206dcef..70b252c16b5 100644 --- a/cmake/plugin.cmake +++ b/cmake/plugin.cmake @@ -230,7 +230,7 @@ MACRO(MYSQL_ADD_PLUGIN) SET(CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} PARENT_SCOPE) IF (NOT ARG_CLIENT) - SET(CPACK_RPM_${ARG_COMPONENT}_PACKAGE_REQUIRES "MariaDB${ver}" PARENT_SCOPE) + SET(CPACK_RPM_${ARG_COMPONENT}_PACKAGE_REQUIRES "MariaDB-server${ver}" PARENT_SCOPE) ENDIF() # workarounds for cmake issues #13248 and #12864: SET(CPACK_RPM_${ARG_COMPONENT}_PACKAGE_PROVIDES "cmake_bug_13248" PARENT_SCOPE) diff --git a/debian/autobake-deb.sh b/debian/autobake-deb.sh index 92c68c225d7..688698dad8a 100755 --- a/debian/autobake-deb.sh +++ b/debian/autobake-deb.sh @@ -79,7 +79,7 @@ GCCVERSION=$(gcc -dumpversion | sed -e 's/\.\([0-9][0-9]\)/\1/g' -e 's/\.\([0-9] # x86 32 bit. if [[ $GCCVERSION -lt 40800 ]] || [[ $(arch) =~ i[346]86 ]] then - sed '/Package: mariadb-plugin-rocksdb/,+7d' -i debian/control + sed '/Package: mariadb-plugin-rocksdb/,+9d' -i debian/control fi if [[ $GCCVERSION -lt 40800 ]] then diff --git a/debian/control b/debian/control index d75d7c40749..79936870579 100644 --- a/debian/control +++ b/debian/control @@ -438,7 +438,7 @@ Description: MariaDB database client (metapackage depending on the latest versio Package: mariadb-plugin-connect Architecture: any Depends: libxml2, - mariadb-server-10.2, + mariadb-server-10.2 (= ${binary:Version}), unixodbc, ${misc:Depends}, ${shlibs:Depends} @@ -452,7 +452,9 @@ Description: Connect storage engine for MariaDB Package: mariadb-plugin-rocksdb Architecture: any -Depends: mariadb-server-10.2, ${misc:Depends}, ${shlibs:Depends} +Depends: mariadb-server-10.2 (= ${binary:Version}), + ${misc:Depends}, + ${shlibs:Depends} Description: RocksDB storage engine for MariaDB The RocksDB storage engine is a high performance storage engine, aimed at maximising storage efficiency while maintaining InnoDB-like performance. @@ -460,7 +462,10 @@ Description: RocksDB storage engine for MariaDB Package: mariadb-plugin-oqgraph Architecture: any -Depends: libjudydebian1, mariadb-server-10.2, ${misc:Depends}, ${shlibs:Depends} +Depends: libjudydebian1, + mariadb-server-10.2 (= ${binary:Version}), + ${misc:Depends}, + ${shlibs:Depends} Breaks: mariadb-oqgraph-engine-10.1, mariadb-oqgraph-engine-10.2 Replaces: mariadb-oqgraph-engine-10.1, mariadb-oqgraph-engine-10.2 Description: OQGraph storage engine for MariaDB @@ -470,7 +475,9 @@ Description: OQGraph storage engine for MariaDB Package: mariadb-plugin-tokudb Architecture: any -Depends: mariadb-server-10.2, ${misc:Depends}, ${shlibs:Depends} +Depends: mariadb-server-10.2 (= ${binary:Version}), + ${misc:Depends}, + ${shlibs:Depends} Breaks: mariadb-server-10.0, mariadb-server-10.1, mariadb-server-10.2 (<< ${source:Version}) @@ -485,7 +492,9 @@ Description: TokuDB storage engine for MariaDB Package: mariadb-plugin-mroonga Architecture: any -Depends: mariadb-server-10.2, ${misc:Depends}, ${shlibs:Depends} +Depends: mariadb-server-10.2 (= ${binary:Version}), + ${misc:Depends}, + ${shlibs:Depends} Breaks: mariadb-server-10.0, mariadb-server-10.1, mariadb-server-10.2 (<< ${source:Version}) @@ -499,7 +508,9 @@ Description: Mroonga storage engine for MariaDB Package: mariadb-plugin-spider Architecture: any -Depends: mariadb-server-10.2, ${misc:Depends}, ${shlibs:Depends} +Depends: mariadb-server-10.2 (= ${binary:Version}), + ${misc:Depends}, + ${shlibs:Depends} Breaks: mariadb-server-10.0, mariadb-server-10.1, mariadb-server-10.2 (<< ${source:Version}) @@ -514,7 +525,9 @@ Description: Spider storage engine for MariaDB Package: mariadb-plugin-cassandra Architecture: any -Depends: mariadb-server-10.2, ${misc:Depends}, ${shlibs:Depends} +Depends: mariadb-server-10.2 (= ${binary:Version}), + ${misc:Depends}, + ${shlibs:Depends} Breaks: mariadb-server-10.0, mariadb-server-10.1, mariadb-server-10.2 (<< ${source:Version}) diff --git a/debian/rules b/debian/rules index 2041371a409..16bcf2a0073 100755 --- a/debian/rules +++ b/debian/rules @@ -116,13 +116,13 @@ override_dh_auto_install: # Skip TokuDB if arch is not amd64 ifneq ($(ARCH), amd64) - sed -i -e "/Package: mariadb-plugin-tokudb/,+14d" debian/control + sed -i -e "/Package: mariadb-plugin-tokudb/,+16d" debian/control endif # If libthrift-dev was available (manually installed, as it is # not in Debian) and ha_cassandra.so was thus built, create package, # otherwise skip it. - [ -f $(BUILDDIR)/storage/cassandra/ha_cassandra.so ] || sed -i -e "/Package: mariadb-plugin-cassandra/,+16d" debian/control + [ -f $(BUILDDIR)/storage/cassandra/ha_cassandra.so ] || sed -i -e "/Package: mariadb-plugin-cassandra/,+18d" debian/control # Copy systemd files to a location available for dh_installinit cp $(BUILDDIR)/support-files/mariadb.service debian/mariadb-server-10.2.mariadb.service From e8182df1425321d67887359d481aaa18ad36e70f Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Thu, 20 Jul 2017 10:32:25 +1000 Subject: [PATCH 49/69] MDEV-12386: Use AppVeyor for public Windows CI Signed-off-by: Daniel Black --- appveyor.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 appveyor.yml diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 00000000000..bc4f4d83528 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,17 @@ +version: 10.2-{build} +before_build: +- md %APPVEYOR_BUILD_FOLDER%\win_build +- cd %APPVEYOR_BUILD_FOLDER%\win_build +- cmake .. -G "Visual Studio 15 2017" -DBOOST_ROOT=C:\Libraries\boost_1_64_0 -DPKG_CONFIG_EXECUTABLE=C:\perl\bin\pkg-config -DBISON_EXECUTABLE=C:\cygwin\bin\bison +- dir +build: + project: win_build\MySQL.sln + parallel: true + verbosity: minimal +configuration: + - Debug +test: +test_script: +- cd %APPVEYOR_BUILD_FOLDER%\win_build\mysql-test +- perl mysql-test-run.pl --force --max-test-fail=20 --parallel=6 --testcase-timeout=2 --skip-test-list=unstable-tests --suite=main,innodb,plugins,mariabackup +image: Visual Studio 2017 From c3bd0b0301936d0dcd0918bb8c966c272610d61b Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Sat, 18 Nov 2017 00:05:22 +0800 Subject: [PATCH 50/69] Appveyor: apply feedback from wlad, timeout=4 PKG_CONFIG does not really work on Windows, Strawberry perl's uses mingw libraries, which VS compiler cannot use, BOOST not used. Tests main.query_cache_debug and main.mdev-504 timed out on debug build at 2 minutes so increase the timeout to 4 minutes. Overall build time was 30 min 44 seconds so plenty of time currently. Signed-off-by: Daniel Black --- appveyor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index bc4f4d83528..a005fc5a93f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -2,7 +2,7 @@ version: 10.2-{build} before_build: - md %APPVEYOR_BUILD_FOLDER%\win_build - cd %APPVEYOR_BUILD_FOLDER%\win_build -- cmake .. -G "Visual Studio 15 2017" -DBOOST_ROOT=C:\Libraries\boost_1_64_0 -DPKG_CONFIG_EXECUTABLE=C:\perl\bin\pkg-config -DBISON_EXECUTABLE=C:\cygwin\bin\bison +- cmake .. -G "Visual Studio 15 2017" -DBISON_EXECUTABLE=C:\cygwin\bin\bison - dir build: project: win_build\MySQL.sln @@ -13,5 +13,5 @@ configuration: test: test_script: - cd %APPVEYOR_BUILD_FOLDER%\win_build\mysql-test -- perl mysql-test-run.pl --force --max-test-fail=20 --parallel=6 --testcase-timeout=2 --skip-test-list=unstable-tests --suite=main,innodb,plugins,mariabackup +- perl mysql-test-run.pl --force --max-test-fail=20 --parallel=6 --testcase-timeout=4 --skip-test-list=unstable-tests --suite=main,innodb,plugins,mariabackup image: Visual Studio 2017 From c881d82c931c52e64f7c8d252c12189d299d6c97 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sun, 24 Dec 2017 17:21:50 +0100 Subject: [PATCH 51/69] cleanup: ha_myisam::data_file_name and index_file_name don't allocate them on THD::mem_root on every init(HA_STATUS_CONST) call, do it once in open() (because they don't change) on TABLE::mem_root (so they stay valid until the table is closed) --- storage/myisam/ha_myisam.cc | 47 ++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index 3a9bf45e22f..7f2afc3130a 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -729,6 +729,7 @@ int ha_myisam::open(const char *name, int mode, uint test_if_locked) { MI_KEYDEF *keyinfo; MI_COLUMNDEF *recinfo= 0; + char readlink_buf[FN_REFLEN], name_buff[FN_REFLEN]; uint recs; uint i; @@ -783,6 +784,30 @@ int ha_myisam::open(const char *name, int mode, uint test_if_locked) (void) mi_extra(file, HA_EXTRA_NO_WAIT_LOCK, 0); info(HA_STATUS_NO_LOCK | HA_STATUS_VARIABLE | HA_STATUS_CONST); + + /* + Set data_file_name and index_file_name to point at the symlink value + if table is symlinked (Ie; Real name is not same as generated name) + */ + fn_format(name_buff, file->filename, "", MI_NAME_DEXT, + MY_APPEND_EXT | MY_UNPACK_FILENAME); + if (my_is_symlink(name_buff)) + { + my_readlink(readlink_buf, name_buff, MYF(0)); + data_file_name= strdup_root(&table->mem_root, readlink_buf); + } + else + data_file_name= 0; + fn_format(name_buff, file->filename, "", MI_NAME_IEXT, + MY_APPEND_EXT | MY_UNPACK_FILENAME); + if (my_is_symlink(name_buff)) + { + my_readlink(readlink_buf, name_buff, MYF(0)); + index_file_name= strdup_root(&table->mem_root, readlink_buf); + } + else + index_file_name= 0; + if (!(test_if_locked & HA_OPEN_WAIT_IF_LOCKED)) (void) mi_extra(file, HA_EXTRA_WAIT_LOCK, 0); if (!table->s->db_record_offset) @@ -1847,7 +1872,6 @@ void ha_myisam::position(const uchar *record) int ha_myisam::info(uint flag) { MI_ISAMINFO misam_info; - char name_buff[FN_REFLEN]; if (!table) return 1; @@ -1895,27 +1919,6 @@ int ha_myisam::info(uint flag) sizeof(table->key_info[0].rec_per_key[0])*share->key_parts); if (table_share->tmp_table == NO_TMP_TABLE) mysql_mutex_unlock(&table_share->LOCK_share); - - /* - Set data_file_name and index_file_name to point at the symlink value - if table is symlinked (Ie; Real name is not same as generated name) - */ - char buf[FN_REFLEN]; - data_file_name= index_file_name= 0; - fn_format(name_buff, file->filename, "", MI_NAME_DEXT, - MY_APPEND_EXT | MY_UNPACK_FILENAME); - if (my_is_symlink(name_buff)) - { - my_readlink(buf, name_buff, MYF(0)); - data_file_name= ha_thd()->strdup(buf); - } - fn_format(name_buff, file->filename, "", MI_NAME_IEXT, - MY_APPEND_EXT | MY_UNPACK_FILENAME); - if (my_is_symlink(name_buff)) - { - my_readlink(buf, name_buff, MYF(0)); - index_file_name= ha_thd()->strdup(buf); - } } if (flag & HA_STATUS_ERRKEY) { From 6d8b1bd6204899afa57121cf1f7adf305118d380 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sun, 24 Dec 2017 18:37:42 +0100 Subject: [PATCH 52/69] cleanup: ha_partition::update_create_info --- sql/ha_partition.cc | 35 ++++++++--------------------------- 1 file changed, 8 insertions(+), 27 deletions(-) diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 0649d5d44aa..459af18f737 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -2180,38 +2180,19 @@ void ha_partition::update_create_info(HA_CREATE_INFO *create_info) DBUG_ASSERT(sub_elem); part= i * num_subparts + j; DBUG_ASSERT(part < m_file_tot_parts && m_file[part]); - if (ha_legacy_type(m_file[part]->ht) == DB_TYPE_INNODB) - { - dummy_info.data_file_name= dummy_info.index_file_name = NULL; - m_file[part]->update_create_info(&dummy_info); - - if (dummy_info.data_file_name || sub_elem->data_file_name) - { - sub_elem->data_file_name = (char*) dummy_info.data_file_name; - } - if (dummy_info.index_file_name || sub_elem->index_file_name) - { - sub_elem->index_file_name = (char*) dummy_info.index_file_name; - } - } + dummy_info.data_file_name= dummy_info.index_file_name = NULL; + m_file[part]->update_create_info(&dummy_info); + sub_elem->data_file_name = (char*) dummy_info.data_file_name; + sub_elem->index_file_name = (char*) dummy_info.index_file_name; } } else { DBUG_ASSERT(m_file[i]); - if (ha_legacy_type(m_file[i]->ht) == DB_TYPE_INNODB) - { - dummy_info.data_file_name= dummy_info.index_file_name= NULL; - m_file[i]->update_create_info(&dummy_info); - if (dummy_info.data_file_name || part_elem->data_file_name) - { - part_elem->data_file_name = (char*) dummy_info.data_file_name; - } - if (dummy_info.index_file_name || part_elem->index_file_name) - { - part_elem->index_file_name = (char*) dummy_info.index_file_name; - } - } + dummy_info.data_file_name= dummy_info.index_file_name= NULL; + m_file[i]->update_create_info(&dummy_info); + part_elem->data_file_name = (char*) dummy_info.data_file_name; + part_elem->index_file_name = (char*) dummy_info.index_file_name; } } DBUG_VOID_RETURN; From 5377242fff5d2260510e65c58e4e52d7c4b222f6 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sun, 24 Dec 2017 18:39:00 +0100 Subject: [PATCH 53/69] MDEV-14026 ALTER TABLE ... DELAY_KEY_WRITE=1 creates table copy for partitioned MyISAM table with DATA DIRECTORY/INDEX DIRECTORY options set data_file_name and index_file_name in HA_CREATE_INFO before calling check_if_incompatible_data() --- mysql-test/r/partition_windows.result | 4 --- .../parts/r/partition_alter_myisam.result | 13 +++++++ .../suite/parts/t/partition_alter_myisam.test | 19 +++++++++++ sql/ha_partition.cc | 34 ++++++++++++++----- 4 files changed, 57 insertions(+), 13 deletions(-) diff --git a/mysql-test/r/partition_windows.result b/mysql-test/r/partition_windows.result index dabcedcb3f9..756690925f8 100644 --- a/mysql-test/r/partition_windows.result +++ b/mysql-test/r/partition_windows.result @@ -26,9 +26,5 @@ ALTER TABLE t1 ADD PARTITION (PARTITION p3 DATA DIRECTORY = 'G:/mysqltest/p3Data Warnings: Warning 1618 option ignored Warning 1618 option ignored -Warning 1618 option ignored -Warning 1618 option ignored -Warning 1618 option ignored -Warning 1618 option ignored INSERT INTO t1 VALUES (NULL, "last", 4); DROP TABLE t1; diff --git a/mysql-test/suite/parts/r/partition_alter_myisam.result b/mysql-test/suite/parts/r/partition_alter_myisam.result index 9f2381039d3..41af6af72fc 100644 --- a/mysql-test/suite/parts/r/partition_alter_myisam.result +++ b/mysql-test/suite/parts/r/partition_alter_myisam.result @@ -42,3 +42,16 @@ PARTITION p3 VALUES IN (4,5,6) ); ERROR HY000: Syntax error: LIST PARTITIONING requires definition of VALUES IN for each partition DROP TABLE t1; +create table t1 ( c1 int, c2 int, c3 varchar(100)) delay_key_write=1 +partition by key(c1) ( +partition p01 data directory = 'MYSQL_TMP_DIR' + index directory = 'MYSQL_TMP_DIR', +partition p02 data directory = 'MYSQL_TMP_DIR' + index directory = 'MYSQL_TMP_DIR'); +insert into t1 values (1, 1, repeat('a', 100)); +insert into t1 select rand()*1000, rand()*1000, repeat('b', 100) from t1; +insert into t1 select rand()*1000, rand()*1000, repeat('b', 100) from t1; +insert into t1 select rand()*1000, rand()*1000, repeat('b', 100) from t1; +alter online table t1 delay_key_write=0; +alter online table t1 delay_key_write=1; +drop table t1; diff --git a/mysql-test/suite/parts/t/partition_alter_myisam.test b/mysql-test/suite/parts/t/partition_alter_myisam.test index a53fa333abd..b2bd0e72e4c 100644 --- a/mysql-test/suite/parts/t/partition_alter_myisam.test +++ b/mysql-test/suite/parts/t/partition_alter_myisam.test @@ -1,3 +1,22 @@ --source include/have_partition.inc --let $engine=MyISAM --source inc/part_alter_values.inc + +# +# MDEV-14026 ALTER TABLE ... DELAY_KEY_WRITE=1 creates table copy for partitioned MyISAM table with DATA DIRECTORY/INDEX DIRECTORY options +# + +replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR; +eval create table t1 ( c1 int, c2 int, c3 varchar(100)) delay_key_write=1 + partition by key(c1) ( + partition p01 data directory = '$MYSQL_TMP_DIR' + index directory = '$MYSQL_TMP_DIR', + partition p02 data directory = '$MYSQL_TMP_DIR' + index directory = '$MYSQL_TMP_DIR'); +insert into t1 values (1, 1, repeat('a', 100)); +insert into t1 select rand()*1000, rand()*1000, repeat('b', 100) from t1; +insert into t1 select rand()*1000, rand()*1000, repeat('b', 100) from t1; +insert into t1 select rand()*1000, rand()*1000, repeat('b', 100) from t1; +alter online table t1 delay_key_write=0; +alter online table t1 delay_key_write=1; +drop table t1; diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 459af18f737..34c253cc48a 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -8133,20 +8133,36 @@ uint ha_partition::alter_table_flags(uint flags) bool ha_partition::check_if_incompatible_data(HA_CREATE_INFO *create_info, uint table_changes) { - handler **file; - bool ret= COMPATIBLE_DATA_YES; - /* The check for any partitioning related changes have already been done in mysql_alter_table (by fix_partition_func), so it is only up to the underlying handlers. */ - for (file= m_file; *file; file++) - if ((ret= (*file)->check_if_incompatible_data(create_info, - table_changes)) != - COMPATIBLE_DATA_YES) - break; - return ret; + List_iterator part_it(m_part_info->partitions); + HA_CREATE_INFO dummy_info= *create_info; + uint i=0; + while (partition_element *part_elem= part_it++) + { + if (m_is_sub_partitioned) + { + List_iterator subpart_it(part_elem->subpartitions); + while (partition_element *sub_elem= subpart_it++) + { + dummy_info.data_file_name= sub_elem->data_file_name; + dummy_info.index_file_name= sub_elem->index_file_name; + if (m_file[i++]->check_if_incompatible_data(&dummy_info, table_changes)) + return COMPATIBLE_DATA_NO; + } + } + else + { + dummy_info.data_file_name= part_elem->data_file_name; + dummy_info.index_file_name= part_elem->index_file_name; + if (m_file[i++]->check_if_incompatible_data(&dummy_info, table_changes)) + return COMPATIBLE_DATA_NO; + } + } + return COMPATIBLE_DATA_YES; } From 02b7dc7bec4ff95c764a244c5037c69f262651e1 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Wed, 27 Dec 2017 12:30:05 +0400 Subject: [PATCH 54/69] MDEV-14249 Wrong character set info of Query_log_event and the query in Query_log_event constructed by different charsets cause error when slave apply the event. --- .../suite/rpl/r/rpl_ctype_latin1.result | 28 +++++++++++++ mysql-test/suite/rpl/t/rpl_ctype_latin1.test | 40 +++++++++++++++++++ sql/sp.cc | 4 +- sql/sql_view.cc | 3 +- 4 files changed, 72 insertions(+), 3 deletions(-) create mode 100644 mysql-test/suite/rpl/r/rpl_ctype_latin1.result create mode 100644 mysql-test/suite/rpl/t/rpl_ctype_latin1.test diff --git a/mysql-test/suite/rpl/r/rpl_ctype_latin1.result b/mysql-test/suite/rpl/r/rpl_ctype_latin1.result new file mode 100644 index 00000000000..909aa639522 --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_ctype_latin1.result @@ -0,0 +1,28 @@ +include/master-slave.inc +[connection master] +# +# Start of 10.2 tests +# +# +# MDEV-14249 Wrong character set info of Query_log_event and the query in Query_log_event constructed by different charsets cause error when slave apply the event. +# +SET NAMES latin1; +CREATE TABLE `tё` (`tё` INT); +CREATE VIEW `vё` AS SELECT 'vё'; +CREATE PROCEDURE `pё`() SELECT 'pё'; +connection slave; +SHOW TABLES LIKE 't%'; +Tables_in_test (t%) +tё +SHOW TABLES LIKE 'v%'; +Tables_in_test (v%) +vё +SHOW PROCEDURE STATUS LIKE 'p%'; +Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation +test pё PROCEDURE root@localhost ts ts DEFINER latin1 latin1_swedish_ci latin1_swedish_ci +connection master; +DROP TABLE `tё`; +DROP VIEW `vё`; +DROP PROCEDURE `pё`; +connection slave; +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_ctype_latin1.test b/mysql-test/suite/rpl/t/rpl_ctype_latin1.test new file mode 100644 index 00000000000..a736d1a6485 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_ctype_latin1.test @@ -0,0 +1,40 @@ +--disable_warnings +--source include/master-slave.inc +--enable_warnings + +--echo # +--echo # Start of 10.2 tests +--echo # + + +--echo # +--echo # MDEV-14249 Wrong character set info of Query_log_event and the query in Query_log_event constructed by different charsets cause error when slave apply the event. +--echo # + +# +# The below tests uses a sequence of bytes 0xD191, +# which in a utf8 console looks like ё (CYRILIC SMALL LETTER YO). +# Don't be mislead. This sequence is used in latin1 context and +# represents a sequence of two characters: +# U+00D1 CAPITAL LATIN LETTER N WITH TILDE (_latin1 0xD1) +# U+2018 LEFT SINGLE QUOTATION MARK (_latin1 0x91) +# + +SET NAMES latin1; +CREATE TABLE `tё` (`tё` INT); +CREATE VIEW `vё` AS SELECT 'vё'; +CREATE PROCEDURE `pё`() SELECT 'pё'; + +--sync_slave_with_master +SHOW TABLES LIKE 't%'; +SHOW TABLES LIKE 'v%'; +--replace_column 5 ts 6 ts +SHOW PROCEDURE STATUS LIKE 'p%'; + +--connection master +DROP TABLE `tё`; +DROP VIEW `vё`; +DROP PROCEDURE `pё`; +--sync_slave_with_master + +--source include/rpl_end.inc diff --git a/sql/sp.cc b/sql/sp.cc index fcbf4dc43d4..ef4d0996b78 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -1277,8 +1277,8 @@ log: { thd->clear_error(); - String log_query; - log_query.set_charset(system_charset_info); + StringBuffer<128> log_query(thd->variables.character_set_client); + DBUG_ASSERT(log_query.charset()->mbminlen == 1); if (!show_create_sp(thd, &log_query, sp->m_type, diff --git a/sql/sql_view.cc b/sql/sql_view.cc index bba79642d87..c3bd16b974b 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -643,7 +643,8 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views, if (!res && mysql_bin_log.is_open()) { - String buff; + StringBuffer<128> buff(thd->variables.character_set_client); + DBUG_ASSERT(buff.charset()->mbminlen == 1); const LEX_STRING command[3]= {{ C_STRING_WITH_LEN("CREATE ") }, { C_STRING_WITH_LEN("ALTER ") }, From bbb8c9d77310860f3f81bfd8b824ce353271fb14 Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Sun, 24 Dec 2017 14:08:20 -0800 Subject: [PATCH 55/69] Fixed the bug MDEV-14755 Crash when executing prepared statement for a query that uses CTE The first reference to a CTE in the processed query uses the unit built by the parser for the CTE specification. This unit is considered as the specification of the derived table created for the first reference of the CTE. This requires some transformation of the original query tree: the unit of the specification must be moved to a new position as a slave of the select where the first reference to the CTE occurs. The transformation is performed by the function st_select_lex_node::move_as_slave(). There was an obvious bug in this function. As a result of this bug in many cases the moved unit turned out to be lost in the query tree. This could cause different problems. In particular the prepared statements for queries that used CTEs could miss cleanup for some selects that was performed at the end of the preparation/execution of the PSs. If such cleanup is not done for a PS the next execution of the PS causes an assertion abort or a crash. --- mysql-test/r/cte_nonrecursive.result | 118 +++++++++++++++++++++++++++ mysql-test/t/cte_nonrecursive.test | 63 ++++++++++++++ sql/sql_lex.cc | 4 +- 3 files changed, 182 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/cte_nonrecursive.result b/mysql-test/r/cte_nonrecursive.result index ebe1aae1e8f..5164c74a0bc 100644 --- a/mysql-test/r/cte_nonrecursive.result +++ b/mysql-test/r/cte_nonrecursive.result @@ -1147,3 +1147,121 @@ SELECT * FROM cte_test; a 1 DROP VIEW cte_test; +# +# mdev-14755 : PS for query using CTE in select with subquery +# +create table t1 (a int); +insert into t1 values +(7), (2), (8), (1), (3), (2), (7), (5), (4), (7), (9), (8); +with cte as +(select a from t1 where a between 4 and 7 group by a) +(select a from cte where exists( select a from t1 where cte.a=t1.a )) +union +(select a from t1 where a < 2); +a +7 +5 +4 +1 +prepare stmt from "with cte as +(select a from t1 where a between 4 and 7 group by a) +(select a from cte where exists( select a from t1 where cte.a=t1.a )) +union +(select a from t1 where a < 2)"; +execute stmt; +a +7 +5 +4 +1 +execute stmt; +a +7 +5 +4 +1 +deallocate prepare stmt; +with cte as +(select a from t1 where a between 4 and 7 group by a) +(select a from t1 where a < 2) +union +(select a from cte where exists( select a from t1 where cte.a=t1.a )); +a +1 +7 +5 +4 +prepare stmt from "with cte as +(select a from t1 where a between 4 and 7 group by a) +(select a from t1 where a < 2) +union +(select a from cte where exists( select a from t1 where cte.a=t1.a ))"; +execute stmt; +a +1 +7 +5 +4 +execute stmt; +a +1 +7 +5 +4 +deallocate prepare stmt; +with cte as +(select a from t1 where a between 4 and 7) +(select a from t1 where a < 2) +union +(select a from cte where exists( select a from t1 where cte.a=t1.a )); +a +1 +7 +5 +4 +prepare stmt from "with cte as +(select a from t1 where a between 4 and 7) +(select a from t1 where a < 2) +union +(select a from cte where exists( select a from t1 where cte.a=t1.a ))"; +execute stmt; +a +1 +7 +5 +4 +execute stmt; +a +1 +7 +5 +4 +deallocate prepare stmt; +with cte as +(select a from t1 where a between 4 and 7) +(select a from cte +where exists( select a from t1 where t1.a < 2 and cte.a=t1.a )) +union +(select a from cte where exists( select a from t1 where cte.a=t1.a )); +a +7 +5 +4 +prepare stmt from "with cte as +(select a from t1 where a between 4 and 7) +(select a from cte +where exists( select a from t1 where t1.a < 2 and cte.a=t1.a )) +union +(select a from cte where exists( select a from t1 where cte.a=t1.a ))"; +execute stmt; +a +7 +5 +4 +execute stmt; +a +7 +5 +4 +deallocate prepare stmt; +drop table t1; diff --git a/mysql-test/t/cte_nonrecursive.test b/mysql-test/t/cte_nonrecursive.test index 742e8f6e4d7..1f21dbcd36d 100644 --- a/mysql-test/t/cte_nonrecursive.test +++ b/mysql-test/t/cte_nonrecursive.test @@ -790,3 +790,66 @@ SHOW CREATE VIEW cte_test; SELECT * FROM cte_test; DROP VIEW cte_test; + +--echo # +--echo # mdev-14755 : PS for query using CTE in select with subquery +--echo # + +create table t1 (a int); +insert into t1 values + (7), (2), (8), (1), (3), (2), (7), (5), (4), (7), (9), (8); + +let $q1= +with cte as +(select a from t1 where a between 4 and 7 group by a) +(select a from cte where exists( select a from t1 where cte.a=t1.a )) +union +(select a from t1 where a < 2); + +eval $q1; +eval prepare stmt from "$q1"; +execute stmt; +execute stmt; +deallocate prepare stmt; + +let $q2= +with cte as +(select a from t1 where a between 4 and 7 group by a) +(select a from t1 where a < 2) +union +(select a from cte where exists( select a from t1 where cte.a=t1.a )); + +eval $q2; +eval prepare stmt from "$q2"; +execute stmt; +execute stmt; +deallocate prepare stmt; + +let $q3= +with cte as +(select a from t1 where a between 4 and 7) +(select a from t1 where a < 2) +union +(select a from cte where exists( select a from t1 where cte.a=t1.a )); + +eval $q3; +eval prepare stmt from "$q3"; +execute stmt; +execute stmt; +deallocate prepare stmt; + +let $q4= +with cte as +(select a from t1 where a between 4 and 7) +(select a from cte + where exists( select a from t1 where t1.a < 2 and cte.a=t1.a )) +union +(select a from cte where exists( select a from t1 where cte.a=t1.a )); + +eval $q4; +eval prepare stmt from "$q4"; +execute stmt; +execute stmt; +deallocate prepare stmt; + +drop table t1; diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index d086f36a74b..69931643c7f 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -2320,10 +2320,8 @@ void st_select_lex_node::move_as_slave(st_select_lex_node *new_master) prev= &curr->next; } else - { prev= &new_master->slave; - new_master->slave= this; - } + *prev= this; next= 0; master= new_master; } From 7e4c185c774cabaa1912760e143d9385ce959eea Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 13 Sep 2017 21:02:44 +0200 Subject: [PATCH 56/69] MDEV-14272 Mariadb crashes with signal 11 when using federatedx engine and galera cherry-pick e6ce97a5928 --- .../federated/net_thd_crash-12951.result | 11 +++++++++ .../suite/federated/net_thd_crash-12951.test | 23 +++++++++++++++++++ storage/federated/ha_federated.cc | 9 ++++++-- 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 mysql-test/suite/federated/net_thd_crash-12951.result create mode 100644 mysql-test/suite/federated/net_thd_crash-12951.test diff --git a/mysql-test/suite/federated/net_thd_crash-12951.result b/mysql-test/suite/federated/net_thd_crash-12951.result new file mode 100644 index 00000000000..573ac96efff --- /dev/null +++ b/mysql-test/suite/federated/net_thd_crash-12951.result @@ -0,0 +1,11 @@ +set global query_cache_size= 16*1024*1024; +set global query_cache_type= 1; +create table t1 (i int) engine=innodb; +create table t2 (i int) engine=federated +CONNECTION="mysql://root@localhost:MASTER_MYPORT/test/t1"; +select * from t2; +i +drop table t2; +drop table t1; +set global query_cache_type= default; +set global query_cache_size= default; diff --git a/mysql-test/suite/federated/net_thd_crash-12951.test b/mysql-test/suite/federated/net_thd_crash-12951.test new file mode 100644 index 00000000000..81cd826686e --- /dev/null +++ b/mysql-test/suite/federated/net_thd_crash-12951.test @@ -0,0 +1,23 @@ +# +# MDEV-12951 Server crash [mysqld got exception 0xc0000005] +# + +--source include/have_innodb.inc + +set global query_cache_size= 16*1024*1024; +set global query_cache_type= 1; + +create table t1 (i int) engine=innodb; +--replace_result $MASTER_MYPORT MASTER_MYPORT +eval create table t2 (i int) engine=federated + CONNECTION="mysql://root@localhost:$MASTER_MYPORT/test/t1"; + +select * from t2; + +source include/restart_mysqld.inc; + +drop table t2; +drop table t1; + +set global query_cache_type= default; +set global query_cache_size= default; diff --git a/storage/federated/ha_federated.cc b/storage/federated/ha_federated.cc index 85e41554efc..0e84546764d 100644 --- a/storage/federated/ha_federated.cc +++ b/storage/federated/ha_federated.cc @@ -2982,6 +2982,9 @@ int ha_federated::reset(void) } reset_dynamic(&results); + if (mysql) + mysql->net.thd= NULL; + return 0; } @@ -3202,11 +3205,13 @@ int ha_federated::real_query(const char *query, size_t length) int rc= 0; DBUG_ENTER("ha_federated::real_query"); + if (!query || !length) + goto end; + if (!mysql && (rc= real_connect())) goto end; - if (!query || !length) - goto end; + mysql->net.thd= table->in_use; rc= mysql_real_query(mysql, query, (uint) length); From 14de2ad3cb4e1f8f48b83d5e9aafa4e3a366d152 Mon Sep 17 00:00:00 2001 From: Monty Date: Thu, 28 Dec 2017 11:47:03 +0200 Subject: [PATCH 57/69] Removed curr_bitmap_pos++ from possible macro --- storage/rocksdb/rdb_datadic.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/storage/rocksdb/rdb_datadic.cc b/storage/rocksdb/rdb_datadic.cc index df743ff0c48..f6f1406e80c 100644 --- a/storage/rocksdb/rdb_datadic.cc +++ b/storage/rocksdb/rdb_datadic.cc @@ -1461,7 +1461,8 @@ int Rdb_key_def::unpack_record(TABLE *const table, uchar *const buf, if (has_covered_bitmap && field->real_type() == MYSQL_TYPE_VARCHAR && !m_pack_info[i].m_covered) { covered_column = curr_bitmap_pos < MAX_REF_PARTS && - bitmap_is_set(&covered_bitmap, curr_bitmap_pos++); + bitmap_is_set(&covered_bitmap, curr_bitmap_pos); + curr_bitmap_pos++; } if (fpi->m_unpack_func && covered_column) { /* It is possible to unpack this column. Do it. */ From 1a9728d90131997d838e981bb4188f152c5df6e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicen=C8=9Biu=20Ciorbaru?= Date: Thu, 28 Dec 2017 19:27:07 +0200 Subject: [PATCH 58/69] Update Connector/C --- libmariadb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmariadb b/libmariadb index 63f841f78f5..fe129ed39f3 160000 --- a/libmariadb +++ b/libmariadb @@ -1 +1 @@ -Subproject commit 63f841f78f520d7f3bcff1fe8cecec9d8c47829d +Subproject commit fe129ed39f33ba2b430aac91473baee84de88b12 From 8e9d8ffd1a215d4c2bf1cdeb24c112bef2ff58dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicen=C8=9Biu=20Ciorbaru?= Date: Thu, 28 Dec 2017 19:49:58 +0200 Subject: [PATCH 59/69] Update main.innodb test result post-merge --- mysql-test/suite/innodb/r/innodb.result | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mysql-test/suite/innodb/r/innodb.result b/mysql-test/suite/innodb/r/innodb.result index d44dfa3f9ee..6d635fbcdc0 100644 --- a/mysql-test/suite/innodb/r/innodb.result +++ b/mysql-test/suite/innodb/r/innodb.result @@ -3359,7 +3359,7 @@ CREATE TEMPORARY TABLE t2 (c1 INT) ENGINE=InnoDB; START TRANSACTION READ ONLY; INSERT INTO t2 VALUES(0); INSERT INTO t1 VALUES(0); -ERROR 25006: Cannot execute statement in a READ ONLY transaction. +ERROR 25006: Cannot execute statement in a READ ONLY transaction ROLLBACK; SELECT * FROM t1; c1 @@ -3367,14 +3367,14 @@ SELECT * FROM t2; c1 START TRANSACTION READ ONLY; INSERT INTO t1 VALUES(0); -ERROR 25006: Cannot execute statement in a READ ONLY transaction. +ERROR 25006: Cannot execute statement in a READ ONLY transaction INSERT INTO t2 VALUES(1); COMMIT; SET TRANSACTION READ ONLY; START TRANSACTION; INSERT INTO t2 VALUES(3); INSERT INTO t1 VALUES(0); -ERROR 25006: Cannot execute statement in a READ ONLY transaction. +ERROR 25006: Cannot execute statement in a READ ONLY transaction COMMIT; SELECT * FROM t1; c1 @@ -3397,7 +3397,7 @@ t2 CREATE TEMPORARY TABLE `t2` ( START TRANSACTION READ ONLY; INSERT INTO t2 VALUES(NULL,1),(NULL,2),(NULL,3); INSERT INTO t1 VALUES(0); -ERROR 25006: Cannot execute statement in a READ ONLY transaction. +ERROR 25006: Cannot execute statement in a READ ONLY transaction ROLLBACK; SELECT * FROM t1; c1 @@ -3405,14 +3405,14 @@ SELECT * FROM t2; c1 c2 START TRANSACTION READ ONLY; INSERT INTO t1 VALUES(0); -ERROR 25006: Cannot execute statement in a READ ONLY transaction. +ERROR 25006: Cannot execute statement in a READ ONLY transaction INSERT INTO t2 VALUES(NULL,1),(NULL,2),(NULL,3); COMMIT; SET TRANSACTION READ ONLY; START TRANSACTION; INSERT INTO t2 VALUES(NULL,1),(NULL,2),(NULL,3); INSERT INTO t1 VALUES(0); -ERROR 25006: Cannot execute statement in a READ ONLY transaction. +ERROR 25006: Cannot execute statement in a READ ONLY transaction COMMIT; SHOW CREATE TABLE t2; Table Create Table From 6c4cf79d9497c1d9c7e1af9aaf66ac18a08cdebe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicen=C8=9Biu=20Ciorbaru?= Date: Thu, 28 Dec 2017 19:29:40 +0200 Subject: [PATCH 60/69] MDEV-13683: crash in Item_window_func::update_used_tables Window definitions are resolved during fix fields. Updating used tables for window functions must be done after all window functions have had a chance to be resolved. There was an additional problem with the implementation: expressions that contained window functions never updated the expression's used tables. To fix both these issues, make sure to call "update_used_tables" on all items that contain window functions after we have passed through all items. --- sql/sql_select.cc | 16 ++++++++++++++++ sql/sql_window.cc | 7 ------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 676b26e7db0..25b64caa530 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -859,6 +859,22 @@ JOIN::prepare(TABLE_LIST *tables_init, } } + /* + After setting up window functions, we may have discovered additional + used tables from the PARTITION BY and ORDER BY list. Update all items + that contain window functions. + */ + if (select_lex->have_window_funcs()) + { + List_iterator_fast it(select_lex->item_list); + Item *item; + while ((item= it++)) + { + if (item->with_window_func) + item->update_used_tables(); + } + } + With_clause *with_clause=select_lex->get_with_clause(); if (with_clause && with_clause->prepare_unreferenced_elements(thd)) DBUG_RETURN(1); diff --git a/sql/sql_window.cc b/sql/sql_window.cc index 7ae967d7077..4e1e64365ae 100644 --- a/sql/sql_window.cc +++ b/sql/sql_window.cc @@ -297,13 +297,6 @@ setup_windows(THD *thd, Ref_ptr_array ref_pointer_array, TABLE_LIST *tables, } } - List_iterator_fast li(win_funcs); - Item_window_func *win_func_item; - while ((win_func_item= li++)) - { - win_func_item->update_used_tables(); - } - DBUG_RETURN(0); } From 24774fba657077e867b6cd030cf213e6d9d76b79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicen=C8=9Biu=20Ciorbaru?= Date: Fri, 29 Dec 2017 09:33:30 +0200 Subject: [PATCH 61/69] Update galera_gtid_slave result file post merge --- mysql-test/suite/galera/r/galera_gtid_slave.result | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mysql-test/suite/galera/r/galera_gtid_slave.result b/mysql-test/suite/galera/r/galera_gtid_slave.result index 40f3f1c0d53..0b6306bdc6a 100644 --- a/mysql-test/suite/galera/r/galera_gtid_slave.result +++ b/mysql-test/suite/galera/r/galera_gtid_slave.result @@ -1,4 +1,7 @@ +connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2; +connection node_2; START SLAVE; +connection node_1; CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; CREATE TABLE t2 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; INSERT INTO t1 VALUES(1); @@ -9,18 +12,25 @@ commit; SELECT @@global.gtid_binlog_state; @@global.gtid_binlog_state 1-1-4 +connection node_2; INSERT INTO t1 VALUES(2); INSERT INTO t1 VALUES(3); SELECT @@global.gtid_binlog_state; @@global.gtid_binlog_state 1-1-4,2-2-2 +connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3; INSERT INTO t1 VALUES(4); SELECT @@global.gtid_binlog_state; @@global.gtid_binlog_state 1-1-4,2-2-2,2-3-3 +connection node_1; DROP TABLE t1,t2; reset master; +connection node_2; +connection node_3; +connection node_2; STOP SLAVE; RESET SLAVE ALL; reset master; +connection node_3; reset master; From f5c479565d1d07662f23f0a688add6dffeee5f84 Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Tue, 26 Dec 2017 14:38:45 +0400 Subject: [PATCH 62/69] MDEV-11071 - Assertion `thd->transaction.stmt.is_empty()' failed in Locked_tables_list::unlock_locked_tables Similarly to regular DROP TABLE, don't leave locked tables mode if CREATE OR REPLACE dropped temporary table but failed to cerate new one. The problem is that there's no track of which temporary table was "locked" by LOCK TABLES. --- mysql-test/r/create_or_replace.result | 20 ++++++++++++++++++++ mysql-test/t/create_or_replace.test | 24 ++++++++++++++++++++++++ sql/sql_table.cc | 2 +- 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/create_or_replace.result b/mysql-test/r/create_or_replace.result index 3d9b29ffe27..e26884f1cbf 100644 --- a/mysql-test/r/create_or_replace.result +++ b/mysql-test/r/create_or_replace.result @@ -458,3 +458,23 @@ CREATE OR REPLACE TABLE t1 AS SELECT f1(); UNLOCK TABLES; DROP FUNCTION f1; DROP TABLE t1; +# +# MDEV-11071 - Assertion `thd->transaction.stmt.is_empty()' failed in +# Locked_tables_list::unlock_locked_tables +# +CREATE TEMPORARY TABLE t1(a INT) ENGINE=InnoDB; +CREATE TEMPORARY TABLE t2(a INT); +CREATE TABLE t3(a INT); +LOCK TABLE t2 WRITE; +SELECT * FROM t2; +a +CREATE OR REPLACE TEMPORARY TABLE t1(a INT) ENGINE=InnoDB ROW_FORMAT=COMPRESSED; +ERROR HY000: CREATE TEMPORARY TABLE is not allowed with ROW_FORMAT=COMPRESSED or KEY_BLOCK_SIZE. +SELECT * FROM t3; +ERROR HY000: Table 't3' was not locked with LOCK TABLES +CREATE OR REPLACE TEMPORARY TABLE t2(a INT) ENGINE=InnoDB ROW_FORMAT=COMPRESSED; +ERROR HY000: CREATE TEMPORARY TABLE is not allowed with ROW_FORMAT=COMPRESSED or KEY_BLOCK_SIZE. +SELECT * FROM t3; +ERROR HY000: Table 't3' was not locked with LOCK TABLES +UNLOCK TABLES; +DROP TABLE t3; diff --git a/mysql-test/t/create_or_replace.test b/mysql-test/t/create_or_replace.test index abf470b62d5..4ef4189694b 100644 --- a/mysql-test/t/create_or_replace.test +++ b/mysql-test/t/create_or_replace.test @@ -396,3 +396,27 @@ CREATE OR REPLACE TABLE t1 AS SELECT f1(); UNLOCK TABLES; DROP FUNCTION f1; DROP TABLE t1; + +--echo # +--echo # MDEV-11071 - Assertion `thd->transaction.stmt.is_empty()' failed in +--echo # Locked_tables_list::unlock_locked_tables +--echo # +CREATE TEMPORARY TABLE t1(a INT) ENGINE=InnoDB; +CREATE TEMPORARY TABLE t2(a INT); +CREATE TABLE t3(a INT); +LOCK TABLE t2 WRITE; +SELECT * FROM t2; +# drops t2 +--error ER_UNSUPPORT_COMPRESSED_TEMPORARY_TABLE +CREATE OR REPLACE TEMPORARY TABLE t1(a INT) ENGINE=InnoDB ROW_FORMAT=COMPRESSED; +# make sure we didn't leave locked tables mode +--error ER_TABLE_NOT_LOCKED +SELECT * FROM t3; +# drops t1 +--error ER_UNSUPPORT_COMPRESSED_TEMPORARY_TABLE +CREATE OR REPLACE TEMPORARY TABLE t2(a INT) ENGINE=InnoDB ROW_FORMAT=COMPRESSED; +# make sure we didn't leave locked tables mode +--error ER_TABLE_NOT_LOCKED +SELECT * FROM t3; +UNLOCK TABLES; +DROP TABLE t3; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index bc877613190..ea06beeb560 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -5111,7 +5111,7 @@ err: /* Write log if no error or if we already deleted a table */ if (!result || thd->log_current_statement) { - if (result && create_info->table_was_deleted) + if (result && create_info->table_was_deleted && pos_in_locked_tables) { /* Possible locked table was dropped. We should remove meta data locks From 8bcbcac053b96a39465e4651f51e625c37f94964 Mon Sep 17 00:00:00 2001 From: Elena Stepanova Date: Fri, 29 Dec 2017 17:25:21 +0200 Subject: [PATCH 63/69] Updated list of unstable tests for 10.2.12 --- mysql-test/unstable-tests | 219 +++++++++++++++++--------------------- 1 file changed, 96 insertions(+), 123 deletions(-) diff --git a/mysql-test/unstable-tests b/mysql-test/unstable-tests index 36ee91694a4..dff89fdf60d 100644 --- a/mysql-test/unstable-tests +++ b/mysql-test/unstable-tests @@ -23,56 +23,55 @@ # ############################################################################## -# Based on 10.2 e2dd4e32063b2526d951e5f4ddfdb8b0d69ef634 +# Based on 10.2 f5c479565d1d07662f23f0a688add6dffeee5f84 -main.alter_table : Modified in 10.2.10 main.analyze_stmt_slow_query_log : MDEV-12237 - Wrong result -main.case : Modified in 10.2.10 +main.auth_named_pipe : MDEV-14724 - System error 2 main.connect2 : MDEV-13885 - Server crash +main.create_or_replace : Modified in 10.2.12 main.cte_grant : Modified in 10.2.11 -main.cte_nonrecursive : Modified in 10.2.11 -main.cte_recursive : Modified in 10.2.11 -main.ctype_gbk : Modified in 10.2.10 -main.ctype_latin1 : Modified in 10.2.10 -main.ctype_ucs : Modified in 10.2.10 -main.ctype_utf32 : Modified in 10.2.10 -main.ctype_utf8 : Modified in 10.2.10 -main.delete_returning : Modified in 10.2.10 +main.cte_nonrecursive : Modified in 10.2.12 +main.cte_recursive : Modified in 10.2.12 +main.ctype_latin1 : Modified in 10.2.12 +main.ctype_like_range : Modified in 10.2.12 +main.ctype_ucs2_uca : Modified in 10.2.12 +main.ctype_utf16_uca : Modified in 10.2.12 +main.ctype_utf32_uca : Modified in 10.2.12 +main.ctype_utf8 : Modified in 10.2.12 +main.ctype_utf8_uca : Modified in 10.2.12 +main.ctype_utf8mb4 : Modified in 10.2.12 +main.ctype_utf8mb4_uca : Modified in 10.2.12 main.delimiter_command_case_sensitivity : Added in 10.2.11 main.derived_cond_pushdown : Modified in 10.2.11 main.distinct : MDEV-14194 - Crash main.events_2 : MDEV-13277 - Crash -main.func_in : Modified in 10.2.10 -main.func_json : MDEV-11648 - Crash, valgrind; modified in 10.2.11 -main.func_misc : Modified in 10.2.11 -main.func_regexp_pcre : Modified in 10.2.10 -main.func_time : Modified in 10.2.10 +main.events_slowlog : MDEV-12821 - Wrong result +main.func_json : Modified in 10.2.12 +main.func_misc : Modified in 10.2.12 +main.func_set : Modified in 10.2.12 +main.func_str : Modified in 10.2.12 main.gis-json : Modified in 10.2.11 -main.gis-precise : Modified in 10.2.10 -main.gis2 : Modified in 10.2.10 -main.having : Modified in 10.2.11 +main.group_by : Modified in 10.2.12 +main.having : Modified in 10.2.12 main.index_merge_innodb : MDEV-7142 - Plan mismatch -main.information_schema : Modified in 10.2.10 main.innodb_mysql_lock : MDEV-7861 - Wrong result +main.join_outer : Modified in 10.2.12 main.kill-2 : MDEV-13257 - Wrong result main.log_slow : MDEV-13263 - Wrong result -main.mdev13607 : Added in 10.2.10 -main.myisam : Modified in 10.2.10 main.mysql_client_test_nonblock : CONC-208 - Error on Power main.mysql_upgrade_noengine : MDEV-14355 - Wrong result main.mysql_upgrade_ssl : MDEV-13492 - Unknown SSL error main.mysqlbinlog : Modified in 10.2.11 +main.mysqldump : MDEV-14800 - Stack smashing detected main.mysqld_option_err : MDEV-12747 - Timeout main.mysqlhotcopy_myisam : MDEV-10995 - Hang on debug main.mysqltest : MDEV-13887 - Wrong result main.openssl_1 : MDEV-13492 - Unknown SSL error main.order_by : Modified in 10.2.11 main.order_by_innodb : Modified in 10.2.11 -main.partition_datatype : Modified in 10.2.10 -main.ps : Modified in 10.2.11 -main.range_vs_index_merge : Modified in 10.2.10 +main.ps : MDEV-11017 - Wrong result; modified in 10.2.12 main.shm : MDEV-12727 - Mismatch, ERROR 2013 -main.show_function_with_pad_char_to_full_length : Added in 10.2.10 +main.show_explain : MDEV-10674 - Wrong result code main.sp : MDEV-7866 - Mismatch; modified in 10.2.11 main.ssl_ca : MDEV-10895 - SSL connection error on Power main.ssl_cert_verify : MDEV-13735 - Server crash @@ -81,21 +80,18 @@ main.ssl_timeout : MDEV-11244 - Crash main.stat_tables_par : MDEV-13266 - Wrong result main.status : MDEV-13255 - Wrong result main.subselect_exists2in : Modified in 10.2.11 -main.subselect_mat_cost_bugs : Modified in 10.2.10 -main.tc_heuristic_recover : MDEV-14189 - Wrong result; modified in 10.2.10 +main.subselect_innodb : MDEV-10614 - Wrong result +main.tc_heuristic_recover : MDEV-14189 - Wrong result main.trigger : Modified in 10.2.11 main.type_bit : Modified in 10.2.11 main.type_date : Modified in 10.2.11 -main.type_float : Modified in 10.2.10 main.type_time : Modified in 10.2.11 -main.type_varchar : Modified in 10.2.10 -main.user_var : Modified in 10.2.10 main.userstat : MDEV-12904 - SSL errors -main.xml : Modified in 10.2.10 +main.view : Modified in 10.2.12 +main.win : Modified in 10.2.12 #---------------------------------------------------------------- -archive.archive-big : MDEV-10615 - Table marked as crashed archive.mysqlhotcopy_archive : MDEV-10995 - Hang on debug #---------------------------------------------------------------- @@ -117,15 +113,11 @@ binlog_encryption.rpl_semi_sync : MDEV-11673 - Valgrind binlog_encryption.rpl_skip_replication : MDEV-13571 - Unexpected warning binlog_encryption.rpl_ssl : MDEV-14507 - Timeouts binlog_encryption.rpl_stm_relay_ign_space : MDEV-13278 - Wrong result (test assertion) +binlog_encryption.rpl_sync : MDEV-13830 - Assertion failure #---------------------------------------------------------------- -connect.json_java_2 : Include file modified in 10.2.10 -connect.json_java_3 : Include file modified in 10.2.10 -connect.json_mongo_c : Include file modified in 10.2.10 -connect.mongo_c : Include file modified in 10.2.10 -connect.mongo_java_2 : Include file modified in 10.2.10 -connect.mongo_java_3 : Include file modified in 10.2.10 +connect.pivot : MDEV-14803 - Failed to discover table connect.tbl : MDEV-10179 - Mismatch, MDEV-9844 - Valgrind, crash connect.tbl_thread : MDEV-10179 - Mismatch, MDEV-9844 - Valgrind, crash, MDEV-14214 - Syntax error connect.vcol : MDEV-12374 - Fails on Windows @@ -139,13 +131,16 @@ encryption.encryption_force : Modified in 10.2.11 encryption.filekeys_encfile : Modified in 10.2.11 encryption.filekeys_encfile_file : Modified in 10.2.11 encryption.innochecksum : MDEV-13644 - Assertion failure +encryption.innodb-compressed-blob : MDEV-14728 - Unable to get certificate encryption.innodb-discard-import-change : MDEV-12632 - Valgrind encryption.innodb-encryption-alter : MDEV-13566 - Lock wait timeout; modified in 10.2.11 encryption.innodb_encryption_discard_import : MDEV-12903 - Wrong result, MDEV-14045 - Error 192 encryption.innodb_encryption_filekeys : MDEV-9962 - Timeout +encryption.innodb_encryption-page-compression : MDEV-14814 - Timeout in wait condition encryption.innodb_encryption_tables : MDEV-9359 - Assertion failure encryption.innodb-first-page-read : MDEV-14356 - Timeout in wait condition encryption.innodb_lotoftables : MDEV-11531 - Operation on a dropped tablespace +encryption.innodb-missing-key : MDEV-9359 - assertion failure encryption.innodb-redo-badkey : MDEV-13893 - Page cannot be decrypted encryption.innodb-spatial-index : MDEV-13746 - Wrong result; modified in 10.2.11 @@ -155,6 +150,7 @@ engines/rr_trx.* : MDEV-10998 - Not maintained #---------------------------------------------------------------- +federated.federated_bug_585688 : MDEV-14805 - Server crash, MDEV-12907 - Valgrind federated.federated_innodb : MDEV-10617 - Wrong checksum federated.federated_transactions : MDEV-10617 - Wrong checksum federated.federatedx : MDEV-10617 - Wrong checksum @@ -174,23 +170,18 @@ gcol.innodb_virtual_basic : Modified in 10.2.11 gcol.innodb_virtual_debug : Modified in 10.2.11 gcol.innodb_virtual_debug_purge : MDEV-13568 - Wrong result gcol.innodb_virtual_rebuild : Added in 10.2.11 +gcol.innodb_virtual_stats : Added in 10.2.12 #---------------------------------------------------------------- innodb.101_compatibility : MDEV-13891 - Wrong result -innodb.alter_table : Modified in 10.2.10 innodb.deadlock_detect : MDEV-13262 - Wrong error code -innodb.defrag_mdl-9155 : Re-enabled in 10.2.10 -innodb_defragment_fill_factor : Re-enabled in 10.2.10 innodb.doublewrite : MDEV-12905 - Server crash innodb.group_commit_crash : MDEV-14191 - InnoDB registration failed innodb.group_commit_crash_no_optimize_thread : MDEV-13830 - Assertion failure -innodb.innodb-16k : Modified in 10.2.10 -innodb.innodb-32k : Modified in 10.2.10 -innodb.innodb-64k : Modified in 10.2.10 -innodb.innodb-alter : Modified in 10.2.10 -innodb.innodb-alter-table : Modified in 10.2.10 +innodb.innodb : Modified in 10.2.12 innodb.innodb-alter-tempfile : MDEV-14485 - Server deadlock on startup +innodb.innodb-autoinc : Modified in 10.2.12 innodb.innodb_bug14147491 : MDEV-11808 - Index is corrupt innodb.innodb_bug59641 : MDEV-13830 - Assertion failure innodb.innodb_bulk_create_index : Added in 10.2.11 @@ -198,94 +189,58 @@ innodb.innodb_bulk_create_index_debug : Added in 10.2.11 innodb.innodb_bulk_create_index_flush : Added in 10.2.11 innodb.innodb_bulk_create_index_replication : Added in 10.2.11 innodb.innodb_bulk_create_index_small : Added in 10.2.11 -innodb.innodb_defrag_binlog : Re-enabled in 10.2.10 -innodb.innodb_defrag_concurrent : Re-enabled in 10.2.10 -innodb.innodb_defrag_stats : Re-enabled in 10.2.10 -innodb.innodb_defrag_stats_many_tables : MDEV-14198 - Table is full; re-enabled in 10.2.10 -innodb.innodb_defragment : Re-enabled in 10.2.10 -innodb.innodb_defragment_fill_factor : Re-enabled in 10.2.10 -innodb.innodb_defragment_small : Re-enabled in 10.2.10 -innodb.innodb-get-fk : MDEV-13276 - Server crash; modified in 10.2.10 +innodb.innodb_defrag_stats_many_tables : MDEV-14198 - Table is full +innodb.innodb-get-fk : MDEV-13276 - Server crash +innodb.innodb-index-debug : Modified in 10.2.12 +innodb.innodb-index-online : MDEV-14809 - Cannot save statistics innodb.innodb_information_schema : MDEV-8851 - Wrong result +innodb.innodb_max_recordsize_32k : MDEV-14801 - Operation failed; modified in 10.2.12 +innodb.innodb_max_recordsize_64k : Modified in 10.2.12 innodb.innodb-on-duplicate-update : Added in 10.2.11 -innodb.innodb-online-alter-gis : Modified in 10.2.10 innodb.innodb-page_compression_default : MDEV-13644 - Assertion failure innodb.innodb-page_compression_lzma : MDEV-14353 - Wrong result innodb.innodb-page_compression_tables : Modified in 10.2.11 innodb.innodb-replace-debug : Added in 10.2.11 +innodb.innodb_stats_debug : Modified in 10.2.12 +innodb.innodb_stats_drop_locked : Modified in 10.2.12 +innodb.innodb_stats_persistent_debug : MDEV-14801 - Operation failed innodb.innodb-table-online : MDEV-13894 - Wrong result; modified in 10.2.11 -innodb.innodb-truncate : Modified in 10.2.10 innodb.innodb_sys_semaphore_waits : MDEV-10331 - Semaphore wait innodb.innodb-wl5522-debug : MDEV-14200 - Wrong errno -innodb.innodb-wl5980-alter : Modified in 10.2.10 innodb.innodb_zip_innochecksum2 : MDEV-13882 - Extra warnings innodb.innodb_zip_innochecksum3 : MDEV-14486 - Resource temporarily unavailable +innodb.lock_deleted : Added in 10.2.12 innodb.log_corruption : MDEV-13251 - Wrong result innodb.log_data_file_size : MDEV-14204 - Server failed to start innodb.log_file_name : MDEV-14193 - Exception -innodb.log_file_size : Modified in 10.2.10 innodb.purge_thread_shutdown : MDEV-13792 - Wrong result innodb.read_only_recovery : MDEV-13886 - Server crash +innodb.recovery_shutdown : Added in 10.2.12 innodb.row_format_redundant : MDEV-14485 - Server deadlock on startup -innodb.table_definition_cache_debug : MDEV-14206 - Extra warning; added in 10.2.10 +innodb.table_definition_cache_debug : MDEV-14206 - Extra warning; opt file modified in 10.2.12 innodb.table_flags : MDEV-13572 - Wrong result innodb.temporary_table : MDEV-13265 - Wrong result -innodb.truncate_debug : Modified in 10.2.10 -innodb.truncate_restart : Added in 10.2.11 -innodb.undo_log : Added in 10.2.10 -innodb.update_time : Added in 10.2.11 +innodb.truncate_restart : Modified in 10.2.12 +innodb.update_time : MDEV-14804 - Wrong result; modified in 10.2.12 innodb.update_time_wl6658 : Added in 10.2.11 -innodb-wl5980-alter : Re-enabled in 10.2.10 -innodb_fts.concurrent_insert : Added in 10.2.10 -innodb_fts.fulltext : Modified in 10.2.10 +innodb_fts.fulltext2 : MDEV-14727 - Long semaphore wait innodb_fts.fulltext_misc : MDEV-12636 - Valgrind innodb_fts.innodb_fts_plugin : MDEV-13888 - Errors in server log innodb_fts.innodb_fts_stopword_charset : MDEV-13259 - Table crashed -innodb_fts.sync : Added in 10.2.10 -innodb_fts.sync_block : Added in 10.2.10 -innodb_fts.truncate : Added in 10.2.10 +innodb_fts.sync : MDEV-14808 - Wrong result -innodb_gis.alter_spatial_index : Modified in 10.2.10 -innodb_gis.bug16236208 : Added in 10.2.10 -innodb_gis.bug16266012 : Added in 10.2.10 -innodb_gis.bug17057168 : Added in 10.2.10 -innodb_gis.geometry : Added in 10.2.10 -innodb_gis.gis_split_inf : Added in 10.2.10 -innodb_gis.gis_split_nan : Added in 10.2.10 -innodb_gis.kill_server : MDEV-14218 - Assertion failure; added in 10.2.10 -innodb_gis.multi_pk : Added in 10.2.10 -innodb_gis.point_basic : Added in 10.2.10 -innodb_gis.point_big : Added in 10.2.10 -innodb_gis.repeatable_spatial : Added in 10.2.10 -innodb_gis.rollback : Added in 10.2.10 -innodb_gis.row_format : Added in 10.2.10 -innodb_gis.rtree_compress : MDEV-14207 - Missing include; added in 10.2.10 -innodb_gis.rtree_compress2 : MDEV-14207 - Missing include; added in 10.2.10 -innodb_gis.rtree_concurrent_srch : Added in 10.2.10 -innodb_gis.rtree_create_inplace : Added in 10.2.10 -innodb_gis.rtree_debug : MDEV-14209 - Huge error log; added in 10.2.10 -innodb_gis.rtree_drop_index : Added in 10.2.10 -innodb_gis.rtree_estimate : Added in 10.2.10 -innodb_gis.rtree_multi_pk : Added in 10.2.10 -innodb_gis.rtree_old : Added in 10.2.10 -innodb_gis.rtree_purge : MDEV-14207 - Missing include; added in 10.2.10 -innodb_gis.rtree_recovery : Added in 10.2.10 -innodb_gis.rtree_rollback1 : Added in 10.2.10 -innodb_gis.rtree_rollback2 : Added in 10.2.10 -innodb_gis.rtree_search : Added in 10.2.10 -innodb_gis.rtree_split : MDEV-14208 - Too many arguments; MDEV-14209 - Huge error log; added in 10.2.10 -innodb_gis.rtree_undo : Added in 10.2.10 -innodb_gis.types : Added in 10.2.10 -innodb_gis.update_root : Added in 10.2.10 - -innodb_zip.16k : Modified in 10.2.10 -innodb_zip.4k : Modified in 10.2.10 -innodb_zip.8k : Modified in 10.2.10 +innodb_gis.kill_server : MDEV-14218 - Assertion failure; modified in 10.2.12 +innodb_gis.rtree_compress : MDEV-14207 - Missing include +innodb_gis.rtree_compress2 : MDEV-14207 - Missing include; modified in 10.2.12 +innodb_gis.rtree_debug : MDEV-14209 - Huge error log +innodb_gis.rtree_purge : MDEV-14207 - Missing include +innodb_gis.rtree_recovery : Modified in 10.2.12 +innodb_gis.rtree_split : MDEV-14208 - Too many arguments; MDEV-14209 - Huge error log +innodb_gis.rtree_undo : MDEV-14456 - Timeout in include file +innodb_gis.types : Modified in 10.2.12 innodb_zip.cmp_per_index : MDEV-14490 - Table is marked as crashed innodb_zip.innochecksum_3 : MDEV-13279 - Extra warnings -innodb_zip.index_large_prefix_4k : Modified in 10.2.10 -innodb_zip.index_large_prefix_8k : Modified in 10.2.10 innodb_zip.prefix_index_liftedlimit : MDEV-14238 - Assertion failure innodb_zip.wl6470_1 : MDEV-14240 - Assertion failure innodb_zip.wl6501_1 : MDEV-10891 - Can't create UNIX socket @@ -295,21 +250,22 @@ innodb_zip.wl6501_scale_1 : MDEV-13254 - Timeout, MDEV-14104 - Error #---------------------------------------------------------------- maria.insert_select : MDEV-12757 - Timeout -maria.maria : MDEV-14430 - Extra warning; modified in 10.2.10 +maria.maria : MDEV-14430 - Extra warning #---------------------------------------------------------------- mariabackup.apply-log-only : MDEV-14192 - Assertion failure -mariabackup.apply-log-only-incr : MDEV-14192 - Assertion failure -mariabackup.compress_qpress : Added in 10.2.10 +mariabackup.apply-log-only-incr : MDEV-14192 - Assertion failure; modified in 10.2.12 mariabackup.data_directory : Added in 10.2.11 mariabackup.full_backup : MDEV-13889 - Timeout mariabackup.incremental_backup : MDEV-14192 - Assertion failure; modified in 10.2.11 mariabackup.incremental_encrypted : MDEV-14188 - Wrong result +mariabackup.log_checksum_mismatch : Added in 10.2.12 mariabackup.mdev-14447 : Added in 10.2.11 -mariabackup.partition_datadir : Added in 10.2.11 -mariabackup.xb_file_key_management : Modified in 10.2.10 +mariabackup.partition_datadir : MDEV-14802 - Timeout; added in 10.2.11 mariabackup.xbstream : MDEV-14192 - Crash +mariabackup.xb_page_compress : MDEV-14810 - status: 1, errno: 11 +mariabackup.xb_compressed_encrypted : MDEV-14812 - Segmentation fault #---------------------------------------------------------------- @@ -328,9 +284,11 @@ multi_source.simple : MDEV-4633 - Wrong result #---------------------------------------------------------------- -parts.partition_alter_maria : Added in 10.2.10 +parts.partition_alter_innodb : Added in 10.2.12 +parts.partition_alter_maria : Modified in 10.2.12 +parts.partition_alter_myisam : Added in 10.2.12 parts.partition_auto_increment_maria : MDEV-14430 - Extra warning -parts.partition_debug_innodb : MDEV-10891 - Can't create UNIX socket +parts.partition_debug_innodb : MDEV-10891 - Can't create UNIX socket #---------------------------------------------------------------- @@ -345,8 +303,11 @@ 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.misc : Modified in 10.2.12 perfschema.setup_actors : MDEV-10679 - Crash +perfschema.socket_summary_by_event_name_func : MDEV-10622 - Wrong result perfschema.stage_mdl_procedure : MDEV-11545 - Missing row +perfschema.threads_mysql : MDEV-10677 - Wrong result #---------------------------------------------------------------- @@ -354,6 +315,7 @@ perfschema_stress.* : MDEV-10996 - Not maintained #---------------------------------------------------------------- +plugins.binlog-simple_plugin_check : Added in 10.2.12 plugins.feedback_plugin_send : MDEV-7932, MDEV-11118 - Connection problems and such plugins.server_audit : Modified in 10.2.11 plugins.thread_pool_server : Modified in 10.2.11 @@ -365,12 +327,14 @@ rocksdb.* : MyRocks is alpha-quality and tests are uns #---------------------------------------------------------------- -roles.definer : Modified in 10.2.10 +roles.flush_roles-12366 : Added in 10.2.12 +roles.set_role-13655 : Added in 10.2.12 #---------------------------------------------------------------- rpl.rpl_binlog_errors : MDEV-12742 - Crash rpl.rpl_binlog_index : MDEV-9501 - Failed registering on master +rpl.rpl_ctype_latin1 : MDEV-14813 - Wrong result on Mac; added in 10.2.12 rpl.rpl_domain_id_filter_io_crash : MDEV-12729 - Timeout in include file, MDEV-13677 - Server crash rpl.rpl_domain_id_filter_restart : MDEV-10684 - Wrong result rpl.rpl_extra_col_master_myisam : MDEV-14203 - Extra warning @@ -381,6 +345,9 @@ rpl.rpl_gtid_reconnect : MDEV-14497 - Crash rpl.rpl_gtid_stop_start : MDEV-11621 - Table marked as crashed rpl.rpl_manual_change_index_file : MDEV-14309 - Requires Env package rpl.rpl_mariadb_slave_capability : MDEV-11018 - Extra lines in binlog +rpl.rpl_mixed_mixing_engines : MDEV-14489 - Sync slave with master failed +rpl.rpl_non_direct_mixed_mixing_engines : MDEV-14489 - Sync slave with master failed +rpl.rpl_non_direct_row_mixing_engines : MDEV-14491 - Long semaphore wait rpl.rpl_non_direct_stm_mixing_engines : MDEV-14489 - Failed sync_slave_with_master rpl.rpl_parallel : MDEV-12730 - Assertion failure rpl.rpl_parallel_mdev6589 : MDEV-12979 - Assertion failure @@ -388,9 +355,12 @@ rpl.rpl_parallel_optimistic_nobinlog : MDEV-12746 - Timeouts, mismatch rpl.rpl_parallel_retry : MDEV-11119 - Crash rpl.rpl_parallel_temptable : MDEV-10356 - Crash rpl.rpl_row_drop_create_temp_table : MDEV-14487 - Wrong result +rpl.rpl_row_log : Included test modified in 10.2.12 +rpl.rpl_row_log_innodb : Included test modified in 10.2.12 rpl.rpl_row_mixing_engines : MDEV-14491 - Long semaphore wait rpl.rpl_semi_sync : MDEV-11220 - Wrong result rpl.rpl_semi_sync_after_sync : MDEV-14366 - Wrong result +rpl.rpl_semi_sync_after_sync_row : MDEV-14366 - Wrong result rpl.rpl_set_statement_default_master : MDEV-13258 - Extra warning rpl.rpl_show_slave_hosts : MDEV-10681 - Crash rpl.rpl_skip_replication : MDEV-13258 - Extra warning @@ -399,8 +369,11 @@ rpl.rpl_slave_load_tmpdir_not_exist : MDEV-14203 - 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_log : Included test modified in 10.2.12 +rpl.rpl_stm_mixing_engines : MDEV-14489 - Sync slave with master failed rpl.rpl_stm_multi_query : MDEV-9501 - Failed registering on master rpl.rpl_stm_stop_middle_group : MDEV-13791 - Server crash +rpl.rpl_sync : MDEV-13830 - Assertion failure rpl.rpl_temporal_mysql56_to_mariadb53 : MDEV-9501 - Failed registering on master rpl.rpl_upgrade_master_info : MDEV-11620 - Table marked as crashed @@ -427,15 +400,14 @@ storage_engine.* : Not always timely maintained #---------------------------------------------------------------- -sys_vars.explicit_defaults_for_timestamp_on : Include file modified in 10.2.10 -sys_vars.explicit_defaults_for_timestamp_off : Include file modified in 10.2.10 -sys_vars.host_cache_size_auto : Modified in 10.2.10 sys_vars.innodb_buffer_pool_dump_at_shutdown_basic : MDEV-14280 - Unexpected error sys_vars.innodb_buffer_pool_dump_now_basic : Modified in 10.2.11 sys_vars.innodb_buffer_pool_dump_pct_basic : Modified in 10.2.11 sys_vars.innodb_buffer_pool_load_now_basic : Modified in 10.2.11 sys_vars.rpl_init_slave_func : MDEV-10149 - Test assertion sys_vars.slow_query_log_func : MDEV-14273 - Wrong result +sys_vars.thread_cache_size_func : MDEV-11775 - Wrong result +sys_vars.wsrep_on_basic : Opt file added in 10.2.12 #---------------------------------------------------------------- @@ -450,6 +422,9 @@ tokudb.rows-32m-seq-insert : MDEV-12640 - Crash tokudb_mariadb.mdev6657 : MDEV-12737 - Mismatch or valgrind +tokudb-rpl.rpl_tokudb_row_log : Included test modified in 10.2.12 +tokudb-rpl.rpl_tokudb_stm_log : Included test modified in 10.2.12 + tokudb_backup.* : MDEV-11001 - Missing include file tokudb_sys_vars.* : MDEV-11001 - Missing include file tokudb_rpl.* : MDEV-11001 - Missing include file @@ -458,16 +433,14 @@ tokudb_parts.partition_alter4_tokudb : MDEV-12640 - Lost connection #---------------------------------------------------------------- +unit.conc_misc : MDEV-14811 - not ok 12 - test_conc49 unit.conc_ps_bugs : MDEV-13252 - not ok 44 test_bug4236 unit.lf : MDEV-12897 - Signal 11 thrown #---------------------------------------------------------------- -vcol.vcol_misc : Modified in 10.2.10 - -#---------------------------------------------------------------- - wsrep.binlog_format : MDEV-11532 - Could not execute check-testcase +wsrep.foreign_key : MDEV-14725 - WSREP has not yet prepared node wsrep.mdev_6832 : MDEV-14195 - Check testcase failed wsrep.pool_of_threads : MDEV-12234 - GLIBCXX_3.4.20 not found wsrep.variables : MDEV-14311 - Wrong result From a118c20c8151a4e95f133b6d5bf92bafc7835e23 Mon Sep 17 00:00:00 2001 From: Varun Gupta Date: Sat, 30 Dec 2017 10:18:22 +0530 Subject: [PATCH 64/69] MDEV-10844: EXPLAIN FORMAT=JSON doesn't show order direction for filesort Currently explain format=json does not show the order direction of fields used during filesort. This patch would remove this limitation --- mysql-test/r/explain_json.result | 60 ++++++++++++++++++++++++++++++++ mysql-test/r/win.result | 2 +- mysql-test/t/explain_json.test | 11 ++++++ sql/sql_explain.cc | 8 ++++- sql/sql_explain.h | 1 + 5 files changed, 80 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/explain_json.result b/mysql-test/r/explain_json.result index b83334c8b08..db792f4f2b6 100644 --- a/mysql-test/r/explain_json.result +++ b/mysql-test/r/explain_json.result @@ -1582,3 +1582,63 @@ EXPLAIN } } drop table t0,t1; +# +# MDEV-10844: EXPLAIN FORMAT=JSON doesn't show order direction for filesort +# +create table t1 (a int, b int); +insert into t1 values (1,2),(3,4),(2,3); +explain format=json select * from t1 order by a, b desc; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "read_sorted_file": { + "filesort": { + "sort_key": "t1.a, t1.b desc", + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 3, + "filtered": 100 + } + } + } + } +} +explain format=json select * from t1 order by a desc, b desc; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "read_sorted_file": { + "filesort": { + "sort_key": "t1.a desc, t1.b desc", + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 3, + "filtered": 100 + } + } + } + } +} +explain format=json select * from t1 order by a desc, b ; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "read_sorted_file": { + "filesort": { + "sort_key": "t1.a desc, t1.b", + "table": { + "table_name": "t1", + "access_type": "ALL", + "rows": 3, + "filtered": 100 + } + } + } + } +} +drop table t1; diff --git a/mysql-test/r/win.result b/mysql-test/r/win.result index cfe3ebe6a3c..7e0c86b1668 100644 --- a/mysql-test/r/win.result +++ b/mysql-test/r/win.result @@ -1779,7 +1779,7 @@ EXPLAIN "query_block": { "select_id": 1, "filesort": { - "sort_key": "row_number() over ( order by t1.s1,t1.s2)", + "sort_key": "row_number() over ( order by t1.s1,t1.s2) desc", "window_functions_computation": { "sorts": { "filesort": { diff --git a/mysql-test/t/explain_json.test b/mysql-test/t/explain_json.test index d253b8380e9..c3665b1818b 100644 --- a/mysql-test/t/explain_json.test +++ b/mysql-test/t/explain_json.test @@ -406,3 +406,14 @@ explain format=json select a, (select max(a) from t1 where t0.a<5 and t1.border; ord; ord= ord->next) { sort_items.push_back(ord->item[0], mem_root); + sort_directions.push_back(&ord->direction, mem_root); } filesort->tracker= &tracker; } @@ -940,10 +941,13 @@ void Explain_aggr_filesort::print_json_members(Json_writer *writer, str.length(0); List_iterator_fast it(sort_items); - Item *item; + List_iterator_fast it_dir(sort_directions); + Item* item; + ORDER::enum_order *direction; bool first= true; while ((item= it++)) { + direction= it_dir++; if (first) first= false; else @@ -951,6 +955,8 @@ void Explain_aggr_filesort::print_json_members(Json_writer *writer, str.append(", "); } append_item_to_str(&str, item); + if (*direction == ORDER::ORDER_DESC) + str.append(" desc"); } writer->add_member("sort_key").add_str(str.c_ptr_safe()); diff --git a/sql/sql_explain.h b/sql/sql_explain.h index bfddf40ff33..a4698908755 100644 --- a/sql/sql_explain.h +++ b/sql/sql_explain.h @@ -282,6 +282,7 @@ public: class Explain_aggr_filesort : public Explain_aggr_node { List sort_items; + List sort_directions; public: enum_explain_aggr_node_type get_type() { return AGGR_OP_FILESORT; } Filesort_tracker tracker; From 7703095d2e26a15d4ecbd3683f9779b97f851c98 Mon Sep 17 00:00:00 2001 From: Varun Gupta Date: Sun, 31 Dec 2017 16:18:39 +0200 Subject: [PATCH 65/69] MDEV-12458: Variable and log records to indicate RocksDB version are missing Added a system variabe rocsdb_git_hash to MyRocks which tell us the version of RocksDB being used --- cmake/make_dist.cmake.in | 3 +++ storage/rocksdb/CMakeLists.txt | 15 +++++++++++++++ storage/rocksdb/ha_rocksdb.cc | 8 ++++++++ .../rocksdb/mysql-test/rocksdb/r/rocksdb.result | 1 + storage/rocksdb/mysql-test/rocksdb/t/rocksdb.test | 2 ++ .../t/rocksdb_git_hash_basic.test | 6 ++++++ storage/rocksdb/rdb_source_revision.h.in | 1 + 7 files changed, 36 insertions(+) create mode 100644 storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_git_hash_basic.test create mode 100644 storage/rocksdb/rdb_source_revision.h.in diff --git a/cmake/make_dist.cmake.in b/cmake/make_dist.cmake.in index 3cc93d10fb8..2e3dbb987f0 100644 --- a/cmake/make_dist.cmake.in +++ b/cmake/make_dist.cmake.in @@ -52,6 +52,9 @@ IF(GIT_EXECUTABLE) ENDIF() ENDIF() +CONFIGURE_FILE(${CMAKE_BINARY_DIR}/storage/rocksdb/rdb_source_revision.h + ${PACKAGE_DIR}/storage/rocksdb/rdb_source_revision.h COPYONLY) + IF(NOT GIT_EXECUTABLE) MESSAGE(STATUS "git not found or source dir is not a repo, use CPack") diff --git a/storage/rocksdb/CMakeLists.txt b/storage/rocksdb/CMakeLists.txt index 1e20e0fa4a3..6cb7eb1d439 100644 --- a/storage/rocksdb/CMakeLists.txt +++ b/storage/rocksdb/CMakeLists.txt @@ -220,3 +220,18 @@ IF(MSVC) # Some checks in C++ runtime that make debug build much slower ADD_DEFINITIONS(-D_ITERATOR_DEBUG_LEVEL=0) ENDIF() + +IF(GIT_EXECUTABLE) + EXECUTE_PROCESS( + COMMAND ${GIT_EXECUTABLE} rev-parse HEAD + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/rocksdb + OUTPUT_VARIABLE OUT RESULT_VARIABLE RES) + IF(RES EQUAL 0) + STRING(REGEX REPLACE "\n$" "" ROCKSDB_GIT_HASH "${OUT}") + ENDIF() +ENDIF() +IF(ROCKSDB_GIT_HASH OR + (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/rdb_source_revision.h)) + CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/rdb_source_revision.h.in + ${CMAKE_CURRENT_BINARY_DIR}/rdb_source_revision.h ) +ENDIF() diff --git a/storage/rocksdb/ha_rocksdb.cc b/storage/rocksdb/ha_rocksdb.cc index 8857b2e8cba..4a0a3eddb1a 100644 --- a/storage/rocksdb/ha_rocksdb.cc +++ b/storage/rocksdb/ha_rocksdb.cc @@ -70,6 +70,7 @@ #include "rocksdb/utilities/memory_util.h" #include "rocksdb/utilities/sim_cache.h" #include "util/stop_watch.h" +#include "./rdb_source_revision.h" /* MyRocks includes */ #include "./event_listener.h" @@ -494,6 +495,7 @@ static uint32_t rocksdb_table_stats_sampling_pct; static my_bool rocksdb_enable_bulk_load_api = 1; static my_bool rocksdb_print_snapshot_conflict_queries = 0; static my_bool rocksdb_large_prefix = 0; +static char* rocksdb_git_hash; char *compression_types_val= const_cast(get_rocksdb_supported_compression_types()); @@ -650,6 +652,11 @@ static MYSQL_SYSVAR_BOOL(enable_bulk_load_api, rocksdb_enable_bulk_load_api, "Enables using SstFileWriter for bulk loading", nullptr, nullptr, rocksdb_enable_bulk_load_api); +static MYSQL_SYSVAR_STR(git_hash, rocksdb_git_hash, + PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, + "Git revision of the RocksDB library used by MyRocks", + nullptr, nullptr, ROCKSDB_GIT_HASH); + static MYSQL_THDVAR_STR(tmpdir, PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_MEMALLOC, "Directory for temporary files during DDL operations.", nullptr, nullptr, ""); @@ -1633,6 +1640,7 @@ static struct st_mysql_sys_var *rocksdb_system_variables[] = { MYSQL_SYSVAR(table_stats_sampling_pct), MYSQL_SYSVAR(large_prefix), + MYSQL_SYSVAR(git_hash), nullptr}; static rocksdb::WriteOptions diff --git a/storage/rocksdb/mysql-test/rocksdb/r/rocksdb.result b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb.result index d791cf98bb0..9b084e63cd5 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/rocksdb.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/rocksdb.result @@ -924,6 +924,7 @@ rocksdb_force_compute_memtable_stats_cachetime 0 rocksdb_force_flush_memtable_and_lzero_now OFF rocksdb_force_flush_memtable_now OFF rocksdb_force_index_records_in_range 0 +rocksdb_git_hash # rocksdb_hash_index_allow_collision ON rocksdb_index_type kBinarySearch rocksdb_info_log_level error_level diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb.test b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb.test index 5c8fa9ed443..9199c572933 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb.test +++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb.test @@ -786,6 +786,8 @@ drop table t45; --echo # Now it fails if there is data overlap with what --echo # already exists --echo # + +--replace_regex /[a-f0-9]{40}/#/ show variables where variable_name like 'rocksdb%' and diff --git a/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_git_hash_basic.test b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_git_hash_basic.test new file mode 100644 index 00000000000..7b314e47d4b --- /dev/null +++ b/storage/rocksdb/mysql-test/rocksdb_sys_vars/t/rocksdb_git_hash_basic.test @@ -0,0 +1,6 @@ +--source include/have_rocksdb.inc + +--let $sys_var=ROCKSDB_GIT_HASH +--let $read_only=1 +--let $session=0 +--source include/rocksdb_sys_var.inc diff --git a/storage/rocksdb/rdb_source_revision.h.in b/storage/rocksdb/rdb_source_revision.h.in new file mode 100644 index 00000000000..617b39c9186 --- /dev/null +++ b/storage/rocksdb/rdb_source_revision.h.in @@ -0,0 +1 @@ +#define ROCKSDB_GIT_HASH "@ROCKSDB_GIT_HASH@" From 322c637c1c7717b5d33e4d7670a39eae17040e3c Mon Sep 17 00:00:00 2001 From: Monty Date: Mon, 1 Jan 2018 14:10:22 +0200 Subject: [PATCH 66/69] Fixed compiler warnings about possible uninitialized variables --- sql/log.cc | 2 +- sql/opt_range.cc | 2 +- sql/sql_cte.cc | 2 +- sql/sql_partition.cc | 10 ++++++++-- sql/table.cc | 8 +++----- storage/maria/ma_open.c | 2 +- 6 files changed, 15 insertions(+), 11 deletions(-) diff --git a/sql/log.cc b/sql/log.cc index a905e2b8caf..23873922368 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -2420,7 +2420,7 @@ static int find_uniq_filename(char *name, ulong next_log_number) char buff[FN_REFLEN], ext_buf[FN_REFLEN]; struct st_my_dir *dir_info; reg1 struct fileinfo *file_info; - ulong max_found, next, number; + ulong max_found, next, UNINIT_VAR(number); size_t buf_length, length; char *start, *end; int error= 0; diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 04d2059eb62..7d57bbf4cb8 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -6729,7 +6729,7 @@ static TRP_RANGE *get_key_scans_params(PARAM *param, SEL_TREE *tree, bool update_tbl_stats, double read_time) { - uint idx, best_idx; + uint idx, UNINIT_VAR(best_idx); SEL_ARG *key_to_read= NULL; ha_rows UNINIT_VAR(best_records); /* protected by key_to_read */ uint UNINIT_VAR(best_mrr_flags), /* protected by key_to_read */ diff --git a/sql/sql_cte.cc b/sql/sql_cte.cc index e1bd455830d..601c1928d58 100644 --- a/sql/sql_cte.cc +++ b/sql/sql_cte.cc @@ -664,7 +664,7 @@ void With_element::move_anchors_ahead() { st_select_lex *next_sl; st_select_lex *new_pos= spec->first_select(); - st_select_lex *last_sl; + st_select_lex *UNINIT_VAR(last_sl); new_pos->linkage= UNION_TYPE; for (st_select_lex *sl= new_pos; sl; sl= next_sl) { diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index de14829329b..fd8d23f5187 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -8071,8 +8071,11 @@ int create_partition_name(char *out, size_t outlen, const char *in1, end= strxnmov(out, outlen-1, in1, "#P#", transl_part, NullS); else if (name_variant == TEMP_PART_NAME) end= strxnmov(out, outlen-1, in1, "#P#", transl_part, "#TMP#", NullS); - else if (name_variant == RENAMED_PART_NAME) + else + { + DBUG_ASSERT(name_variant == RENAMED_PART_NAME); end= strxnmov(out, outlen-1, in1, "#P#", transl_part, "#REN#", NullS); + } if (end - out == static_cast(outlen-1)) { my_error(ER_PATH_LENGTH, MYF(0), longest_str(in1, transl_part)); @@ -8112,9 +8115,12 @@ int create_subpartition_name(char *out, size_t outlen, else if (name_variant == TEMP_PART_NAME) end= strxnmov(out, outlen-1, in1, "#P#", transl_part_name, "#SP#", transl_subpart_name, "#TMP#", NullS); - else if (name_variant == RENAMED_PART_NAME) + else + { + DBUG_ASSERT(name_variant == RENAMED_PART_NAME); end= strxnmov(out, outlen-1, in1, "#P#", transl_part_name, "#SP#", transl_subpart_name, "#REN#", NullS); + } if (end - out == static_cast(outlen-1)) { my_error(ER_PATH_LENGTH, MYF(0), diff --git a/sql/table.cc b/sql/table.cc index 811094ccc76..00debaec84e 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -997,7 +997,7 @@ bool parse_vcol_defs(THD *thd, MEM_ROOT *mem_root, TABLE *table, Virtual_column_info **check_constraint_ptr= table->check_constraints; sql_mode_t saved_mode= thd->variables.sql_mode; Query_arena backup_arena; - Virtual_column_info *vcol; + Virtual_column_info *vcol= 0; StringBuffer expr_str; bool res= 1; DBUG_ENTER("parse_vcol_defs"); @@ -1168,7 +1168,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write, uint new_frm_ver, field_pack_length, new_field_pack_flag; uint interval_count, interval_parts, read_length, int_length; uint db_create_options, keys, key_parts, n_length; - uint com_length, null_bit_pos, mysql57_vcol_null_bit_pos, bitmap_count; + uint com_length, null_bit_pos, UNINIT_VAR(mysql57_vcol_null_bit_pos), bitmap_count; uint i; bool use_hash, mysql57_null_bits= 0; char *keynames, *names, *comment_pos; @@ -2104,6 +2104,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write, } } + key_first_info= keyinfo; for (uint key=0 ; key < keys ; key++,keyinfo++) { uint usable_parts= 0; @@ -2121,9 +2122,6 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write, keyinfo->name_length+1); } - if (!key) - key_first_info= keyinfo; - if (ext_key_parts > share->key_parts && key) { KEY_PART_INFO *new_key_part= (keyinfo-1)->key_part + diff --git a/storage/maria/ma_open.c b/storage/maria/ma_open.c index 5a0c81d3e3e..8b3fa921cf1 100644 --- a/storage/maria/ma_open.c +++ b/storage/maria/ma_open.c @@ -280,7 +280,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags) size_t info_length; char name_buff[FN_REFLEN], org_name[FN_REFLEN], index_name[FN_REFLEN], data_name[FN_REFLEN]; - uchar *disk_cache, *disk_pos, *end_pos; + uchar *UNINIT_VAR(disk_cache), *disk_pos, *end_pos; MARIA_HA info, *UNINIT_VAR(m_info), *old_info; MARIA_SHARE share_buff,*share; double *rec_per_key_part; From 08ff39dca2ae8510dd2d2f9720b17eec9b23b38a Mon Sep 17 00:00:00 2001 From: Monty Date: Mon, 1 Jan 2018 14:12:18 +0200 Subject: [PATCH 67/69] Write location of core when doing core dump --- sql/signal_handler.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sql/signal_handler.cc b/sql/signal_handler.cc index 6e21d6249ab..68e801d5885 100644 --- a/sql/signal_handler.cc +++ b/sql/signal_handler.cc @@ -298,7 +298,9 @@ extern "C" sig_handler handle_fatal_signal(int sig) #ifdef HAVE_WRITE_CORE if (test_flags & TEST_CORE_ON_SIGNAL) { - my_safe_printf_stderr("%s", "Writing a core file\n"); + char buff[80]; + my_getwd(buff, sizeof(buff), 0); + my_safe_printf_stderr("Writing a core file at %s\n", buff); fflush(stderr); my_write_core(sig); } From 7e882a60bfb116e40df89e793c2b71decbe82f6d Mon Sep 17 00:00:00 2001 From: Monty Date: Mon, 1 Jan 2018 14:44:20 +0200 Subject: [PATCH 68/69] Ensure that table->vcol_set is properly restored if used Code in QUICK_RANGE_SELECT::init_ror_merged_scan() could theoretically have caused crashes if this was ever called from an update or delete This also found a bug in the vcol/range.result. file. --- mysql-test/suite/vcol/r/range.result | 4 ++-- sql/filesort.cc | 23 ++++++++++++++--------- sql/opt_range.cc | 7 +++++-- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/mysql-test/suite/vcol/r/range.result b/mysql-test/suite/vcol/r/range.result index ad7a39bc11c..5b081a5dbe8 100644 --- a/mysql-test/suite/vcol/r/range.result +++ b/mysql-test/suite/vcol/r/range.result @@ -4,6 +4,6 @@ create table t2 (a int, b int) engine=myisam; insert into t2 values (1,2),(2,4); select * from t1 inner join t2 on ( t2.b = t1.v or t2.a = t1.pk ); pk i v a b -1 1 0 1 2 -2 2 0 2 4 +1 1 2 1 2 +2 2 4 2 4 drop table t1, t2; diff --git a/sql/filesort.cc b/sql/filesort.cc index d4b28e47a39..d6bdebee3d3 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -712,6 +712,7 @@ static ha_rows find_all_keys(THD *thd, Sort_param *param, SQL_SELECT *select, handler *file; MY_BITMAP *save_read_set, *save_write_set, *save_vcol_set; Item *sort_cond; + ha_rows retval; DBUG_ENTER("find_all_keys"); DBUG_PRINT("info",("using: %s", (select ? select->quick ? "ranges" : "where": @@ -769,7 +770,7 @@ static ha_rows find_all_keys(THD *thd, Sort_param *param, SQL_SELECT *select, if (quick_select) { if (select->quick->reset()) - DBUG_RETURN(HA_POS_ERROR); + goto err; } DEBUG_SYNC(thd, "after_index_merge_phase1"); @@ -806,7 +807,7 @@ static ha_rows find_all_keys(THD *thd, Sort_param *param, SQL_SELECT *select, (void) file->extra(HA_EXTRA_NO_CACHE); file->ha_rnd_end(); } - DBUG_RETURN(HA_POS_ERROR); /* purecov: inspected */ + goto err; /* purecov: inspected */ } bool write_record= false; @@ -854,7 +855,7 @@ static ha_rows find_all_keys(THD *thd, Sort_param *param, SQL_SELECT *select, if (idx == param->max_keys_per_buffer) { if (write_keys(param, fs_info, idx, buffpek_pointers, tempfile)) - DBUG_RETURN(HA_POS_ERROR); + goto err; idx= 0; indexpos++; } @@ -880,12 +881,12 @@ static ha_rows find_all_keys(THD *thd, Sort_param *param, SQL_SELECT *select, file->ha_rnd_end(); } - if (thd->is_error()) - DBUG_RETURN(HA_POS_ERROR); - /* Signal we should use orignal column read and write maps */ sort_form->column_bitmaps_set(save_read_set, save_write_set, save_vcol_set); + if (thd->is_error()) + DBUG_RETURN(HA_POS_ERROR); + DBUG_PRINT("test",("error: %d indexpos: %d",error,indexpos)); if (error != HA_ERR_END_OF_FILE) { @@ -895,11 +896,15 @@ static ha_rows find_all_keys(THD *thd, Sort_param *param, SQL_SELECT *select, if (indexpos && idx && write_keys(param, fs_info, idx, buffpek_pointers, tempfile)) DBUG_RETURN(HA_POS_ERROR); /* purecov: inspected */ - const ha_rows retval= - my_b_inited(tempfile) ? - (ha_rows) (my_b_tell(tempfile)/param->rec_length) : idx; + retval= (my_b_inited(tempfile) ? + (ha_rows) (my_b_tell(tempfile)/param->rec_length) : + idx); DBUG_PRINT("info", ("find_all_keys return %llu", (ulonglong) retval)); DBUG_RETURN(retval); + +err: + sort_form->column_bitmaps_set(save_read_set, save_write_set, save_vcol_set); + DBUG_RETURN(HA_POS_ERROR); } /* find_all_keys */ diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 7d57bbf4cb8..560e24e33c5 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -1540,7 +1540,7 @@ end: head->file= org_file; /* Restore head->read_set (and write_set) to what they had before the call */ - head->column_bitmaps_set(save_read_set, save_write_set); + head->column_bitmaps_set(save_read_set, save_write_set, save_vcol_set); if (reset()) { @@ -11364,7 +11364,10 @@ int QUICK_RANGE_SELECT::reset() buf_size/= 2; } if (!mrr_buf_desc) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); + { + error= HA_ERR_OUT_OF_MEM; + goto err; + } /* Initialize the handler buffer. */ mrr_buf_desc->buffer= mrange_buff; From aed2050e40cb332d54e8d40eb7242309b962c4e1 Mon Sep 17 00:00:00 2001 From: Monty Date: Mon, 1 Jan 2018 15:01:20 +0200 Subject: [PATCH 69/69] Ignore generated file rdb_source_revision.h --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index b5cc5abdb0b..c8b6e22078d 100644 --- a/.gitignore +++ b/.gitignore @@ -190,6 +190,7 @@ storage/myisam/sp_test storage/rocksdb/ldb storage/rocksdb/mysql_ldb storage/rocksdb/sst_dump +storage/rocksdb/rdb_source_revision.h storage/tokudb/PerconaFT/buildheader/db.h storage/tokudb/PerconaFT/buildheader/make_tdb storage/tokudb/PerconaFT/buildheader/runcat.sh