summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <andrey@lmy004.wdf.sap.corp>2005-08-16 11:22:29 +0200
committerunknown <andrey@lmy004.wdf.sap.corp>2005-08-16 11:22:29 +0200
commitef5cafdf6dc42051a3eb51851fe969f4507a92ab (patch)
treedd815157db0407929cfcf31f643bdfd745fd2118
parent5082c41bf3ae5668d28132e912574a42cbe18ccb (diff)
parent1566ec35d62d70a944a4b146934dc6683a532fff (diff)
downloadmariadb-git-ef5cafdf6dc42051a3eb51851fe969f4507a92ab.tar.gz
Merge ahristov@bk-internal.mysql.com:/home/bk/mysql-5.0
into lmy004.wdf.sap.corp:/work/mysql-5.0-clean
-rw-r--r--mysql-test/r/show_check.result43
-rw-r--r--mysql-test/t/show_check.test18
-rw-r--r--sql/mysql_priv.h2
-rw-r--r--sql/sql_base.cc9
-rw-r--r--sql/sql_show.cc3
5 files changed, 69 insertions, 6 deletions
diff --git a/mysql-test/r/show_check.result b/mysql-test/r/show_check.result
index f1c536ed1da..94d1ac7ac11 100644
--- a/mysql-test/r/show_check.result
+++ b/mysql-test/r/show_check.result
@@ -512,3 +512,46 @@ t1 CREATE TABLE `t1` (
KEY `c2` USING BTREE (`c2`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
+CREATE TABLE txt1(a int);
+CREATE TABLE tyt2(a int);
+CREATE TABLE urkunde(a int);
+FLUSH TABLES;
+SELECT 1 FROM mysql.db, mysql.proc, mysql.user, mysql.time_zone, mysql.time_zone_name, txt1, tyt2, urkunde LIMIT 0;
+1
+SHOW OPEN TABLES;
+Database Table In_use Name_locked
+mysql db 0 0
+test urkunde 0 0
+mysql time_zone 0 0
+mysql user 0 0
+test txt1 0 0
+mysql proc 0 0
+test tyt2 0 0
+mysql time_zone_name 0 0
+SHOW OPEN TABLES FROM mysql;
+Database Table In_use Name_locked
+mysql db 0 0
+mysql time_zone 0 0
+mysql user 0 0
+mysql proc 0 0
+mysql time_zone_name 0 0
+SHOW OPEN TABLES FROM mysql LIKE 'u%';
+Database Table In_use Name_locked
+mysql user 0 0
+SHOW OPEN TABLES LIKE 't%';
+Database Table In_use Name_locked
+mysql time_zone 0 0
+test txt1 0 0
+test tyt2 0 0
+mysql time_zone_name 0 0
+SHOW OPEN TABLES LIKE '%o%';
+Database Table In_use Name_locked
+mysql time_zone 0 0
+mysql proc 0 0
+mysql time_zone_name 0 0
+FLUSH TABLES;
+SHOW OPEN TABLES;
+Database Table In_use Name_locked
+DROP TABLE txt1;
+DROP TABLE tyt2;
+DROP TABLE urkunde;
diff --git a/mysql-test/t/show_check.test b/mysql-test/t/show_check.test
index efe3504ad7d..41b8a9e401c 100644
--- a/mysql-test/t/show_check.test
+++ b/mysql-test/t/show_check.test
@@ -387,3 +387,21 @@ SHOW CREATE TABLE t1;
DROP TABLE t1;
# End of 4.1 tests
+#
+# BUG 12183 - SHOW OPEN TABLES behavior doesn't match grammar
+# First we close all open tables with FLUSH tables and then we open some.
+CREATE TABLE txt1(a int);
+CREATE TABLE tyt2(a int);
+CREATE TABLE urkunde(a int);
+FLUSH TABLES;
+SELECT 1 FROM mysql.db, mysql.proc, mysql.user, mysql.time_zone, mysql.time_zone_name, txt1, tyt2, urkunde LIMIT 0;
+SHOW OPEN TABLES;
+SHOW OPEN TABLES FROM mysql;
+SHOW OPEN TABLES FROM mysql LIKE 'u%';
+SHOW OPEN TABLES LIKE 't%';
+SHOW OPEN TABLES LIKE '%o%';
+FLUSH TABLES;
+SHOW OPEN TABLES;
+DROP TABLE txt1;
+DROP TABLE tyt2;
+DROP TABLE urkunde;
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index 0370251f119..085bb0166cc 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -981,7 +981,7 @@ bool fill_record_n_invoke_before_triggers(THD *thd, Field **field,
bool ignore_errors,
Table_triggers_list *triggers,
enum trg_event_type event);
-OPEN_TABLE_LIST *list_open_tables(THD *thd, const char *wild);
+OPEN_TABLE_LIST *list_open_tables(THD *thd, const char *db, const char *wild);
inline TABLE_LIST *find_table_in_global_list(TABLE_LIST *table,
const char *db_name,
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 5627b97c734..3b716422663 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -129,12 +129,11 @@ static void check_unused(void)
# Pointer to list of names of open tables.
*/
-OPEN_TABLE_LIST *list_open_tables(THD *thd, const char *wild)
+OPEN_TABLE_LIST *list_open_tables(THD *thd, const char *db, const char *wild)
{
int result = 0;
OPEN_TABLE_LIST **start_list, *open_list;
TABLE_LIST table_list;
- char name[NAME_LEN*2];
DBUG_ENTER("list_open_tables");
VOID(pthread_mutex_lock(&LOCK_open));
@@ -151,10 +150,12 @@ OPEN_TABLE_LIST *list_open_tables(THD *thd, const char *wild)
DBUG_ASSERT(share->table_name != 0);
if ((!share->table_name)) // To be removed
continue; // Shouldn't happen
+ if (db && my_strcasecmp(system_charset_info, db, share->table_cache_key))
+ continue;
+
if (wild)
{
- strxmov(name,share->table_cache_key,".",share->table_name,NullS);
- if (wild_compare(name,wild,0))
+ if (wild_compare(share->table_name,wild,0))
continue;
}
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 0a76e9fb753..e1d5f80ebc2 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -3189,7 +3189,8 @@ int fill_open_tables(THD *thd, TABLE_LIST *tables, COND *cond)
TABLE *table= tables->table;
CHARSET_INFO *cs= system_charset_info;
OPEN_TABLE_LIST *open_list;
- if (!(open_list=list_open_tables(thd,wild)) && thd->is_fatal_error)
+ if (!(open_list=list_open_tables(thd,thd->lex->select_lex.db, wild))
+ && thd->is_fatal_error)
DBUG_RETURN(1);
for (; open_list ; open_list=open_list->next)