const NdbDictionary::Table* NDBT_Tables::tableWithPkSize(const char* _nam, Uint32 pkSize){ NdbDictionary::Table* tab = new NdbDictionary::Table(_nam); // Add one PK of the desired length tab->addColumn(NDBT_Attribute("PK1", NdbDictionary::Column::Char, pkSize, true)); // Add 4 attributes tab->addColumn(NDBT_Attribute("ATTR1", NdbDictionary::Column::Char, 21)); tab->addColumn(NDBT_Attribute("ATTR2", NdbDictionary::Column::Char, 124)); tab->addColumn(NDBT_Attribute("ATTR3", NdbDictionary::Column::Unsigned)); tab->addColumn(NDBT_Attribute("ATTR4", NdbDictionary::Column::Unsigned)); return tab; }
int create100Tables(NDBT_Context* ctx, NDBT_Step* step) { Ndb* pNdb = GETNDB(step); const NdbDictionary::Table* pTab= ctx->getTab(); /* Run as a 'T1' testcase - do nothing for other tables */ if (strcmp(pTab->getName(), "T1") != 0) return NDBT_OK; for (Uint32 t=0; t < 100; t++) { char tabnameBuff[10]; snprintf(tabnameBuff, sizeof(tabnameBuff), "TAB%u", t); NdbDictionary::Table tab; tab.setName(tabnameBuff); NdbDictionary::Column pk; pk.setName("PK"); pk.setType(NdbDictionary::Column::Varchar); pk.setLength(20); pk.setNullable(false); pk.setPrimaryKey(true); tab.addColumn(pk); pNdb->getDictionary()->dropTable(tab.getName()); if(pNdb->getDictionary()->createTable(tab) != 0) { ndbout << "Create table failed with error : " << pNdb->getDictionary()->getNdbError().code << " " << pNdb->getDictionary()->getNdbError().message << endl; return NDBT_FAILED; } ndbout << "Created table " << tabnameBuff << endl; } return NDBT_OK; }