From 66f7bd24414724af26b2bf690e03ff3fe7ccbb4a Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 16 Dec 2004 11:14:24 +0100 Subject: [PATCH] wl2240 - ndb - more testing ndb/test/ndbapi/testPartitioning.cpp: Update test partitioning to add primary keys (distribution keys) incase of either - only 1 primary key - primary keys with charsets ndb/test/src/HugoCalculator.cpp: Fix so that Hugo can cope with pk's in the "end" of the table --- ndb/test/ndbapi/testPartitioning.cpp | 55 ++++++++++++++++++++++------ ndb/test/src/HugoCalculator.cpp | 3 +- 2 files changed, 46 insertions(+), 12 deletions(-) diff --git a/ndb/test/ndbapi/testPartitioning.cpp b/ndb/test/ndbapi/testPartitioning.cpp index d67878f65e3..dd030863a5a 100644 --- a/ndb/test/ndbapi/testPartitioning.cpp +++ b/ndb/test/ndbapi/testPartitioning.cpp @@ -60,20 +60,53 @@ add_distribution_key(Ndb*, NdbDictionary::Table& tab, int when) int keys = tab.getNoOfPrimaryKeys(); int dks = (2 * keys + 2) / 3; dks = (dks > max_dks ? max_dks : dks); int cnt = 0; - ndbout_c("%s pks: %d dks: %d", tab.getName(), keys, dks); + for(unsigned i = 0; igetPrimaryKey()) - { - if(dks >= keys || (rand() % 100) > 50) - { - col->setDistributionKey(true); - dks--; - } + if(tab.getColumn(i)->getPrimaryKey() && + tab.getColumn(i)->getCharset() != 0) keys--; + + Uint32 max = NDB_MAX_NO_OF_ATTRIBUTES_IN_KEY - tab.getNoOfPrimaryKeys(); + + if(max_dks < max) + max = max_dks; + + if(keys <= 1 && max > 0) + { + dks = 1 + (rand() % max); + ndbout_c("%s pks: %d dks: %d", tab.getName(), keys, dks); + while(dks--) + { + NdbDictionary::Column col; + BaseString name; + name.assfmt("PK_DK_%d", dks); + col.setName(name.c_str()); + col.setType(NdbDictionary::Column::Unsigned); + col.setLength(1); + col.setNullable(false); + col.setPrimaryKey(1); + col.setDistributionKey(true); + tab.addColumn(col); + } + } + else + { + for(unsigned i = 0; igetPrimaryKey() && col->getCharset() == 0) + { + if(dks >= keys || (rand() % 100) > 50) + { + col->setDistributionKey(true); + dks--; + } + keys--; + } } } + ndbout << (NDBT_Table&)tab << endl; + return 0; } @@ -81,7 +114,7 @@ static int run_create_table(NDBT_Context* ctx, NDBT_Step* step) { max_dks = ctx->getProperty("distributionkey", (unsigned)0); - + if(NDBT_Tables::createTable(GETNDB(step), ctx->getTab()->getName(), false, false, diff --git a/ndb/test/src/HugoCalculator.cpp b/ndb/test/src/HugoCalculator.cpp index a885a2371f1..20bcc445541 100644 --- a/ndb/test/src/HugoCalculator.cpp +++ b/ndb/test/src/HugoCalculator.cpp @@ -40,7 +40,8 @@ HugoCalculator::HugoCalculator(const NdbDictionary::Table& tab) : m_tab(tab) { // The "number of updates" column for this table is found in the last column for (i=m_tab.getNoOfColumns()-1; i>=0; i--){ const NdbDictionary::Column* attr = m_tab.getColumn(i); - if (attr->getType() == NdbDictionary::Column::Unsigned){ + if (attr->getType() == NdbDictionary::Column::Unsigned && + !attr->getPrimaryKey()){ m_updatesCol = i; break; }