diff options
-rw-r--r-- | client/mysqldump.c | 10 | ||||
-rw-r--r-- | mysql-test/r/information_schema.result | 42 | ||||
-rw-r--r-- | mysql-test/r/innodb_ext_key.result | 2 | ||||
-rw-r--r-- | mysql-test/r/join.result | 11 | ||||
-rw-r--r-- | mysql-test/t/information_schema.test | 56 | ||||
-rw-r--r-- | mysql-test/t/join.test | 15 | ||||
-rw-r--r-- | sql/opt_range.cc | 15 | ||||
-rw-r--r-- | sql/slave.cc | 1 | ||||
-rw-r--r-- | sql/sql_select.cc | 2 | ||||
-rw-r--r-- | sql/sql_show.cc | 16 |
10 files changed, 161 insertions, 9 deletions
diff --git a/client/mysqldump.c b/client/mysqldump.c index fa5c06786d2..a0222f370b3 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -4004,7 +4004,13 @@ static int dump_tablespaces(char* ts_where) char *ubs; char *endsemi; DBUG_ENTER("dump_tablespaces"); - + + /* + Try to turn off semi-join optimization (if that fails, this is a + pre-optimizer_switch server, and the old query plan is ok for us. + */ + mysql_query(mysql, "set optimizer_switch='semijoin=off'"); + init_dynamic_string_checked(&sqlbuf, "SELECT LOGFILE_GROUP_NAME," " FILE_NAME," @@ -4164,6 +4170,8 @@ static int dump_tablespaces(char* ts_where) mysql_free_result(tableres); dynstr_free(&sqlbuf); + mysql_query(mysql, "set optimizer_switch=default"); + DBUG_RETURN(0); } diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index d27b03e85d3..a070c5c10d5 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -1985,3 +1985,45 @@ drop database mysqltest; # # End of 5.5 tests # +# +# MDEV-5723: mysqldump -uroot unusable for multi-database operations, checks all databases +# +drop database if exists db1; +create database db1; +use db1; +create table t1 (a int); +create table t2 (a int); +create table t3 (a int); +create database mysqltest; +use mysqltest; +create table t1 (a int); +create table t2 (a int); +create table t3 (a int); +flush tables; +flush status; +SELECT +LOGFILE_GROUP_NAME, FILE_NAME, TOTAL_EXTENTS, INITIAL_SIZE, ENGINE, EXTRA +FROM +INFORMATION_SCHEMA.FILES +WHERE +FILE_TYPE = 'UNDO LOG' AND FILE_NAME IS NOT NULL AND +LOGFILE_GROUP_NAME IN (SELECT DISTINCT LOGFILE_GROUP_NAME +FROM INFORMATION_SCHEMA.FILES +WHERE +FILE_TYPE = 'DATAFILE' AND +TABLESPACE_NAME IN (SELECT DISTINCT TABLESPACE_NAME +FROM INFORMATION_SCHEMA.PARTITIONS +WHERE TABLE_SCHEMA IN ('db1') +) +) +GROUP BY +LOGFILE_GROUP_NAME, FILE_NAME, ENGINE +ORDER BY +LOGFILE_GROUP_NAME; +LOGFILE_GROUP_NAME FILE_NAME TOTAL_EXTENTS INITIAL_SIZE ENGINE EXTRA +# This must have Opened_tables=3, not 6. +show status like 'Opened_tables'; +Variable_name Value +Opened_tables 3 +drop database mysqltest; +drop database db1; diff --git a/mysql-test/r/innodb_ext_key.result b/mysql-test/r/innodb_ext_key.result index 9ef28e1ce54..9140f306f77 100644 --- a/mysql-test/r/innodb_ext_key.result +++ b/mysql-test/r/innodb_ext_key.result @@ -327,7 +327,7 @@ from lineitem use index (i_l_shipdate, i_l_receiptdate) where l_shipdate='1992-07-01' and l_orderkey=130 or l_receiptdate='1992-07-01' and l_orderkey=5603; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE lineitem index_merge i_l_shipdate,i_l_receiptdate i_l_shipdate,i_l_receiptdate 8,8 NULL 2 Using sort_union(i_l_shipdate,i_l_receiptdate); Using where +1 SIMPLE lineitem index_merge i_l_shipdate,i_l_receiptdate i_l_shipdate,i_l_receiptdate 8,8 NULL 2 Using union(i_l_shipdate,i_l_receiptdate); Using where flush status; select l_orderkey, l_linenumber from lineitem use index (i_l_shipdate, i_l_receiptdate) diff --git a/mysql-test/r/join.result b/mysql-test/r/join.result index 0f798f7ba1a..e7292e8ddce 100644 --- a/mysql-test/r/join.result +++ b/mysql-test/r/join.result @@ -1538,3 +1538,14 @@ a 3 4 DROP TABLE t1,t2; +# +# MDEV-5635: join of a const table with non-const tables +# +CREATE TABLE t1 (a varchar(3) NOT NULL) ENGINE=MyISAM; +INSERT INTO t1 VALUES ('foo'); +CREATE TABLE t2 (b varchar(3), c varchar(3), INDEX(b)) ENGINE=MyISAM; +INSERT INTO t2 VALUES ('bar', 'bar'),( 'qux', 'qux'); +SELECT STRAIGHT_JOIN * FROM t1, t2 AS t2_1, t2 AS t2_2 +WHERE t2_2.c = t2_1.c AND t2_2.b = t2_1.b AND ( a IS NULL OR t2_1.c = a ); +a b c b c +DROP TABLE t1,t2; diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test index 8c88be5c603..f6422a0aae7 100644 --- a/mysql-test/t/information_schema.test +++ b/mysql-test/t/information_schema.test @@ -1816,5 +1816,61 @@ drop database mysqltest; --echo # End of 5.5 tests --echo # +--echo # +--echo # MDEV-5723: mysqldump -uroot unusable for multi-database operations, checks all databases +--echo # + +--disable_warnings +drop database if exists db1; +--enable_warnings + +connect (con1,localhost,root,,); +connection con1; + +create database db1; +use db1; +create table t1 (a int); +create table t2 (a int); +create table t3 (a int); + +create database mysqltest; +use mysqltest; +create table t1 (a int); +create table t2 (a int); +create table t3 (a int); + +flush tables; +flush status; + +SELECT + LOGFILE_GROUP_NAME, FILE_NAME, TOTAL_EXTENTS, INITIAL_SIZE, ENGINE, EXTRA +FROM + INFORMATION_SCHEMA.FILES +WHERE + FILE_TYPE = 'UNDO LOG' AND FILE_NAME IS NOT NULL AND + LOGFILE_GROUP_NAME IN (SELECT DISTINCT LOGFILE_GROUP_NAME + FROM INFORMATION_SCHEMA.FILES + WHERE + FILE_TYPE = 'DATAFILE' AND + TABLESPACE_NAME IN (SELECT DISTINCT TABLESPACE_NAME + FROM INFORMATION_SCHEMA.PARTITIONS + WHERE TABLE_SCHEMA IN ('db1') + ) + ) +GROUP BY + LOGFILE_GROUP_NAME, FILE_NAME, ENGINE +ORDER BY + LOGFILE_GROUP_NAME; + +--echo # This must have Opened_tables=3, not 6. +show status like 'Opened_tables'; + +drop database mysqltest; +drop database db1; + +connection default; +disconnect con1; + # Wait till all disconnects are completed --source include/wait_until_count_sessions.inc + diff --git a/mysql-test/t/join.test b/mysql-test/t/join.test index 54b2a3c82ea..e07a3665920 100644 --- a/mysql-test/t/join.test +++ b/mysql-test/t/join.test @@ -1185,3 +1185,18 @@ SELECT t1.a FROM t1 NATURAL STRAIGHT_JOIN t2 ORDER BY t1.a; SELECT t1.a FROM t1 NATURAL STRAIGHT_JOIN t2 ORDER BY t1.a; DROP TABLE t1,t2; + +--echo # +--echo # MDEV-5635: join of a const table with non-const tables +--echo # + +CREATE TABLE t1 (a varchar(3) NOT NULL) ENGINE=MyISAM; +INSERT INTO t1 VALUES ('foo'); + +CREATE TABLE t2 (b varchar(3), c varchar(3), INDEX(b)) ENGINE=MyISAM; +INSERT INTO t2 VALUES ('bar', 'bar'),( 'qux', 'qux'); + +SELECT STRAIGHT_JOIN * FROM t1, t2 AS t2_1, t2 AS t2_2 + WHERE t2_2.c = t2_1.c AND t2_2.b = t2_1.b AND ( a IS NULL OR t2_1.c = a ); + +DROP TABLE t1,t2; diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 30d796c7688..b08ecc399bf 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -7967,7 +7967,8 @@ static SEL_TREE *get_mm_tree(RANGE_OPT_PARAM *param,COND *cond) value= cond_func->arg_count > 1 ? cond_func->arguments()[1] : NULL; if (value && value->is_expensive()) DBUG_RETURN(0); - ftree= get_full_func_mm_tree(param, cond_func, field_item, value, inv); + if (!cond_func->arguments()[0]->real_item()->const_item()) + ftree= get_full_func_mm_tree(param, cond_func, field_item, value, inv); } /* Even if get_full_func_mm_tree() was executed above and did not @@ -7992,7 +7993,8 @@ static SEL_TREE *get_mm_tree(RANGE_OPT_PARAM *param,COND *cond) value= cond_func->arguments()[0]; if (value && value->is_expensive()) DBUG_RETURN(0); - ftree= get_full_func_mm_tree(param, cond_func, field_item, value, inv); + if (!cond_func->arguments()[1]->real_item()->const_item()) + ftree= get_full_func_mm_tree(param, cond_func, field_item, value, inv); } } @@ -10629,8 +10631,13 @@ static bool is_key_scan_ror(PARAM *param, uint keynr, uint8 nparts) if (param->table->field[fieldnr]->key_length() != kp->length) return FALSE; } - - if (key_part == key_part_end) + + /* + If there are equalities for all key parts, it is a ROR scan. If there are + equalities all keyparts and even some of key parts from "Extended Key" + index suffix, it is a ROR-scan, too. + */ + if (key_part >= key_part_end) return TRUE; key_part= table_key->key_part + nparts; diff --git a/sql/slave.cc b/sql/slave.cc index 8482924ef87..74955c09ced 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1343,6 +1343,7 @@ bool is_network_error(uint errorno) errorno == ER_CON_COUNT_ERROR || errorno == ER_CONNECTION_KILLED || errorno == ER_NEW_ABORTING_CONNECTION || + errorno == ER_NET_READ_INTERRUPTED || errorno == ER_SERVER_SHUTDOWN) return TRUE; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 06a48d9157b..cfef5eafa27 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -19476,7 +19476,7 @@ static int test_if_order_by_key(ORDER *order, TABLE *table, uint idx, for (; const_key_parts & 1 ; const_key_parts>>= 1) key_part++; - if (key_part == key_part_end) + if (key_part >= key_part_end) { /* We are at the end of the key. Check if the engine has the primary diff --git a/sql/sql_show.cc b/sql/sql_show.cc index a640e44ebe1..aa23f01ab7d 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -8062,8 +8062,20 @@ static bool do_fill_table(THD *thd, da->push_warning_info(&wi_tmp); - bool res= table_list->schema_table->fill_table( - thd, table_list, join_table->select_cond); + Item *item= join_table->select_cond; + if (join_table->cache_select && + join_table->cache_select->cond) + { + /* + If join buffering is used, we should use the condition that is attached + to the join cache. Cache condition has a part of WHERE that can be + checked when we're populating this table. + join_tab->select_cond is of no interest, because it only has conditions + that depend on both this table and previous tables in the join order. + */ + item= join_table->cache_select->cond; + } + bool res= table_list->schema_table->fill_table(thd, table_list, item); da->pop_warning_info(); |