Commit 4a1a0c48 authored by unknown's avatar unknown

BUG#5973 ndb table belonging to different database shows up in SHOW TABLES


mysql-test/r/ndb_autodiscover.result:
  Added test cases to check that SHOW TABLES  only show tables in the selected  db.
mysql-test/t/ndb_autodiscover.test:
  Added test cases to check that SHOW TABLES  only show tables in the selected  db.
sql/ha_ndbcluster.cc:
  Only find files for the current db
  Only add files to files list which can be created i.e has a valid frm blob. This prevents NDB$BLOB tables and tables created from NdbApi to show up.
parent 451636cd
...@@ -330,6 +330,34 @@ show status like 'handler_discover%'; ...@@ -330,6 +330,34 @@ show status like 'handler_discover%';
Variable_name Value Variable_name Value
Handler_discover 0 Handler_discover 0
drop table t6; drop table t6;
show tables;
Tables_in_test
create table t1 (a int) engine=ndb;
show tables;
Tables_in_test
t1
create database test2;
use test2;
show tables;
Tables_in_test2
select * from t1;
ERROR 42S02: Table 'test2.t1' doesn't exist
create table t2 (b int) engine=ndb;
use test;
select * from t1;
a
show tables;
Tables_in_test
t1
drop table t1;
use test2;
drop table t2;
drop database test2;
show databases;
Database
mysql
test
use test;
CREATE TABLE t9 ( CREATE TABLE t9 (
a int NOT NULL PRIMARY KEY, a int NOT NULL PRIMARY KEY,
b int b int
......
...@@ -427,6 +427,31 @@ show status like 'handler_discover%'; ...@@ -427,6 +427,31 @@ show status like 'handler_discover%';
drop table t6; drop table t6;
#####################################################
# Test that only tables in the current database shows
# up in SHOW TABLES
#
show tables;
create table t1 (a int) engine=ndb;
show tables;
create database test2;
use test2;
show tables;
--error 1146
select * from t1;
create table t2 (b int) engine=ndb;
use test;
select * from t1;
show tables;
drop table t1;
use test2;
drop table t2;
drop database test2;
show databases;
use test;
###################################################### ######################################################
# Note! This should always be the last step in this # Note! This should always be the last step in this
# file, the table t9 will be used and dropped # file, the table t9 will be used and dropped
......
...@@ -3844,6 +3844,10 @@ int ndbcluster_find_files(THD *thd,const char *db,const char *path, ...@@ -3844,6 +3844,10 @@ int ndbcluster_find_files(THD *thd,const char *db,const char *path,
NdbDictionary::Dictionary::List::Element& t= list.elements[i]; NdbDictionary::Dictionary::List::Element& t= list.elements[i];
DBUG_PRINT("info", ("Found %s/%s in NDB", t.database, t.name)); DBUG_PRINT("info", ("Found %s/%s in NDB", t.database, t.name));
// Add only tables that belongs to db
if (my_strcasecmp(system_charset_info, t.database, db))
continue;
// Apply wildcard to list of tables in NDB // Apply wildcard to list of tables in NDB
if (wild) if (wild)
{ {
...@@ -3938,7 +3942,7 @@ int ndbcluster_find_files(THD *thd,const char *db,const char *path, ...@@ -3938,7 +3942,7 @@ int ndbcluster_find_files(THD *thd,const char *db,const char *path,
while ((file_name=it2++)) while ((file_name=it2++))
{ {
DBUG_PRINT("info", ("Table %s need discovery", name)); DBUG_PRINT("info", ("Table %s need discovery", name));
ha_create_table_from_engine(thd, db, file_name, true); if (ha_create_table_from_engine(thd, db, file_name, true) == 0)
files->push_back(thd->strdup(file_name)); files->push_back(thd->strdup(file_name));
} }
......
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