From 7a7ac8f63ad6e1ba7f74ac2c85bcb4b8df3b16ee Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 15 Dec 2004 12:17:29 +0100 Subject: [PATCH] wl2240 - ndb - scan only 1 fragment if possible ndb/src/common/debugger/signaldata/ScanTab.cpp: Fix printout ndb/src/ndbapi/NdbDictionaryImpl.cpp: Set distribution key for ordered indexes ndb/src/ndbapi/NdbDictionaryImpl.hpp: Allow create_index_object to modify index_table ndb/tools/restore/consumer_restore.cpp: Allow create_index_object to modify index_table --- .../common/debugger/signaldata/ScanTab.cpp | 2 +- ndb/src/ndbapi/NdbDictionaryImpl.cpp | 28 ++++++++++++++++--- ndb/src/ndbapi/NdbDictionaryImpl.hpp | 4 +-- ndb/tools/restore/consumer_restore.cpp | 2 +- 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/ndb/src/common/debugger/signaldata/ScanTab.cpp b/ndb/src/common/debugger/signaldata/ScanTab.cpp index 941d6a1514e..247ddbfe8e2 100644 --- a/ndb/src/common/debugger/signaldata/ScanTab.cpp +++ b/ndb/src/common/debugger/signaldata/ScanTab.cpp @@ -41,7 +41,7 @@ printSCANTABREQ(FILE * output, const Uint32 * theData, Uint32 len, Uint16 receiv sig->getDistributionKeyFlag(requestInfo)); if(sig->getDistributionKeyFlag(requestInfo)) - fprintf(output, " DKey: %u", sig->distributionKey); + fprintf(output, " DKey: %x", sig->distributionKey); Uint32 keyLen = (sig->attrLenKeyLen >> 16); Uint32 attrLen = (sig->attrLenKeyLen & 0xFFFF); diff --git a/ndb/src/ndbapi/NdbDictionaryImpl.cpp b/ndb/src/ndbapi/NdbDictionaryImpl.cpp index 6c052dac9f0..a283589055e 100644 --- a/ndb/src/ndbapi/NdbDictionaryImpl.cpp +++ b/ndb/src/ndbapi/NdbDictionaryImpl.cpp @@ -1930,7 +1930,7 @@ NdbDictionaryImpl::getIndexImpl(const char * externalName, int NdbDictInterface::create_index_obj_from_table(NdbIndexImpl** dst, - const NdbTableImpl* tab, + NdbTableImpl* tab, const NdbTableImpl* prim){ NdbIndexImpl *idx = new NdbIndexImpl(); idx->m_version = tab->m_version; @@ -1938,23 +1938,43 @@ NdbDictInterface::create_index_obj_from_table(NdbIndexImpl** dst, idx->m_indexId = tab->m_tableId; idx->m_externalName.assign(tab->getName()); idx->m_tableName.assign(prim->m_externalName); - idx->m_type = tab->m_indexType; + NdbDictionary::Index::Type type = idx->m_type = tab->m_indexType; idx->m_logging = tab->m_logging; // skip last attribute (NDB$PK or NDB$TNODE) + + Uint32 distKeys = 0; for(unsigned i = 0; i+1m_columns.size(); i++){ + NdbColumnImpl* org = tab->m_columns[i]; + NdbColumnImpl* col = new NdbColumnImpl; // Copy column definition - *col = *tab->m_columns[i]; + *col = * org; idx->m_columns.push_back(col); + /** * reverse map */ - int key_id = prim->getColumn(col->getName())->getColumnNo(); + const NdbColumnImpl* primCol = prim->getColumn(col->getName()); + int key_id = primCol->getColumnNo(); int fill = -1; idx->m_key_ids.fill(key_id, fill); idx->m_key_ids[key_id] = i; col->m_keyInfoPos = key_id; + + /** + * Fix distribution key stuff for ordered indexes + */ + if(type == NdbDictionary::Index::OrderedIndex) + { + if(primCol->m_distributionKey || + (prim->m_noOfDistributionKeys == 0 && primCol->getPrimaryKey())) + { + distKeys++; + org->m_distributionKey = 1; + } + } } + tab->m_noOfDistributionKeys = distKeys; * dst = idx; return 0; diff --git a/ndb/src/ndbapi/NdbDictionaryImpl.hpp b/ndb/src/ndbapi/NdbDictionaryImpl.hpp index 38477e95d99..3ea20e2af16 100644 --- a/ndb/src/ndbapi/NdbDictionaryImpl.hpp +++ b/ndb/src/ndbapi/NdbDictionaryImpl.hpp @@ -303,8 +303,8 @@ public: bool fullyQualifiedNames); static int create_index_obj_from_table(NdbIndexImpl ** dst, - const NdbTableImpl*, - const NdbTableImpl*); + NdbTableImpl* index_table, + const NdbTableImpl* primary_table); NdbError & m_error; private: diff --git a/ndb/tools/restore/consumer_restore.cpp b/ndb/tools/restore/consumer_restore.cpp index e2c55e5a0b1..ce1beb4aaa7 100644 --- a/ndb/tools/restore/consumer_restore.cpp +++ b/ndb/tools/restore/consumer_restore.cpp @@ -209,7 +209,7 @@ BackupRestore::endOfTables(){ NdbDictionary::Dictionary* dict = m_ndb->getDictionary(); for(size_t i = 0; i split;