Commit a3b74b30 authored by joreland@mysql.com's avatar joreland@mysql.com

wl2240 - ndb - more testing

parent 9cc5abd2
...@@ -60,11 +60,41 @@ add_distribution_key(Ndb*, NdbDictionary::Table& tab, int when) ...@@ -60,11 +60,41 @@ add_distribution_key(Ndb*, NdbDictionary::Table& tab, int when)
int keys = tab.getNoOfPrimaryKeys(); int keys = tab.getNoOfPrimaryKeys();
int dks = (2 * keys + 2) / 3; dks = (dks > max_dks ? max_dks : dks); int dks = (2 * keys + 2) / 3; dks = (dks > max_dks ? max_dks : dks);
int cnt = 0; int cnt = 0;
for(unsigned i = 0; i<tab.getNoOfColumns(); i++)
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); 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; i<tab.getNoOfColumns(); i++) for(unsigned i = 0; i<tab.getNoOfColumns(); i++)
{ {
NdbDictionary::Column* col = tab.getColumn(i); NdbDictionary::Column* col = tab.getColumn(i);
if(col->getPrimaryKey()) if(col->getPrimaryKey() && col->getCharset() == 0)
{ {
if(dks >= keys || (rand() % 100) > 50) if(dks >= keys || (rand() % 100) > 50)
{ {
...@@ -74,6 +104,9 @@ add_distribution_key(Ndb*, NdbDictionary::Table& tab, int when) ...@@ -74,6 +104,9 @@ add_distribution_key(Ndb*, NdbDictionary::Table& tab, int when)
keys--; keys--;
} }
} }
}
ndbout << (NDBT_Table&)tab << endl;
return 0; return 0;
} }
......
...@@ -40,7 +40,8 @@ HugoCalculator::HugoCalculator(const NdbDictionary::Table& tab) : m_tab(tab) { ...@@ -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 // The "number of updates" column for this table is found in the last column
for (i=m_tab.getNoOfColumns()-1; i>=0; i--){ for (i=m_tab.getNoOfColumns()-1; i>=0; i--){
const NdbDictionary::Column* attr = m_tab.getColumn(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; m_updatesCol = i;
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment