summaryrefslogtreecommitdiff
path: root/storage/ndb/tools
diff options
context:
space:
mode:
authorunknown <Justin.He/justin.he@dev3-240.dev.cn.tlan>2007-03-13 18:18:17 +0800
committerunknown <Justin.He/justin.he@dev3-240.dev.cn.tlan>2007-03-13 18:18:17 +0800
commitd87ba06c276680580ecca457306a38f45edda835 (patch)
tree9a8e6c1c4daec995e093848738e2e76b071e4d5c /storage/ndb/tools
parent04fa93433bb9f6e8bba3da986754844b522739cd (diff)
parentb285de297405aec39a6cd3957aefa53da13c8652 (diff)
downloadmariadb-git-d87ba06c276680580ecca457306a38f45edda835.tar.gz
Merge dev3-240.dev.cn.tlan:/home/justin.he/mysql/mysql-5.1/mysql-5.1-new-ndb.test
into dev3-240.dev.cn.tlan:/home/justin.he/mysql/mysql-5.1/mysql-5.1-new-ndb-bj.test sql/ha_ndbcluster.cc: Auto merged storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp: Auto merged storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp: Auto merged storage/ndb/src/kernel/blocks/dbtup/DbtupAbort.cpp: Auto merged storage/ndb/src/kernel/blocks/dbtup/DbtupCommit.cpp: Auto merged storage/ndb/src/kernel/blocks/dbtup/DbtupDiskAlloc.cpp: Auto merged storage/ndb/src/kernel/blocks/dbtup/DbtupFixAlloc.cpp: Auto merged storage/ndb/src/kernel/blocks/dbtup/DbtupGen.cpp: Auto merged storage/ndb/src/kernel/blocks/dbtup/DbtupIndex.cpp: Auto merged storage/ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp: Auto merged storage/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp: Auto merged storage/ndb/src/kernel/blocks/dbtup/DbtupScan.cpp: Auto merged storage/ndb/src/kernel/blocks/dbtup/DbtupVarAlloc.cpp: Auto merged storage/ndb/src/kernel/vm/Pool.hpp: Auto merged storage/ndb/src/mgmclient/CommandInterpreter.cpp: Auto merged storage/ndb/src/mgmsrv/ConfigInfo.cpp: Auto merged storage/ndb/tools/restore/consumer_restore.cpp: Auto merged
Diffstat (limited to 'storage/ndb/tools')
-rw-r--r--storage/ndb/tools/restore/consumer.hpp1
-rw-r--r--storage/ndb/tools/restore/consumer_restore.cpp56
-rw-r--r--storage/ndb/tools/restore/consumer_restore.hpp1
-rw-r--r--storage/ndb/tools/restore/restore_main.cpp20
4 files changed, 78 insertions, 0 deletions
diff --git a/storage/ndb/tools/restore/consumer.hpp b/storage/ndb/tools/restore/consumer.hpp
index b05f7e00402..4121cc4e1b4 100644
--- a/storage/ndb/tools/restore/consumer.hpp
+++ b/storage/ndb/tools/restore/consumer.hpp
@@ -41,6 +41,7 @@ public:
NODE_GROUP_MAP *m_nodegroup_map;
uint m_nodegroup_map_len;
virtual bool has_temp_error() {return false;}
+ virtual bool table_equal(const TableS &) {return true;}
};
#endif
diff --git a/storage/ndb/tools/restore/consumer_restore.cpp b/storage/ndb/tools/restore/consumer_restore.cpp
index 03cf3e6ddb7..7e3395c36f6 100644
--- a/storage/ndb/tools/restore/consumer_restore.cpp
+++ b/storage/ndb/tools/restore/consumer_restore.cpp
@@ -668,6 +668,62 @@ err:
}
bool
+BackupRestore::table_equal(const TableS &tableS){
+ const char *tablename = tableS.getTableName();
+
+ if(tableS.m_dictTable == NULL){
+ ndbout<<"Table %s has no m_dictTable " << tablename << endl;
+ return false;
+ }
+ /**
+ * Ignore blob tables
+ */
+ if(match_blob(tablename) >= 0)
+ return true;
+
+ const NdbTableImpl & tmptab = NdbTableImpl::getImpl(* tableS.m_dictTable);
+ if ((int) tmptab.m_indexType != (int) NdbDictionary::Index::Undefined){
+ return true;
+ }
+
+ BaseString tmp(tablename);
+ Vector<BaseString> split;
+ if(tmp.split(split, "/") != 3){
+ err << "Invalid table name format " << tablename << endl;
+ return false;
+ }
+
+ m_ndb->setDatabaseName(split[0].c_str());
+ m_ndb->setSchemaName(split[1].c_str());
+
+ NdbDictionary::Dictionary* dict = m_ndb->getDictionary();
+ const NdbDictionary::Table* tab = dict->getTable(split[2].c_str());
+ if(tab == 0){
+ err << "Unable to find table: " << split[2].c_str() << endl;
+ return false;
+ }
+
+ if(tab->getNoOfColumns() != tableS.m_dictTable->getNoOfColumns())
+ {
+ ndbout_c("m_columns.size %d != %d",tab->getNoOfColumns(),
+ tableS.m_dictTable->getNoOfColumns());
+ return false;
+ }
+
+ for(int i = 0; i<tab->getNoOfColumns(); i++)
+ {
+ if(!tab->getColumn(i)->equal(*(tableS.m_dictTable->getColumn(i))))
+ {
+ ndbout_c("m_columns %s != %s",tab->getColumn(i)->getName(),
+ tableS.m_dictTable->getColumn(i)->getName());
+ return false;
+ }
+ }
+
+ return true;
+}
+
+bool
BackupRestore::createSystable(const TableS & tables){
if (!m_restore && !m_restore_meta && !m_restore_epoch)
return true;
diff --git a/storage/ndb/tools/restore/consumer_restore.hpp b/storage/ndb/tools/restore/consumer_restore.hpp
index 5063619d3c3..0bc9d8e8d20 100644
--- a/storage/ndb/tools/restore/consumer_restore.hpp
+++ b/storage/ndb/tools/restore/consumer_restore.hpp
@@ -73,6 +73,7 @@ public:
virtual bool finalize_table(const TableS &);
virtual bool has_temp_error();
virtual bool createSystable(const TableS & table);
+ virtual bool table_equal(const TableS & table);
virtual bool update_apply_status(const RestoreMetaData &metaData);
void connectToMysql();
bool map_in_frm(char *new_data, const char *data,
diff --git a/storage/ndb/tools/restore/restore_main.cpp b/storage/ndb/tools/restore/restore_main.cpp
index 4734e9f609d..ee3af467aa7 100644
--- a/storage/ndb/tools/restore/restore_main.cpp
+++ b/storage/ndb/tools/restore/restore_main.cpp
@@ -50,6 +50,7 @@ NDB_STD_OPTS_VARS;
static bool ga_restore_epoch = false;
static bool ga_restore = false;
static bool ga_print = false;
+static bool ga_skip_table_check = false;
static int _print = 0;
static int _print_meta = 0;
static int _print_data = 0;
@@ -91,6 +92,9 @@ static struct my_option my_long_options[] =
NDB_REP_DB "." NDB_APPLY_TABLE " with id 0 will be updated/inserted.",
(gptr*) &ga_restore_epoch, (gptr*) &ga_restore_epoch, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
+ { "skip-table-check", 's', "Skip table structure check during restore of data",
+ (gptr*) &ga_skip_table_check, (gptr*) &ga_skip_table_check, 0,
+ GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "parallelism", 'p',
"No of parallel transactions during restore of data."
"(parallelism can be 1 to 1024)",
@@ -459,6 +463,8 @@ main(int argc, char** argv)
g_options.appfmt(" -n %d", ga_nodeId);
if (_restore_meta)
g_options.appfmt(" -m");
+ if (ga_skip_table_check)
+ g_options.appfmt(" -s");
if (_restore_data)
g_options.appfmt(" -r");
if (ga_restore_epoch)
@@ -589,6 +595,20 @@ main(int argc, char** argv)
{
if(_restore_data || _print_data)
{
+ if (!ga_skip_table_check){
+ for(i=0; i < metaData.getNoOfTables(); i++){
+ if (checkSysTable(metaData, i))
+ {
+ for(Uint32 j= 0; j < g_consumers.size(); j++)
+ if (!g_consumers[j]->table_equal(* metaData[i]))
+ {
+ err << "Restore: Failed to restore data, ";
+ err << metaData[i]->getTableName() << " table structure doesn't match backup ... Exiting " << endl;
+ exitHandler(NDBT_FAILED);
+ }
+ }
+ }
+ }
RestoreDataIterator dataIter(metaData, &free_data_callback);
// Read data file header