diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 570ac48238c..b08c7a2d8b7 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -5789,7 +5789,6 @@ int ndbcluster_find_all_files(THD *thd) DBUG_ENTER("ndbcluster_find_all_files"); Ndb* ndb; char key[FN_REFLEN]; - NdbDictionary::Dictionary::List list; if (!(ndb= check_ndb_in_thd(thd))) DBUG_RETURN(HA_ERR_NO_CONNECTION); @@ -5799,6 +5798,7 @@ int ndbcluster_find_all_files(THD *thd) int unhandled, retries= 5, skipped; do { + NdbDictionary::Dictionary::List list; if (dict->listObjects(list, NdbDictionary::Object::UserTable) != 0) ERR_RETURN(dict->getNdbError()); unhandled= 0; @@ -10082,14 +10082,15 @@ static int ndbcluster_fill_files_table(THD *thd, TABLE_LIST *tables, COND *cond) } } - dict->listObjects(dflist, NdbDictionary::Object::Undofile); + NdbDictionary::Dictionary::List uflist; + dict->listObjects(uflist, NdbDictionary::Object::Undofile); ndberr= dict->getNdbError(); if (ndberr.classification != NdbError::NoError) ERR_RETURN(ndberr); - for (i= 0; i < dflist.count; i++) + for (i= 0; i < uflist.count; i++) { - NdbDictionary::Dictionary::List::Element& elt= dflist.elements[i]; + NdbDictionary::Dictionary::List::Element& elt= uflist.elements[i]; Ndb_cluster_connection_node_iter iter; unsigned id; diff --git a/storage/ndb/include/kernel/signaldata/DictTabInfo.hpp b/storage/ndb/include/kernel/signaldata/DictTabInfo.hpp index 6997938472c..42e06fba381 100644 --- a/storage/ndb/include/kernel/signaldata/DictTabInfo.hpp +++ b/storage/ndb/include/kernel/signaldata/DictTabInfo.hpp @@ -586,7 +586,8 @@ public: enum Unimplemented { ScanOptimised = 15, //Default updateOptimised - AttributeGroup = 1012 //Default 0 + AttributeGroup = 1012, //Default 0 + FileNo = 102 }; }; @@ -618,13 +619,13 @@ struct DictFilegroupInfo { */ FileName = 100, FileType = 101, - FileId = 102, - FileNo = 103, // Per Filegroup + FileId = 103, FileFGroupId = 104, FileFGroupVersion = 105, FileSizeHi = 106, FileSizeLo = 107, FileFreeExtents = 108, + FileVersion = 109, FileEnd = 199, // /** @@ -696,8 +697,8 @@ struct DictFilegroupInfo { struct File { char FileName[PATH_MAX]; Uint32 FileType; - Uint32 FileNo; Uint32 FileId; + Uint32 FileVersion; Uint32 FilegroupId; Uint32 FilegroupVersion; Uint32 FileSizeHi; diff --git a/storage/ndb/include/kernel/signaldata/DropFilegroup.hpp b/storage/ndb/include/kernel/signaldata/DropFilegroup.hpp index 70ca21c203b..7cf275b1f9e 100644 --- a/storage/ndb/include/kernel/signaldata/DropFilegroup.hpp +++ b/storage/ndb/include/kernel/signaldata/DropFilegroup.hpp @@ -66,9 +66,10 @@ struct DropFilegroupRef { Busy = 701, NotMaster = 702, NoSuchFilegroup = 767, - FilegroupInUse = 768 + FilegroupInUse = 768, + InvalidSchemaObjectVersion = 774 }; - + Uint32 senderData; Uint32 senderRef; Uint32 masterNodeId; @@ -150,7 +151,8 @@ struct DropFileRef { NoError = 0, Busy = 701, NoSuchFile = 766, - DropUndoFileNotSupported = 769 + DropUndoFileNotSupported = 769, + InvalidSchemaObjectVersion = 774 }; Uint32 senderData; diff --git a/storage/ndb/src/common/debugger/signaldata/DictTabInfo.cpp b/storage/ndb/src/common/debugger/signaldata/DictTabInfo.cpp index b9f91c510c0..e46fc2ff7da 100644 --- a/storage/ndb/src/common/debugger/signaldata/DictTabInfo.cpp +++ b/storage/ndb/src/common/debugger/signaldata/DictTabInfo.cpp @@ -216,8 +216,8 @@ SimpleProperties::SP2StructMapping DictFilegroupInfo::FileMapping[] = { DFGIMAPS(File, FileName, FileName, 0, PATH_MAX), DFGIMAP2(File, FileType, FileType, 0, 1), - DFGIMAP(File, FileNo, FileNo), DFGIMAP(File, FileId, FileId), + DFGIMAP(File, FileVersion, FileVersion), DFGIMAP(File, FileFGroupId, FilegroupId), DFGIMAP(File, FileFGroupVersion, FilegroupVersion), DFGIMAP(File, FileSizeHi, FileSizeHi), @@ -254,8 +254,8 @@ void DictFilegroupInfo::File::init(){ memset(FileName, sizeof(FileName), 0); FileType = ~0; - FileNo = ~0; FileId = ~0; + FileVersion = ~0; FilegroupId = ~0; FilegroupVersion = ~0; FileSizeHi = 0; diff --git a/storage/ndb/src/kernel/blocks/backup/BackupInit.cpp b/storage/ndb/src/kernel/blocks/backup/BackupInit.cpp index 48072fe946e..b22cd51e61d 100644 --- a/storage/ndb/src/kernel/blocks/backup/BackupInit.cpp +++ b/storage/ndb/src/kernel/blocks/backup/BackupInit.cpp @@ -143,12 +143,13 @@ Backup::execREAD_CONFIG_REQ(Signal* signal) m_ctx.m_config.getOwnConfigIterator(); ndbrequire(p != 0); - Uint32 noBackups = 0, noTables = 0, noAttribs = 0; + Uint32 noBackups = 0, noTables = 0, noAttribs = 0, noFrags = 0; ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_DB_DISCLESS, &m_diskless)); ndb_mgm_get_int_parameter(p, CFG_DB_PARALLEL_BACKUPS, &noBackups); // ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_DB_NO_TABLES, &noTables)); ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_DICT_TABLE, &noTables)); ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_DB_NO_ATTRIBUTES, &noAttribs)); + ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_DIH_FRAG_CONNECT, &noFrags)); noAttribs++; //RT 527 bug fix @@ -158,9 +159,7 @@ Backup::execREAD_CONFIG_REQ(Signal* signal) c_tablePool.setSize(noBackups * noTables + 1); c_attributePool.setSize(noBackups * noAttribs + MAX_ATTRIBUTES_IN_TABLE); c_triggerPool.setSize(noBackups * 3 * noTables); - - // 2 = no of replicas - c_fragmentPool.setSize(noBackups * NO_OF_FRAG_PER_NODE * noTables + 1); + c_fragmentPool.setSize(noBackups * noFrags + 1); Uint32 szDataBuf = (2 * 1024 * 1024); Uint32 szLogBuf = (2 * 1024 * 1024); diff --git a/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp b/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp index 9425762e4cb..87bd1d7c53b 100644 --- a/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp +++ b/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp @@ -631,7 +631,8 @@ Dbdict::packFileIntoPages(SimpleProperties::Writer & w, f.FileSizeHi = (f_ptr.p->m_file_size >> 32); f.FileSizeLo = (f_ptr.p->m_file_size & 0xFFFFFFFF); f.FileFreeExtents= free_extents; - f.FileNo = f_ptr.p->key; + f.FileId = f_ptr.p->key; + f.FileVersion = f_ptr.p->m_version; FilegroupPtr lfg_ptr; ndbrequire(c_filegroup_hash.find(lfg_ptr, f.FilegroupId)); @@ -13588,6 +13589,13 @@ Dbdict::execDROP_FILE_REQ(Signal* signal) break; } + if (file_ptr.p->m_version != version) + { + ref->errorCode = DropFileRef::InvalidSchemaObjectVersion; + ref->errorLine = __LINE__; + break; + } + Ptr trans_ptr; if (! c_Trans.seize(trans_ptr)) { @@ -13662,6 +13670,13 @@ Dbdict::execDROP_FILEGROUP_REQ(Signal* signal) ref->errorLine = __LINE__; break; } + + if (filegroup_ptr.p->m_version != version) + { + ref->errorCode = DropFilegroupRef::InvalidSchemaObjectVersion; + ref->errorLine = __LINE__; + break; + } Ptr trans_ptr; if (! c_Trans.seize(trans_ptr)) @@ -15095,6 +15110,7 @@ Dbdict::create_file_prepare_start(Signal* signal, SchemaOp* op){ filePtr.p->m_obj_ptr_i = obj_ptr.i; filePtr.p->m_filegroup_id = f.FilegroupId; filePtr.p->m_type = f.FileType; + filePtr.p->m_version = op->m_obj_version; obj_ptr.p->m_id = op->m_obj_id; obj_ptr.p->m_type = f.FileType; diff --git a/storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp b/storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp index e0c82af3c59..c770b6c69b8 100644 --- a/storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp +++ b/storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp @@ -535,6 +535,7 @@ public: Uint32 key; Uint32 m_magic; + Uint32 m_version; Uint32 m_obj_ptr_i; Uint32 m_filegroup_id; Uint32 m_type; diff --git a/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp b/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp index 52cd85571ca..6bed6310052 100644 --- a/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp +++ b/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp @@ -4624,13 +4624,27 @@ NdbDictInterface::get_filegroup(NdbFilegroupImpl & dst, LinearSectionPtr ptr[1]; ptr[0].p = (Uint32*)name; ptr[0].sz = (strLen + 3)/4; - + +#ifndef IGNORE_VALGRIND_WARNINGS + if (strLen & 3) + { + Uint32 pad = 0; + m_buffer.clear(); + m_buffer.append(name, strLen); + m_buffer.append(&pad, 4); + ptr[0].p = (Uint32*)m_buffer.get_data(); + } +#endif + int r = dictSignal(&tSignal, ptr, 1, -1, // any node WAIT_GET_TAB_INFO_REQ, DICT_WAITFOR_TIMEOUT, 100); if (r) { + dst.m_id = -1; + dst.m_version = ~0; + DBUG_PRINT("info", ("get_filegroup failed dictSignal")); DBUG_RETURN(-1); } @@ -4766,7 +4780,18 @@ NdbDictInterface::get_file(NdbFileImpl & dst, LinearSectionPtr ptr[1]; ptr[0].p = (Uint32*)name; ptr[0].sz = (strLen + 3)/4; - + +#ifndef IGNORE_VALGRIND_WARNINGS + if (strLen & 3) + { + Uint32 pad = 0; + m_buffer.clear(); + m_buffer.append(name, strLen); + m_buffer.append(&pad, 4); + ptr[0].p = (Uint32*)m_buffer.get_data(); + } +#endif + int r = dictSignal(&tSignal, ptr, 1, node, WAIT_GET_TAB_INFO_REQ, @@ -4834,7 +4859,8 @@ NdbDictInterface::parseFileInfo(NdbFileImpl &dst, } dst.m_type= (NdbDictionary::Object::Type)f.FileType; - dst.m_id= f.FileNo; + dst.m_id= f.FileId; + dst.m_version = f.FileVersion; dst.m_size= ((Uint64)f.FileSizeHi << 32) | (f.FileSizeLo); dst.m_path.assign(f.FileName); diff --git a/storage/ndb/src/ndbapi/ndberror.c b/storage/ndb/src/ndbapi/ndberror.c index 52ecb5f8e21..8185bf38c3e 100644 --- a/storage/ndb/src/ndbapi/ndberror.c +++ b/storage/ndb/src/ndbapi/ndberror.c @@ -386,6 +386,7 @@ ErrorBundle ErrorCodes[] = { { 768, DMEC, SE, "Cant drop filegroup, filegroup is used" }, { 769, DMEC, SE, "Drop undofile not supported, drop logfile group instead" }, { 770, DMEC, SE, "Cant drop file, file is used" }, + { 774, DMEC, SE, "Invalid schema object for drop" }, { 241, HA_ERR_TABLE_DEF_CHANGED, SE, "Invalid schema object version" }, { 283, HA_ERR_NO_SUCH_TABLE, SE, "Table is being dropped" }, { 284, HA_ERR_TABLE_DEF_CHANGED, SE, "Table not defined in transaction coordinator" },