diff --git a/mysql-test/r/ndb_restore.result b/mysql-test/r/ndb_restore.result index d1c76192cef..aba6997d218 100644 --- a/mysql-test/r/ndb_restore.result +++ b/mysql-test/r/ndb_restore.result @@ -141,6 +141,11 @@ DROP TABLE test.backup_info; drop table t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c,t10_c; ForceVarPart: 0 ForceVarPart: 1 +select * from information_schema.columns where table_name = "t1_c"; +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT +NULL test t1_c capgoaledatta 1 NULL NO mediumint NULL NULL 7 0 NULL NULL mediumint(5) unsigned PRI auto_increment select,insert,update,references +NULL test t1_c goaledatta 2 NO char 2 2 NULL NULL latin1 latin1_swedish_ci char(2) PRI select,insert,update,references +NULL test t1_c maturegarbagefa 3 NO varchar 32 32 NULL NULL latin1 latin1_swedish_ci varchar(32) PRI select,insert,update,references select count(*) from t1; count(*) 5 diff --git a/mysql-test/t/ndb_restore.test b/mysql-test/t/ndb_restore.test index 7f0cafdfd77..18efa66ebe0 100644 --- a/mysql-test/t/ndb_restore.test +++ b/mysql-test/t/ndb_restore.test @@ -180,6 +180,11 @@ drop table t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c,t10_c; --exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d test t3_c | grep ForceVarPart --exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d test t2_c | grep ForceVarPart +# Bug #30667 +# ndb table discovery does not work correcly with information schema +# - prior to bug fix this would yeild no output and a warning +select * from information_schema.columns where table_name = "t1_c"; + # random output order?? #show tables; diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 7a291276095..91e16be790f 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -6953,9 +6953,26 @@ int ndbcluster_find_files(handlerton *hton, THD *thd, while ((file_name=it++)) { bool file_on_disk= FALSE; - DBUG_PRINT("info", ("%s", file_name)); + DBUG_PRINT("info", ("%s", file_name)); if (hash_search(&ndb_tables, file_name, strlen(file_name))) { + build_table_filename(name, sizeof(name), db, file_name, reg_ext, 0); + if (my_access(name, F_OK)) + { + pthread_mutex_lock(&LOCK_open); + DBUG_PRINT("info", ("Table %s listed and need discovery", + file_name)); + if (ndb_create_table_from_engine(thd, db, file_name)) + { + pthread_mutex_unlock(&LOCK_open); + push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, + ER_TABLE_EXISTS_ERROR, + "Discover of table %s.%s failed", + db, file_name); + continue; + } + pthread_mutex_unlock(&LOCK_open); + } DBUG_PRINT("info", ("%s existed in NDB _and_ on disk ", file_name)); file_on_disk= TRUE; } diff --git a/storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp b/storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp index cf18bf34040..5300d5bbfd9 100644 --- a/storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp +++ b/storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp @@ -99,6 +99,7 @@ AsyncFile::AsyncFile(SimulatedBlock& fs) : { m_page_ptr.setNull(); m_current_request= m_last_request= 0; + m_open_flags = 0; } void @@ -328,6 +329,7 @@ void AsyncFile::openReq(Request* request) { m_auto_sync_freq = 0; m_write_wo_sync = 0; + m_open_flags = request->par.open.flags; // for open.flags, see signal FSOPENREQ #ifdef NDB_WIN32 @@ -954,7 +956,12 @@ AsyncFile::writevReq( Request * request) void AsyncFile::closeReq(Request * request) { - syncReq(request); + if (m_open_flags & ( + FsOpenReq::OM_WRITEONLY | + FsOpenReq::OM_READWRITE | + FsOpenReq::OM_APPEND )) { + syncReq(request); + } #ifdef NDB_WIN32 if(!CloseHandle(hFile)) { request->error = GetLastError(); diff --git a/storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp b/storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp index d8d585c47f7..e4a01753acd 100644 --- a/storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp +++ b/storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp @@ -224,6 +224,8 @@ private: #else int theFd; #endif + + Uint32 m_open_flags; // OM_ flags from request to open file MemoryChannel *theReportTo; MemoryChannel* theMemoryChannelPtr;