Commit 64649e33 authored by Sergey Petrunya's avatar Sergey Petrunya

MDEV-5723: mysqldump -uroot unusable for multi-database operations, checks all databases

- Make do_fill_table() use join_tab->cache_select->cond if it is present.  When 
  join_tab->cache_select->cond is present, join_tab->select_cond doesn't have any 
  conditions that are usable for I_S optimizations.
parent 24d9bf82
...@@ -1972,3 +1972,45 @@ drop database mysqltest; ...@@ -1972,3 +1972,45 @@ drop database mysqltest;
# #
# End of 5.5 tests # 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;
...@@ -1816,5 +1816,61 @@ drop database mysqltest; ...@@ -1816,5 +1816,61 @@ drop database mysqltest;
--echo # End of 5.5 tests --echo # End of 5.5 tests
--echo # --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 # Wait till all disconnects are completed
--source include/wait_until_count_sessions.inc --source include/wait_until_count_sessions.inc
...@@ -8021,9 +8021,21 @@ static bool do_fill_table(THD *thd, ...@@ -8021,9 +8021,21 @@ static bool do_fill_table(THD *thd,
Warning_info *wi_saved= thd->warning_info; Warning_info *wi_saved= thd->warning_info;
thd->warning_info= &wi; thd->warning_info= &wi;
bool res= table_list->schema_table->fill_table( Item *item= join_table->select_cond;
thd, table_list, 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);
thd->warning_info= wi_saved; thd->warning_info= wi_saved;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment