diff options
author | mskold@mysql.com <> | 2006-05-30 13:20:38 +0200 |
---|---|---|
committer | mskold@mysql.com <> | 2006-05-30 13:20:38 +0200 |
commit | f838e8a4991573db3c2f46f53c0d1ad0c3b48fc8 (patch) | |
tree | 53e249892e3340722c48b7ecca3124c706ccd085 /ndb | |
parent | 1504abcdd5b86eecd2a8eef54b5439a94e3b845e (diff) | |
parent | 4efdebeddf81c01b57f3745f50ca38d8339c7d99 (diff) | |
download | mariadb-git-f838e8a4991573db3c2f46f53c0d1ad0c3b48fc8.tar.gz |
Merge mskold@bk-internal.mysql.com:/home/bk/mysql-4.1
into mysql.com:/home/marty/MySQL/mysql-4.1
Diffstat (limited to 'ndb')
-rw-r--r-- | ndb/include/ndbapi/NdbDictionary.hpp | 23 | ||||
-rw-r--r-- | ndb/src/ndbapi/NdbDictionary.cpp | 16 | ||||
-rw-r--r-- | ndb/src/ndbapi/NdbDictionaryImpl.cpp | 27 | ||||
-rw-r--r-- | ndb/src/ndbapi/NdbDictionaryImpl.hpp | 22 |
4 files changed, 57 insertions, 31 deletions
diff --git a/ndb/include/ndbapi/NdbDictionary.hpp b/ndb/include/ndbapi/NdbDictionary.hpp index a541cd5190e..196fd99d09d 100644 --- a/ndb/include/ndbapi/NdbDictionary.hpp +++ b/ndb/include/ndbapi/NdbDictionary.hpp @@ -956,14 +956,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 &); /** * 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 &); @@ -1027,7 +1027,15 @@ 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 &); + /** * Get index with given name, NULL if undefined * @param indexName Name of index to get. @@ -1037,6 +1045,15 @@ public: const Index * getIndex(const char * indexName, const char * tableName); + /** + * 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); + #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL /** * Invalidate cached index object diff --git a/ndb/src/ndbapi/NdbDictionary.cpp b/ndb/src/ndbapi/NdbDictionary.cpp index 00db5704949..8ed85995d69 100644 --- a/ndb/src/ndbapi/NdbDictionary.cpp +++ b/ndb/src/ndbapi/NdbDictionary.cpp @@ -786,6 +786,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) @@ -796,6 +802,16 @@ NdbDictionary::Dictionary::getIndex(const char * indexName, return 0; } +const NdbDictionary::Index * +NdbDictionary::Dictionary::getIndex(const char * indexName, + const Table & t) +{ + 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){ diff --git a/ndb/src/ndbapi/NdbDictionaryImpl.cpp b/ndb/src/ndbapi/NdbDictionaryImpl.cpp index 8b1847502d9..80a584651d1 100644 --- a/ndb/src/ndbapi/NdbDictionaryImpl.cpp +++ b/ndb/src/ndbapi/NdbDictionaryImpl.cpp @@ -2147,7 +2147,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) { @@ -2169,40 +2169,23 @@ 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 char * internalIndexName = (tableName) - ? - m_ndb.internalizeIndexName(getTable(tableName), indexName) - : - m_ndb.internalizeTableName(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); + 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 diff --git a/ndb/src/ndbapi/NdbDictionaryImpl.hpp b/ndb/src/ndbapi/NdbDictionaryImpl.hpp index 602a2d6b6ca..8763a444503 100644 --- a/ndb/src/ndbapi/NdbDictionaryImpl.hpp +++ b/ndb/src/ndbapi/NdbDictionaryImpl.hpp @@ -379,7 +379,8 @@ public: int createIndex(NdbIndexImpl &ix); int dropIndex(const char * indexName, const char * tableName); - int dropIndex(NdbIndexImpl &, const char * tableName); + // int dropIndex(NdbIndexImpl &, const char * tableName); + int dropIndex(NdbIndexImpl &); NdbTableImpl * getIndexTable(NdbIndexImpl * index, NdbTableImpl * table); @@ -397,6 +398,8 @@ public: bool do_add_blob_tables); NdbIndexImpl * getIndex(const char * indexName, const char * tableName); + NdbIndexImpl * getIndex(const char * indexName, + NdbTableImpl * table); NdbIndexImpl * getIndexImpl(const char * name, const char * internalName); NdbEventImpl * getEvent(const char * eventName); NdbEventImpl * getEventImpl(const char * internalName); @@ -643,17 +646,24 @@ NdbDictionaryImpl::get_local_table_info(const char * internalTableName, return info; // autoincrement already initialized } + inline NdbIndexImpl * NdbDictionaryImpl::getIndex(const char * indexName, const char * tableName) { - if (tableName || m_ndb.usingFullyQualifiedNames()) { + return getIndex(indexName, (tableName) ? getTable(tableName) : NULL); +} + +inline +NdbIndexImpl * +NdbDictionaryImpl::getIndex(const char * indexName, + NdbTableImpl * table) +{ + if (table || m_ndb.usingFullyQualifiedNames()) { const char * internalIndexName = 0; - if (tableName) { - NdbTableImpl * t = getTable(tableName); - if (t != 0) - internalIndexName = m_ndb.internalizeIndexName(t, indexName); + if (table) { + internalIndexName = m_ndb.internalizeIndexName(table, indexName); } else { internalIndexName = m_ndb.internalizeTableName(indexName); // Index is also a table |