summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <mskold@mysql.com>2006-05-30 13:20:38 +0200
committerunknown <mskold@mysql.com>2006-05-30 13:20:38 +0200
commitf982aa934a1d43b2db2eecdf8dfbd2ceb5d49961 (patch)
tree53e249892e3340722c48b7ecca3124c706ccd085 /sql
parentf27a0eed21da5053b5d7b5baa217ca4b87f6a3e5 (diff)
parentcba185d9243561630b067c1d117759c71db75e2a (diff)
downloadmariadb-git-f982aa934a1d43b2db2eecdf8dfbd2ceb5d49961.tar.gz
Merge mskold@bk-internal.mysql.com:/home/bk/mysql-4.1
into mysql.com:/home/marty/MySQL/mysql-4.1 sql/ha_ndbcluster.cc: Auto merged
Diffstat (limited to 'sql')
-rw-r--r--sql/ha_ndbcluster.cc41
1 files changed, 40 insertions, 1 deletions
diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc
index c0eae685a52..3f2c6cbc6bb 100644
--- a/sql/ha_ndbcluster.cc
+++ b/sql/ha_ndbcluster.cc
@@ -898,6 +898,8 @@ static int fix_unique_index_attr_order(NDB_INDEX_DATA &data,
DBUG_RETURN(0);
}
+
+
int ha_ndbcluster::build_index_list(Ndb *ndb, TABLE *tab, enum ILBP phase)
{
uint i;
@@ -3941,7 +3943,6 @@ int ha_ndbcluster::create_index(const char *name,
DBUG_RETURN(0);
}
-
/*
Rename a table in NDB Cluster
*/
@@ -3950,12 +3951,16 @@ int ha_ndbcluster::rename_table(const char *from, const char *to)
{
NDBDICT *dict;
char new_tabname[FN_HEADLEN];
+ char new_dbname[FN_HEADLEN];
const NDBTAB *orig_tab;
int result;
+ bool recreate_indexes= FALSE;
+ NDBDICT::List index_list;
DBUG_ENTER("ha_ndbcluster::rename_table");
DBUG_PRINT("info", ("Renaming %s to %s", from, to));
set_dbname(from);
+ set_dbname(to, new_dbname);
set_tabname(from);
set_tabname(to, new_tabname);
@@ -3973,6 +3978,12 @@ int ha_ndbcluster::rename_table(const char *from, const char *to)
if (!(orig_tab= dict->getTable(m_tabname)))
ERR_RETURN(dict->getNdbError());
}
+ if (my_strcasecmp(system_charset_info, new_dbname, m_dbname))
+ {
+ dict->listIndexes(index_list, m_tabname);
+ recreate_indexes= TRUE;
+ }
+
m_table= (void *)orig_tab;
// Change current database to that of target table
set_dbname(to);
@@ -3983,6 +3994,34 @@ int ha_ndbcluster::rename_table(const char *from, const char *to)
result= handler::rename_table(from, to);
}
+ // If we are moving tables between databases, we need to recreate
+ // indexes
+ if (recreate_indexes)
+ {
+ const NDBTAB *new_tab;
+ set_tabname(to);
+ if (!(new_tab= dict->getTable(m_tabname)))
+ ERR_RETURN(dict->getNdbError());
+
+ for (unsigned i = 0; i < index_list.count; i++) {
+ NDBDICT::List::Element& index_el = index_list.elements[i];
+ set_dbname(from);
+ ndb->setDatabaseName(m_dbname);
+ const NDBINDEX * index= dict->getIndex(index_el.name, *new_tab);
+ set_dbname(to);
+ ndb->setDatabaseName(m_dbname);
+ DBUG_PRINT("info", ("Creating index %s/%s",
+ m_dbname, index->getName()));
+ dict->createIndex(*index);
+ DBUG_PRINT("info", ("Dropping index %s/%s",
+ m_dbname, index->getName()));
+
+ set_dbname(from);
+ ndb->setDatabaseName(m_dbname);
+ dict->dropIndex(*index);
+ }
+ }
+
DBUG_RETURN(result);
}