diff options
author | unknown <tomas@whalegate.ndb.mysql.com> | 2007-04-12 11:07:30 +0200 |
---|---|---|
committer | unknown <tomas@whalegate.ndb.mysql.com> | 2007-04-12 11:07:30 +0200 |
commit | d7dadcd7c7668cf871f3b5cc00825dfaa6450c45 (patch) | |
tree | ed15b823b182cfeb96fe15b518fa931d52389674 /ndb | |
parent | 1810062ef13cde77f1dc23f1251b5b47b22e2194 (diff) | |
download | mariadb-git-d7dadcd7c7668cf871f3b5cc00825dfaa6450c45.tar.gz |
Bug #27758 Restoring NDB backups makes table usable in SQL nodes
- parse indexname using "split" instead of sscanf, as not to break at space
- test case with space in key
- enclose names in printout
mysql-test/r/ndb_restore.result:
Bug #27758 Restoring NDB backups makes table usable in SQL nodes
- change to using an index with space to reproduce bug
mysql-test/t/ndb_restore.test:
Bug #27758 Restoring NDB backups makes table usable in SQL nodes
- change to using an index with space to reproduce bug
ndb/tools/restore/consumer_restore.cpp:
Bug #27758 Restoring NDB backups makes table usable in SQL nodes
- parse indexname using "split" instead of sscanf, as not to break at space
- enclose names in printout
ndb/tools/restore/restore_main.cpp:
Bug #27758 Restoring NDB backups makes table usable in SQL nodes
- enclose names in printout
sql/ha_ndbcluster.cc:
Bug #27758 Restoring NDB backups makes table usable in SQL nodes
- correct error message
Diffstat (limited to 'ndb')
-rw-r--r-- | ndb/tools/restore/consumer_restore.cpp | 56 | ||||
-rw-r--r-- | ndb/tools/restore/restore_main.cpp | 4 |
2 files changed, 33 insertions, 27 deletions
diff --git a/ndb/tools/restore/consumer_restore.cpp b/ndb/tools/restore/consumer_restore.cpp index c955570eaa3..d15cfea07df 100644 --- a/ndb/tools/restore/consumer_restore.cpp +++ b/ndb/tools/restore/consumer_restore.cpp @@ -205,7 +205,7 @@ BackupRestore::table(const TableS & table){ BaseString tmp(name); Vector<BaseString> split; if(tmp.split(split, "/") != 3){ - err << "Invalid table name format " << name << endl; + err << "Invalid table name format `" << name << "`" << endl; return false; } @@ -230,16 +230,17 @@ BackupRestore::table(const TableS & table){ if (dict->createTable(copy) == -1) { - err << "Create table " << table.getTableName() << " failed: " + err << "Create table `" << table.getTableName() << "` failed: " << dict->getNdbError() << endl; return false; } - info << "Successfully restored table " << table.getTableName()<< endl ; + info << "Successfully restored table `" + << table.getTableName() << "`" << endl; } const NdbDictionary::Table* tab = dict->getTable(split[2].c_str()); if(tab == 0){ - err << "Unable to find table: " << split[2].c_str() << endl; + err << "Unable to find table: `" << split[2].c_str() << "`" << endl; return false; } const NdbDictionary::Table* null = 0; @@ -257,12 +258,15 @@ BackupRestore::endOfTables(){ for(size_t i = 0; i<m_indexes.size(); i++){ NdbTableImpl & indtab = NdbTableImpl::getImpl(* m_indexes[i]); - BaseString tmp(indtab.m_primaryTable.c_str()); Vector<BaseString> split; - if(tmp.split(split, "/") != 3){ - err << "Invalid table name format " << indtab.m_primaryTable.c_str() - << endl; - return false; + { + BaseString tmp(indtab.m_primaryTable.c_str()); + if (tmp.split(split, "/") != 3) + { + err << "Invalid table name format `" << indtab.m_primaryTable.c_str() + << "`" << endl; + return false; + } } m_ndb->setDatabaseName(split[0].c_str()); @@ -270,39 +274,41 @@ BackupRestore::endOfTables(){ const NdbDictionary::Table * prim = dict->getTable(split[2].c_str()); if(prim == 0){ - err << "Unable to find base table \"" << split[2].c_str() - << "\" for index " - << indtab.getName() << endl; + err << "Unable to find base table `" << split[2].c_str() + << "` for index `" + << indtab.getName() << "`" << endl; return false; } NdbTableImpl& base = NdbTableImpl::getImpl(*prim); NdbIndexImpl* idx; - int id; - char idxName[255], buf[255]; - if(sscanf(indtab.getName(), "%[^/]/%[^/]/%d/%s", - buf, buf, &id, idxName) != 4){ - err << "Invalid index name format " << indtab.getName() << endl; - return false; + Vector<BaseString> split_idx; + { + BaseString tmp(indtab.getName()); + if (tmp.split(split_idx, "/") != 4) + { + err << "Invalid index name format `" << indtab.getName() << "`" << endl; + return false; + } } if(NdbDictInterface::create_index_obj_from_table(&idx, &indtab, &base)) { - err << "Failed to create index " << idxName - << " on " << split[2].c_str() << endl; + err << "Failed to create index `" << split_idx[3] + << "` on " << split[2].c_str() << endl; return false; } - idx->setName(idxName); + idx->setName(split_idx[3].c_str()); if(dict->createIndex(* idx) != 0) { delete idx; - err << "Failed to create index " << idxName - << " on " << split[2].c_str() << endl + err << "Failed to create index `" << split_idx[3].c_str() + << "` on `" << split[2].c_str() << "`" << endl << dict->getNdbError() << endl; return false; } delete idx; - info << "Successfully created index " << idxName - << " on " << split[2].c_str() << endl; + info << "Successfully created index `" << split_idx[3].c_str() + << "` on `" << split[2].c_str() << "`" << endl; } return true; } diff --git a/ndb/tools/restore/restore_main.cpp b/ndb/tools/restore/restore_main.cpp index 52a913d73b4..9ec59b9b4a6 100644 --- a/ndb/tools/restore/restore_main.cpp +++ b/ndb/tools/restore/restore_main.cpp @@ -559,8 +559,8 @@ main(int argc, char** argv) for(Uint32 j= 0; j < g_consumers.size(); j++) if (!g_consumers[j]->table(* table)) { - err << "Restore: Failed to restore table: "; - err << table->getTableName() << " ... Exiting " << endl; + err << "Restore: Failed to restore table: `"; + err << table->getTableName() << "` ... Exiting " << endl; exitHandler(NDBT_FAILED); } } |