Commit 1de817e9 authored by unknown's avatar unknown

Fix removal of tables from cache when the database they are contained

within is dropped and lower_case_table_names is set. (Bug #8355)


mysql-test/t/lowercase_table2.test:
  Add new regression test
mysql-test/r/lowercase_table2.result:
  Add results for regression test
sql/mysql_priv.h:
  Change remove_db_from_cache() to use char* instead of my_string
sql/sql_base.cc:
  Lowercase database name in remove_db_from_cache so
  that all of the correct entries are removed.
parent ffe417fd
...@@ -141,3 +141,21 @@ select * from T1; ...@@ -141,3 +141,21 @@ select * from T1;
a b a b
1 abc 1 abc
drop table T1; drop table T1;
create database mysqltest_LC2;
use mysqltest_LC2;
create table myUC (i int);
insert into myUC values (1),(2),(3);
select * from myUC;
i
1
2
3
use test;
drop database mysqltest_LC2;
create database mysqltest_LC2;
use mysqltest_LC2;
create table myUC (i int);
select * from myUC;
i
use test;
drop database mysqltest_LC2;
...@@ -111,3 +111,20 @@ select * from T1; ...@@ -111,3 +111,20 @@ select * from T1;
alter table T1 add index (a); alter table T1 add index (a);
select * from T1; select * from T1;
drop table T1; drop table T1;
#
# Bug #8355: Tables not dropped from table cache on drop db
#
create database mysqltest_LC2;
use mysqltest_LC2;
create table myUC (i int);
insert into myUC values (1),(2),(3);
select * from myUC;
use test;
drop database mysqltest_LC2;
create database mysqltest_LC2;
use mysqltest_LC2;
create table myUC (i int);
select * from myUC;
use test;
drop database mysqltest_LC2;
...@@ -750,7 +750,7 @@ bool close_temporary_table(THD *thd, const char *db, const char *table_name); ...@@ -750,7 +750,7 @@ bool close_temporary_table(THD *thd, const char *db, const char *table_name);
void close_temporary(TABLE *table, bool delete_table=1); void close_temporary(TABLE *table, bool delete_table=1);
bool rename_temporary_table(THD* thd, TABLE *table, const char *new_db, bool rename_temporary_table(THD* thd, TABLE *table, const char *new_db,
const char *table_name); const char *table_name);
void remove_db_from_cache(const my_string db); void remove_db_from_cache(const char *db);
void flush_tables(); void flush_tables();
bool remove_table_from_cache(THD *thd, const char *db, const char *table, bool remove_table_from_cache(THD *thd, const char *db, const char *table,
bool return_if_owned_by_thd=0); bool return_if_owned_by_thd=0);
......
...@@ -2864,8 +2864,18 @@ static void mysql_rm_tmp_tables(void) ...@@ -2864,8 +2864,18 @@ static void mysql_rm_tmp_tables(void)
** and afterwards delete those marked unused. ** and afterwards delete those marked unused.
*/ */
void remove_db_from_cache(const my_string db) void remove_db_from_cache(const char *db)
{ {
char name_buff[NAME_LEN+1];
if (db && lower_case_table_names)
{
/*
convert database to lower case for comparision.
*/
strmake(name_buff, db, sizeof(name_buff)-1);
my_casedn_str(files_charset_info, name_buff);
db= name_buff;
}
for (uint idx=0 ; idx < open_cache.records ; idx++) for (uint idx=0 ; idx < open_cache.records ; idx++)
{ {
TABLE *table=(TABLE*) hash_element(&open_cache,idx); TABLE *table=(TABLE*) hash_element(&open_cache,idx);
......
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