Loading mysql-test/r/ndb_rename.result 0 → 100644 +14 −0 Original line number Diff line number Diff line DROP TABLE IF EXISTS t1,t2; drop database if exists mysqltest; CREATE TABLE t1 ( pk1 INT NOT NULL PRIMARY KEY, attr1 INT NOT NULL, attr2 INT, attr3 VARCHAR(10), INDEX i1(attr1) ) ENGINE=ndbcluster; alter table t1 rename t2; create database ndbtest; alter table t2 rename ndbtest.t2; drop table ndbtest.t2; drop database ndbtest; mysql-test/t/ndb_rename.test 0 → 100644 +32 −0 Original line number Diff line number Diff line -- source include/have_ndb.inc -- source include/not_embedded.inc --disable_warnings DROP TABLE IF EXISTS t1,t2; drop database if exists mysqltest; --enable_warnings # # Table rename tests # # # Create a normal table with primary key # CREATE TABLE t1 ( pk1 INT NOT NULL PRIMARY KEY, attr1 INT NOT NULL, attr2 INT, attr3 VARCHAR(10), INDEX i1(attr1) ) ENGINE=ndbcluster; alter table t1 rename t2; create database ndbtest; alter table t2 rename ndbtest.t2; drop table ndbtest.t2; drop database ndbtest; # End of 4.1 tests ndb/include/ndbapi/NdbDictionary.hpp +20 −3 Original line number Diff line number Diff line Loading @@ -1182,6 +1182,15 @@ public: const Index * getIndex(const char * indexName, const char * tableName) const; /** * Get index with given name, NULL if undefined * @param indexName Name of index to get. * @param Table instance table that index belongs to. * @return index if successful, otherwise 0. */ const Index * getIndex(const char * indexName, const Table & table) const; /** * Fetch list of indexes of given table. * @param list Reference to list where to store the listed indexes Loading Loading @@ -1230,14 +1239,14 @@ public: /** * Create defined table given defined Table instance * @param table Table to create * @param Table instance to create * @return 0 if successful otherwise -1. */ int createTable(const Table &table); /** * Drop table given retrieved Table instance * @param table Table to drop * @param Table instance to drop * @return 0 if successful otherwise -1. */ int dropTable(Table & table); Loading Loading @@ -1302,6 +1311,14 @@ public: int dropIndex(const char * indexName, const char * tableName); /** * Drop index the defined Index instance * @param Index to drop * @return 0 if successful otherwise -1. */ int dropIndex(const Index &); #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL /** * Invalidate cached index object Loading ndb/src/ndbapi/NdbDictionary.cpp +16 −0 Original line number Diff line number Diff line Loading @@ -800,6 +800,12 @@ NdbDictionary::Dictionary::dropIndex(const char * indexName, return m_impl.dropIndex(indexName, tableName); } int NdbDictionary::Dictionary::dropIndex(const Index & ind) { return m_impl.dropIndex(NdbIndexImpl::getImpl(ind)); } const NdbDictionary::Index * NdbDictionary::Dictionary::getIndex(const char * indexName, const char * tableName) const Loading @@ -810,6 +816,16 @@ NdbDictionary::Dictionary::getIndex(const char * indexName, return 0; } const NdbDictionary::Index * NdbDictionary::Dictionary::getIndex(const char * indexName, const Table & t) const { NdbIndexImpl * i = m_impl.getIndex(indexName, & NdbTableImpl::getImpl(t)); if(i) return i->m_facade; return 0; } void NdbDictionary::Dictionary::invalidateIndex(const char * indexName, const char * tableName){ Loading ndb/src/ndbapi/NdbDictionaryImpl.cpp +5 −22 Original line number Diff line number Diff line Loading @@ -2267,7 +2267,7 @@ NdbDictionaryImpl::dropIndex(const char * indexName, m_error.code = 4243; return -1; } int ret = dropIndex(*idx, tableName); int ret = dropIndex(*idx); //, tableName); // If index stored in cache is incompatible with the one in the kernel // we must clear the cache and try again if (ret == INCOMPATIBLE_VERSION) { Loading @@ -2289,42 +2289,25 @@ NdbDictionaryImpl::dropIndex(const char * indexName, } int NdbDictionaryImpl::dropIndex(NdbIndexImpl & impl, const char * tableName) NdbDictionaryImpl::dropIndex(NdbIndexImpl & impl) { const char * indexName = impl.getName(); if (tableName || m_ndb.usingFullyQualifiedNames()) { NdbTableImpl * timpl = impl.m_table; if (timpl == 0) { m_error.code = 709; return -1; } const BaseString internalIndexName((tableName) ? m_ndb.internalize_index_name(getTable(tableName), indexName) : m_ndb.internalize_table_name(indexName)); // Index is also a table if(impl.m_status == NdbDictionary::Object::New){ return dropIndex(indexName, tableName); } int ret = m_receiver.dropIndex(impl, *timpl); if(ret == 0){ m_localHash.drop(internalIndexName.c_str()); m_localHash.drop(timpl->m_internalName.c_str()); m_globalHash->lock(); impl.m_table->m_status = NdbDictionary::Object::Invalid; m_globalHash->drop(impl.m_table); timpl->m_status = NdbDictionary::Object::Invalid; m_globalHash->drop(timpl); m_globalHash->unlock(); } return ret; } m_error.code = 4243; return -1; } int NdbDictInterface::dropIndex(const NdbIndexImpl & impl, const NdbTableImpl & timpl) Loading Loading
mysql-test/r/ndb_rename.result 0 → 100644 +14 −0 Original line number Diff line number Diff line DROP TABLE IF EXISTS t1,t2; drop database if exists mysqltest; CREATE TABLE t1 ( pk1 INT NOT NULL PRIMARY KEY, attr1 INT NOT NULL, attr2 INT, attr3 VARCHAR(10), INDEX i1(attr1) ) ENGINE=ndbcluster; alter table t1 rename t2; create database ndbtest; alter table t2 rename ndbtest.t2; drop table ndbtest.t2; drop database ndbtest;
mysql-test/t/ndb_rename.test 0 → 100644 +32 −0 Original line number Diff line number Diff line -- source include/have_ndb.inc -- source include/not_embedded.inc --disable_warnings DROP TABLE IF EXISTS t1,t2; drop database if exists mysqltest; --enable_warnings # # Table rename tests # # # Create a normal table with primary key # CREATE TABLE t1 ( pk1 INT NOT NULL PRIMARY KEY, attr1 INT NOT NULL, attr2 INT, attr3 VARCHAR(10), INDEX i1(attr1) ) ENGINE=ndbcluster; alter table t1 rename t2; create database ndbtest; alter table t2 rename ndbtest.t2; drop table ndbtest.t2; drop database ndbtest; # End of 4.1 tests
ndb/include/ndbapi/NdbDictionary.hpp +20 −3 Original line number Diff line number Diff line Loading @@ -1182,6 +1182,15 @@ public: const Index * getIndex(const char * indexName, const char * tableName) const; /** * Get index with given name, NULL if undefined * @param indexName Name of index to get. * @param Table instance table that index belongs to. * @return index if successful, otherwise 0. */ const Index * getIndex(const char * indexName, const Table & table) const; /** * Fetch list of indexes of given table. * @param list Reference to list where to store the listed indexes Loading Loading @@ -1230,14 +1239,14 @@ public: /** * Create defined table given defined Table instance * @param table Table to create * @param Table instance to create * @return 0 if successful otherwise -1. */ int createTable(const Table &table); /** * Drop table given retrieved Table instance * @param table Table to drop * @param Table instance to drop * @return 0 if successful otherwise -1. */ int dropTable(Table & table); Loading Loading @@ -1302,6 +1311,14 @@ public: int dropIndex(const char * indexName, const char * tableName); /** * Drop index the defined Index instance * @param Index to drop * @return 0 if successful otherwise -1. */ int dropIndex(const Index &); #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL /** * Invalidate cached index object Loading
ndb/src/ndbapi/NdbDictionary.cpp +16 −0 Original line number Diff line number Diff line Loading @@ -800,6 +800,12 @@ NdbDictionary::Dictionary::dropIndex(const char * indexName, return m_impl.dropIndex(indexName, tableName); } int NdbDictionary::Dictionary::dropIndex(const Index & ind) { return m_impl.dropIndex(NdbIndexImpl::getImpl(ind)); } const NdbDictionary::Index * NdbDictionary::Dictionary::getIndex(const char * indexName, const char * tableName) const Loading @@ -810,6 +816,16 @@ NdbDictionary::Dictionary::getIndex(const char * indexName, return 0; } const NdbDictionary::Index * NdbDictionary::Dictionary::getIndex(const char * indexName, const Table & t) const { NdbIndexImpl * i = m_impl.getIndex(indexName, & NdbTableImpl::getImpl(t)); if(i) return i->m_facade; return 0; } void NdbDictionary::Dictionary::invalidateIndex(const char * indexName, const char * tableName){ Loading
ndb/src/ndbapi/NdbDictionaryImpl.cpp +5 −22 Original line number Diff line number Diff line Loading @@ -2267,7 +2267,7 @@ NdbDictionaryImpl::dropIndex(const char * indexName, m_error.code = 4243; return -1; } int ret = dropIndex(*idx, tableName); int ret = dropIndex(*idx); //, tableName); // If index stored in cache is incompatible with the one in the kernel // we must clear the cache and try again if (ret == INCOMPATIBLE_VERSION) { Loading @@ -2289,42 +2289,25 @@ NdbDictionaryImpl::dropIndex(const char * indexName, } int NdbDictionaryImpl::dropIndex(NdbIndexImpl & impl, const char * tableName) NdbDictionaryImpl::dropIndex(NdbIndexImpl & impl) { const char * indexName = impl.getName(); if (tableName || m_ndb.usingFullyQualifiedNames()) { NdbTableImpl * timpl = impl.m_table; if (timpl == 0) { m_error.code = 709; return -1; } const BaseString internalIndexName((tableName) ? m_ndb.internalize_index_name(getTable(tableName), indexName) : m_ndb.internalize_table_name(indexName)); // Index is also a table if(impl.m_status == NdbDictionary::Object::New){ return dropIndex(indexName, tableName); } int ret = m_receiver.dropIndex(impl, *timpl); if(ret == 0){ m_localHash.drop(internalIndexName.c_str()); m_localHash.drop(timpl->m_internalName.c_str()); m_globalHash->lock(); impl.m_table->m_status = NdbDictionary::Object::Invalid; m_globalHash->drop(impl.m_table); timpl->m_status = NdbDictionary::Object::Invalid; m_globalHash->drop(timpl); m_globalHash->unlock(); } return ret; } m_error.code = 4243; return -1; } int NdbDictInterface::dropIndex(const NdbIndexImpl & impl, const NdbTableImpl & timpl) Loading