19 #include <NDBT_Table.hpp>
20 #include <NDBT_Tables.hpp>
29 static const NdbDictionary::Column::StorageType MM=
30 NdbDictionary::Column::StorageTypeMemory;
31 static const NdbDictionary::Column::StorageType DD=
32 NdbDictionary::Column::StorageTypeDisk;
321 char* I1_Indexes[] = {
322 "UNIQUE",
"ID",
"PORT",
"ACCESSNODE",
"POP",
"PORTSTATE", 0,
350 char* I2_Indexes[] = {
351 "ORDERED",
"CUSTOMER_ID", 0,
352 "ORDERED",
"NUM_IP", 0,
382 char* I3_Indexes[] = {
409 const char* BigVarDefault =
411 "KOL7 default in table D2"
412 "KOL7 default in table D2"
413 "KOL7 default in table D2"
414 "KOL7 default in table D2"
415 "KOL7 default in table D2"
416 "KOL7 default in table D2"
417 "KOL7 default in table D2"
418 "KOL7 default in table D2"
419 "KOL7 default in table D2"
420 "KOL7 default in table D2"
421 "KOL7 default in table D2"
422 "KOL7 default in table D2"
423 "KOL7 default in table D2"
424 "KOL7 default in table D2"
425 "KOL7 default in table D2"
426 "KOL7 default in table D2";
428 static unsigned smallUintDefault = 77;
435 &smallUintDefault,
sizeof(
unsigned)),
438 "\x1E" "A default value for KOL4 in D2", 31),
444 "\x1E""A default value for KOL8 in D2", 31)
474 int numTestTables =
sizeof(test_tables)/
sizeof(
NDBT_Table*);
674 int numFailTables =
sizeof(fail_tables)/
sizeof(
NDBT_Table*);
745 NDBT_Table SYSTEM_VALUES(
"SYSTEM_VALUES",
sizeof(SYSTEM_VALUES_Attribs)/
sizeof(
NDBT_Attribute), SYSTEM_VALUES_Attribs);
758 NDBT_Table ACCOUNT_TYPES(
"ACCOUNT_TYPE",
sizeof(ACCOUNT_TYPES_Attribs)/
sizeof(
NDBT_Attribute), ACCOUNT_TYPES_Attribs);
775 int numUtilTables =
sizeof(util_tables)/
sizeof(
NDBT_Table*);
793 NDBT_Tables::MaxVarTypeKeyBytes,
true),
795 NDBT_Tables::MaxKeyMaxVarTypeAttrBytes,
false)
800 NDBT_Table WIDE_2COL(
"WIDE_2COL",
sizeof(WIDE_2COL_ATTRIBS)/
812 NDBT_Tables::MaxVarTypeKeyBytes,
true),
814 NDBT_Tables::MaxKeyMaxVarTypeAttrBytesIndex ,
false)
818 NDBT_Table WIDE_2COL_IX(
"WIDE_2COL_IX",
sizeof(WIDE_2COL_IX_ATTRIBS)/
822 const char* WIDE_2COL_IX_Indexes[] = {
838 NDBT_Tables::MaxVarTypeKeyBytes,
true),
840 NDBT_Tables::MaxKeyMaxVarTypeAttrBytes -
841 NDBT_Tables::HugoOverheadBytes,
false),
849 NDBT_Table WIDE_MAXKEY_HUGO(
"WIDE_MAXKEY_HUGO",
sizeof(WIDE_MAXKEY_HUGO_ATTRIBS)/
863 NDBT_Tables::MinKeyMaxVarTypeAttrBytes -
864 NDBT_Tables::HugoOverheadBytes,
false),
872 NDBT_Table WIDE_MAXATTR_HUGO(
"WIDE_MAXATTR_HUGO",
sizeof(WIDE_MAXATTR_HUGO_ATTRIBS)/
877 static NDBT_Table* WIDE_MAXKEYMAXCOLS_HUGO= NULL;
882 if (WIDE_MAXKEYMAXCOLS_HUGO == NULL)
888 const int buffsize=100;
889 char namebuff[buffsize];
893 for (;attrNum < (NDB_MAX_ATTRIBUTES_IN_INDEX - 1); attrNum ++)
904 (NDB_MAX_KEYSIZE_IN_WORDS -
905 (NDB_MAX_ATTRIBUTES_IN_INDEX -1)) * 4,
911 for (;attrNum < (NDB_MAX_ATTRIBUTES_IN_TABLE - 1); attrNum ++)
921 Uint32 sz32 = NDB_MAX_TUPLE_SIZE_IN_WORDS;
922 sz32 -= NDB_MAX_KEYSIZE_IN_WORDS;
923 sz32 -= NDB_MAX_ATTRIBUTES_IN_INDEX;
924 sz32 -= 2 * NDB_MAX_ATTRIBUTES_IN_TABLE;
929 WIDE_MAXKEYMAXCOLS_HUGO=
new NDBT_Table(name, NDB_MAX_ATTRIBUTES_IN_TABLE,
933 for (attrNum=0; attrNum < NDB_MAX_ATTRIBUTES_IN_TABLE; attrNum++)
934 delete attrs[attrNum];
938 return WIDE_MAXKEYMAXCOLS_HUGO;
941 static NDBT_Table* WIDE_MINKEYMAXCOLS_HUGO= NULL;
944 NDBT_Table* createMinKeyMaxColsHugoTabDef(
const char* name)
946 if (WIDE_MINKEYMAXCOLS_HUGO == NULL)
952 const int buffsize=100;
953 char namebuff[buffsize];
961 for (;attrNum < (NDB_MAX_ATTRIBUTES_IN_TABLE - 1); attrNum ++)
973 (NDB_MAX_TUPLE_SIZE_IN_WORDS -
974 (NDB_MAX_ATTRIBUTES_IN_TABLE - 1)) * 4,
977 WIDE_MINKEYMAXCOLS_HUGO=
new NDBT_Table(name, NDB_MAX_ATTRIBUTES_IN_TABLE,
981 for (attrNum=0; attrNum < NDB_MAX_ATTRIBUTES_IN_TABLE; attrNum++)
982 delete attrs[attrNum];
987 return WIDE_MINKEYMAXCOLS_HUGO;
996 TableGenerator tabGen;
1003 {
"WIDE_2COL", &WIDE_2COL, NULL},
1004 {
"WIDE_2COL_IX", &WIDE_2COL_IX, NULL},
1005 {
"WIDE_MAXKEY_HUGO", &WIDE_MAXKEY_HUGO, NULL},
1006 {
"WIDE_MAXATTR_HUGO", &WIDE_MAXATTR_HUGO, NULL},
1007 {
"WIDE_MAXKEYMAXCOLS_HUGO", NULL, createMaxKeyMaxColsHugoTabDef},
1008 {
"WIDE_MINKEYMAXCOLS_HUGO", NULL, createMinKeyMaxColsHugoTabDef}
1013 int numOtherTables =
sizeof(other_tables)/
sizeof(
OtherTable);
1018 const char * m_table;
1019 const char ** m_indexes;
1025 {
"I1", I1_Indexes },
1026 {
"I2", I2_Indexes },
1027 {
"I3", I3_Indexes },
1028 {
"WIDE_2COL_IX", WIDE_2COL_IX_Indexes },
1034 NDBT_Tables::getTable(
const char* _nam){
1038 for (i=0; i<numTestTables; i++){
1039 if (strcmp(test_tables[i]->getName(), _nam) == 0){
1040 return test_tables[
i];
1043 for (i=0; i<numFailTables; i++){
1044 if (strcmp(fail_tables[i]->getName(), _nam) == 0){
1045 return fail_tables[
i];
1048 for (i=0; i<numUtilTables; i++){
1049 if (strcmp(util_tables[i]->getName(), _nam) == 0){
1050 return util_tables[
i];
1053 for(i=0; i<numOtherTables; i++){
1054 if (strcmp(other_tables[i].name, _nam) == 0){
1055 return (other_tables[i].tab != NULL)?
1056 other_tables[
i].tab :
1057 (*other_tables[
i].tabGen)(other_tables[i].name);
1066 if(sscanf(_nam,
"TPK_%d", &pkSizeOfTable) == 1){
1067 return tableWithPkSize(_nam, pkSizeOfTable);
1073 NDBT_Tables::tableWithPkSize(
const char* _nam, Uint32 pkSize){
1101 NDBT_Tables::getTable(
int _num){
1103 assert(_num < numTestTables);
1104 return test_tables[_num];
1108 NDBT_Tables::getNumTables(){
1109 return numTestTables;
1113 NDBT_Tables::getIndexes(
const char*
table)
1116 for (i = 0; indexes[
i].m_table != 0; i++) {
1117 if (strcmp(indexes[i].m_table, table) == 0)
1118 return indexes[
i].m_indexes;
1124 NDBT_Tables::createAllTables(
Ndb* pNdb,
bool _temp,
bool existsOk){
1126 for (
int i=0; i < NDBT_Tables::getNumTables(); i++){
1128 int ret= createTable(pNdb,
1129 NDBT_Tables::getTable(i)->getName(), _temp, existsOk);
1138 NDBT_Tables::createAllTables(
Ndb* pNdb){
1139 return createAllTables(pNdb,
false);
1143 NDBT_Tables::create_default_tablespace(
Ndb* pNdb)
1151 if (NdbEnv_GetEnv(
"UNDOBUFFER", buf,
sizeof(buf)))
1154 ndbout_c(
"Using %umb dd-undo-buffer", mb);
1159 if (strcmp(lg.getName(),
"DEFAULT-LG") != 0)
1161 lg.setName(
"DEFAULT-LG");
1162 lg.setUndoBufferSize(mb*1024*1024);
1163 res = pDict->createLogfileGroup(lg);
1165 g_err <<
"Failed to create logfilegroup:"
1176 if (NdbEnv_GetEnv(
"UNDOSIZE", buf,
sizeof(buf)))
1179 ndbout_c(
"Using %umb dd-undo", mb);
1185 if (NdbEnv_GetEnv(
"UNDOFILES", buf,
sizeof(buf)))
1188 ndbout_c(
"Using max %u dd-undo files", files);
1193 while (mb > files * sz)
1196 for (Uint32 i = 0; i * sz < mb; i++)
1201 if (strcmp(uf.getPath(), tmp) != 0)
1204 uf.setSize(Uint64(sz)*1024*1024);
1205 uf.setLogfileGroup(
"DEFAULT-LG");
1207 res = pDict->createUndofile(uf,
true);
1209 g_err <<
"Failed to create undofile:"
1217 if (strcmp(ts.getName(),
"DEFAULT-TS") != 0)
1219 ts.setName(
"DEFAULT-TS");
1220 ts.setExtentSize(1024*1024);
1221 ts.setDefaultLogfileGroup(
"DEFAULT-LG");
1223 res = pDict->createTablespace(ts);
1225 g_err <<
"Failed to create tablespace:"
1234 if (NdbEnv_GetEnv(
"DATASIZE", buf,
sizeof(buf)))
1237 ndbout_c(
"Using %umb dd-data", mb);
1245 if (NdbEnv_GetEnv(
"DATAFILES", buf,
sizeof(buf)))
1248 ndbout_c(
"Using max %u dd-data files", files);
1252 while (mb > files * sz)
1254 for (Uint32 i = 0; i * sz < mb; i++)
1259 if (strcmp(df.getPath(), tmp) != 0)
1262 df.setSize(Uint64(sz)*1024*1024);
1263 df.setTablespace(
"DEFAULT-TS");
1265 res = pDict->createDatafile(df,
true);
1267 g_err <<
"Failed to create datafile:"
1278 NDBT_Tables::createTable(
Ndb* pNdb,
const char* _name,
bool _temp,
1279 bool existsOk, NDBT_CreateTableHook f,
void* arg)
1283 ndbout <<
"Could not create table " << _name
1284 <<
", it doesn't exist in list of tables "\
1285 "that NDBT_Tables can create!" << endl;
1286 return NDBT_WRONGARGS;
1290 for (Uint32 i = 0; i<strlen(_name); i++)
1291 sum += 33 * sum + (Uint32)_name[
i];
1293 bool forceVarPart = (sum & 1);
1298 tmpTab.setStoredTable(_temp ? 0 : 1);
1299 tmpTab.setForceVarPart(forceVarPart);
1303 int ret = tmpTab.validate(error);
1306 if(f != 0 && f(pNdb, tmpTab, 0, arg))
1308 ndbout <<
"Failed to create table" << endl;
1317 if (create_default_tablespace(pNdb) == 0)
1336 for(i = 0; indexes[
i].m_table != 0; i++){
1337 if(strcmp(indexes[i].m_table, _name) != 0)
1340 while(indexes[i].m_indexes[j] != 0){
1343 name.
assfmt(
"%s$NDBT_IDX%d", _name, j);
1346 bool logging = !_temp;
1347 if(strcmp(indexes[i].m_indexes[j],
"ORDERED") == 0){
1350 }
else if(strcmp(indexes[i].m_indexes[j],
"UNIQUE") == 0){
1353 ndbout <<
"Unknown index type";
1359 while(indexes[i].m_indexes[j] != 0){
1364 if (tmpTab.getTemporary())
1366 tmpIndx.setTemporary(
true);
1375 if(f != 0 && f(pNdb, tmpTab, 1, arg))
1377 ndbout <<
"Failed to create table" << endl;
1386 NDBT_Tables::dropAllTables(
Ndb* pNdb){
1388 for (
int i=0; i < NDBT_Tables::getNumTables(); i++){
1392 return NDBT_ProgramExit(NDBT_FAILED);
1404 NDBT_Tables::print(
const char * _name){
1408 ndbout <<
"Could not print table " << _name
1409 <<
", it doesn't exist in list of tables "
1410 <<
"that NDBT_Tables can create!" << endl;
1411 return NDBT_WRONGARGS;
1413 ndbout << (* tab) << endl;
1418 NDBT_Tables::printAll(){
1420 for (
int i=0; i < getNumTables(); i++){