Loading mysql-test/r/ndb_autodiscover.result +17 −3 Original line number Diff line number Diff line Loading @@ -93,7 +93,7 @@ name char(20), a int, b float, c char(24) ERROR 42S01: Table 't3' already exists show status like 'handler_discover%'; Variable_name Value Handler_discover 1 Handler_discover 0 create table IF NOT EXISTS t3( id int not null primary key, id2 int not null, Loading @@ -101,7 +101,7 @@ name char(20) ) engine=ndb; show status like 'handler_discover%'; Variable_name Value Handler_discover 2 Handler_discover 0 SHOW CREATE TABLE t3; Table Create Table t3 CREATE TABLE `t3` ( Loading @@ -114,7 +114,7 @@ id name 1 Explorer show status like 'handler_discover%'; Variable_name Value Handler_discover 2 Handler_discover 1 drop table t3; flush status; create table t7( Loading Loading @@ -358,6 +358,20 @@ Database mysql test use test; CREATE TABLE sys.SYSTAB_0 (a int); ERROR 42S01: Table 'SYSTAB_0' already exists select * from sys.SYSTAB_0; ERROR HY000: Failed to open 'SYSTAB_0', error while unpacking from engine CREATE TABLE IF NOT EXISTS sys.SYSTAB_0 (a int); show warnings; Level Code Message select * from sys.SYSTAB_0; ERROR HY000: Failed to open 'SYSTAB_0', error while unpacking from engine drop table sys.SYSTAB_0; ERROR 42S02: Unknown table 'SYSTAB_0' drop table IF EXISTS sys.SYSTAB_0; Warnings: Note 1051 Unknown table 'SYSTAB_0' CREATE TABLE t9 ( a int NOT NULL PRIMARY KEY, b int Loading mysql-test/t/ndb_autodiscover.test +21 −0 Original line number Diff line number Diff line Loading @@ -453,6 +453,27 @@ drop database test2; show databases; use test; ##################################################### # Test that it's not possible to create tables # with same name as NDB internal tables # This will also test that it's not possible to create # a table with tha same name as a table that can't be # discovered( for example a table created via NDBAPI) --error 1050 CREATE TABLE sys.SYSTAB_0 (a int); --error 1105 select * from sys.SYSTAB_0; CREATE TABLE IF NOT EXISTS sys.SYSTAB_0 (a int); show warnings; --error 1105 select * from sys.SYSTAB_0; --error 1051 drop table sys.SYSTAB_0; drop table IF EXISTS sys.SYSTAB_0; ###################################################### # Note! This should always be the last step in this # file, the table t9 will be used and dropped Loading ndb/test/ndbapi/create_tab.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -77,8 +77,8 @@ int main(int argc, const char** argv){ */ // Connect to Ndb Ndb::setConnectString(_connectstr); Ndb MyNdb( "TEST_DB" ); MyNdb.setConnectString(_connectstr); if(MyNdb.init() != 0){ ERR(MyNdb.getNdbError()); Loading sql/ha_ndbcluster.cc +12 −13 Original line number Diff line number Diff line Loading @@ -4300,7 +4300,7 @@ int ndbcluster_discover(THD* thd, const char *db, const char *name, { const NdbError err= dict->getNdbError(); if (err.code == 709) DBUG_RETURN(1); DBUG_RETURN(-1); ERR_RETURN(err); } DBUG_PRINT("info", ("Found table %s", tab->getName())); Loading @@ -4308,13 +4308,15 @@ int ndbcluster_discover(THD* thd, const char *db, const char *name, len= tab->getFrmLength(); if (len == 0 || tab->getFrmData() == NULL) { DBUG_PRINT("No frm data found", ("Table is probably created via NdbApi")); DBUG_RETURN(2); DBUG_PRINT("error", ("No frm data found.")); DBUG_RETURN(1); } if (unpackfrm(&data, &len, tab->getFrmData())) DBUG_RETURN(3); { DBUG_PRINT("error", ("Could not unpack table")); DBUG_RETURN(1); } *frmlen= len; *frmblob= data; Loading @@ -4327,13 +4329,13 @@ int ndbcluster_discover(THD* thd, const char *db, const char *name, */ int ndbcluster_table_exists(THD* thd, const char *db, const char *name) int ndbcluster_table_exists_in_engine(THD* thd, const char *db, const char *name) { uint len; const void* data; const NDBTAB* tab; Ndb* ndb; DBUG_ENTER("ndbcluster_table_exists"); DBUG_ENTER("ndbcluster_table_exists_in_engine"); DBUG_PRINT("enter", ("db: %s, name: %s", db, name)); if (!(ndb= check_ndb_in_thd(thd))) Loading Loading @@ -4512,7 +4514,7 @@ int ndbcluster_find_files(THD *thd,const char *db,const char *path, DBUG_PRINT("info", ("%s existed on disk", name)); // The .ndb file exists on disk, but it's not in list of tables in ndb // Verify that handler agrees table is gone. if (ndbcluster_table_exists(thd, db, file_name) == 0) if (ndbcluster_table_exists_in_engine(thd, db, file_name) == 0) { DBUG_PRINT("info", ("NDB says %s does not exists", file_name)); it.remove(); Loading Loading @@ -4563,7 +4565,7 @@ int ndbcluster_find_files(THD *thd,const char *db,const char *path, while ((file_name=it2++)) { DBUG_PRINT("info", ("Table %s need discovery", name)); if (ha_create_table_from_engine(thd, db, file_name, TRUE) == 0) if (ha_create_table_from_engine(thd, db, file_name) == 0) files->push_back(thd->strdup(file_name)); } Loading Loading @@ -4639,11 +4641,8 @@ bool ndbcluster_init() pthread_mutex_init(&ndbcluster_mutex,MY_MUTEX_INIT_FAST); ndbcluster_inited= 1; #ifdef USE_DISCOVER_ON_STARTUP if (ndb_discover_tables() != 0) goto ndbcluster_init_error; #endif DBUG_RETURN(FALSE); ndbcluster_init_error: ndbcluster_end(); DBUG_RETURN(TRUE); Loading sql/ha_ndbcluster.h +2 −1 Original line number Diff line number Diff line Loading @@ -275,7 +275,8 @@ int ndbcluster_discover(THD* thd, const char* dbname, const char* name, const void** frmblob, uint* frmlen); int ndbcluster_find_files(THD *thd,const char *db,const char *path, const char *wild, bool dir, List<char> *files); int ndbcluster_table_exists(THD* thd, const char *db, const char *name); int ndbcluster_table_exists_in_engine(THD* thd, const char *db, const char *name); int ndbcluster_drop_database(const char* path); void ndbcluster_print_error(int error, const NdbOperation *error_op); Loading
mysql-test/r/ndb_autodiscover.result +17 −3 Original line number Diff line number Diff line Loading @@ -93,7 +93,7 @@ name char(20), a int, b float, c char(24) ERROR 42S01: Table 't3' already exists show status like 'handler_discover%'; Variable_name Value Handler_discover 1 Handler_discover 0 create table IF NOT EXISTS t3( id int not null primary key, id2 int not null, Loading @@ -101,7 +101,7 @@ name char(20) ) engine=ndb; show status like 'handler_discover%'; Variable_name Value Handler_discover 2 Handler_discover 0 SHOW CREATE TABLE t3; Table Create Table t3 CREATE TABLE `t3` ( Loading @@ -114,7 +114,7 @@ id name 1 Explorer show status like 'handler_discover%'; Variable_name Value Handler_discover 2 Handler_discover 1 drop table t3; flush status; create table t7( Loading Loading @@ -358,6 +358,20 @@ Database mysql test use test; CREATE TABLE sys.SYSTAB_0 (a int); ERROR 42S01: Table 'SYSTAB_0' already exists select * from sys.SYSTAB_0; ERROR HY000: Failed to open 'SYSTAB_0', error while unpacking from engine CREATE TABLE IF NOT EXISTS sys.SYSTAB_0 (a int); show warnings; Level Code Message select * from sys.SYSTAB_0; ERROR HY000: Failed to open 'SYSTAB_0', error while unpacking from engine drop table sys.SYSTAB_0; ERROR 42S02: Unknown table 'SYSTAB_0' drop table IF EXISTS sys.SYSTAB_0; Warnings: Note 1051 Unknown table 'SYSTAB_0' CREATE TABLE t9 ( a int NOT NULL PRIMARY KEY, b int Loading
mysql-test/t/ndb_autodiscover.test +21 −0 Original line number Diff line number Diff line Loading @@ -453,6 +453,27 @@ drop database test2; show databases; use test; ##################################################### # Test that it's not possible to create tables # with same name as NDB internal tables # This will also test that it's not possible to create # a table with tha same name as a table that can't be # discovered( for example a table created via NDBAPI) --error 1050 CREATE TABLE sys.SYSTAB_0 (a int); --error 1105 select * from sys.SYSTAB_0; CREATE TABLE IF NOT EXISTS sys.SYSTAB_0 (a int); show warnings; --error 1105 select * from sys.SYSTAB_0; --error 1051 drop table sys.SYSTAB_0; drop table IF EXISTS sys.SYSTAB_0; ###################################################### # Note! This should always be the last step in this # file, the table t9 will be used and dropped Loading
ndb/test/ndbapi/create_tab.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -77,8 +77,8 @@ int main(int argc, const char** argv){ */ // Connect to Ndb Ndb::setConnectString(_connectstr); Ndb MyNdb( "TEST_DB" ); MyNdb.setConnectString(_connectstr); if(MyNdb.init() != 0){ ERR(MyNdb.getNdbError()); Loading
sql/ha_ndbcluster.cc +12 −13 Original line number Diff line number Diff line Loading @@ -4300,7 +4300,7 @@ int ndbcluster_discover(THD* thd, const char *db, const char *name, { const NdbError err= dict->getNdbError(); if (err.code == 709) DBUG_RETURN(1); DBUG_RETURN(-1); ERR_RETURN(err); } DBUG_PRINT("info", ("Found table %s", tab->getName())); Loading @@ -4308,13 +4308,15 @@ int ndbcluster_discover(THD* thd, const char *db, const char *name, len= tab->getFrmLength(); if (len == 0 || tab->getFrmData() == NULL) { DBUG_PRINT("No frm data found", ("Table is probably created via NdbApi")); DBUG_RETURN(2); DBUG_PRINT("error", ("No frm data found.")); DBUG_RETURN(1); } if (unpackfrm(&data, &len, tab->getFrmData())) DBUG_RETURN(3); { DBUG_PRINT("error", ("Could not unpack table")); DBUG_RETURN(1); } *frmlen= len; *frmblob= data; Loading @@ -4327,13 +4329,13 @@ int ndbcluster_discover(THD* thd, const char *db, const char *name, */ int ndbcluster_table_exists(THD* thd, const char *db, const char *name) int ndbcluster_table_exists_in_engine(THD* thd, const char *db, const char *name) { uint len; const void* data; const NDBTAB* tab; Ndb* ndb; DBUG_ENTER("ndbcluster_table_exists"); DBUG_ENTER("ndbcluster_table_exists_in_engine"); DBUG_PRINT("enter", ("db: %s, name: %s", db, name)); if (!(ndb= check_ndb_in_thd(thd))) Loading Loading @@ -4512,7 +4514,7 @@ int ndbcluster_find_files(THD *thd,const char *db,const char *path, DBUG_PRINT("info", ("%s existed on disk", name)); // The .ndb file exists on disk, but it's not in list of tables in ndb // Verify that handler agrees table is gone. if (ndbcluster_table_exists(thd, db, file_name) == 0) if (ndbcluster_table_exists_in_engine(thd, db, file_name) == 0) { DBUG_PRINT("info", ("NDB says %s does not exists", file_name)); it.remove(); Loading Loading @@ -4563,7 +4565,7 @@ int ndbcluster_find_files(THD *thd,const char *db,const char *path, while ((file_name=it2++)) { DBUG_PRINT("info", ("Table %s need discovery", name)); if (ha_create_table_from_engine(thd, db, file_name, TRUE) == 0) if (ha_create_table_from_engine(thd, db, file_name) == 0) files->push_back(thd->strdup(file_name)); } Loading Loading @@ -4639,11 +4641,8 @@ bool ndbcluster_init() pthread_mutex_init(&ndbcluster_mutex,MY_MUTEX_INIT_FAST); ndbcluster_inited= 1; #ifdef USE_DISCOVER_ON_STARTUP if (ndb_discover_tables() != 0) goto ndbcluster_init_error; #endif DBUG_RETURN(FALSE); ndbcluster_init_error: ndbcluster_end(); DBUG_RETURN(TRUE); Loading
sql/ha_ndbcluster.h +2 −1 Original line number Diff line number Diff line Loading @@ -275,7 +275,8 @@ int ndbcluster_discover(THD* thd, const char* dbname, const char* name, const void** frmblob, uint* frmlen); int ndbcluster_find_files(THD *thd,const char *db,const char *path, const char *wild, bool dir, List<char> *files); int ndbcluster_table_exists(THD* thd, const char *db, const char *name); int ndbcluster_table_exists_in_engine(THD* thd, const char *db, const char *name); int ndbcluster_drop_database(const char* path); void ndbcluster_print_error(int error, const NdbOperation *error_op);