From ef0d6d35ea8b19a9d66f1c0f676cbf71aa3462a7 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 11 Aug 2004 10:03:43 +0200 Subject: [PATCH] Add indexes to test toolkit ndb/test/include/NDBT_Table.hpp: Remove unused parameter ndb/test/include/NDBT_Tables.hpp: Add existsOk ndb/test/src/NDBT_Tables.cpp: Rename C2_* tables to I{123} Add indexes to I{123} ndb/test/src/NDBT_Test.cpp: Rename C2_* tables to I{123} Add indexes to I{123} --- ndb/test/include/NDBT_Table.hpp | 5 +- ndb/test/include/NDBT_Tables.hpp | 3 +- ndb/test/src/NDBT_Tables.cpp | 139 +++++++++++++++++++++++-------- ndb/test/src/NDBT_Test.cpp | 2 +- 4 files changed, 111 insertions(+), 38 deletions(-) diff --git a/ndb/test/include/NDBT_Table.hpp b/ndb/test/include/NDBT_Table.hpp index 94d7d5dda3b..59db3ed1092 100644 --- a/ndb/test/include/NDBT_Table.hpp +++ b/ndb/test/include/NDBT_Table.hpp @@ -50,13 +50,12 @@ public: NDBT_Table(const char* name, int noOfAttributes, - const NdbDictionary::Column attributes[], - bool stored = true) + const NdbDictionary::Column attributes[]) : NdbDictionary::Table(name) { assert(name != 0); - setStoredTable(stored); + //setStoredTable(stored); for(int i = 0; igetDictionary()->createTable(tmpTab); - int err = pNdb->getDictionary()->getNdbError().code; - if(r == -1){ - if (existsOk && err == 721) - ; - else { - return NDBT_FAILED; - } - } + int ret= createTable(pNdb, + NDBT_Tables::getTable(i)->getName(), _temp, existsOk); + if(ret) + return ret; } return NDBT_OK; } @@ -794,7 +817,8 @@ NDBT_Tables::createAllTables(Ndb* pNdb){ } int -NDBT_Tables::createTable(Ndb* pNdb, const char* _name, bool _temp){ +NDBT_Tables::createTable(Ndb* pNdb, const char* _name, bool _temp, + bool existsOk){ const NdbDictionary::Table* tab = NDBT_Tables::getTable(_name); if (tab == NULL){ @@ -804,10 +828,59 @@ NDBT_Tables::createTable(Ndb* pNdb, const char* _name, bool _temp){ return NDBT_WRONGARGS; } - NdbDictionary::Table tmpTab(* tab); - tmpTab.setStoredTable(_temp ? 0 : 1); + int r = 0; + do { + NdbDictionary::Table tmpTab(* tab); + tmpTab.setStoredTable(_temp ? 0 : 1); + + r = pNdb->getDictionary()->createTable(tmpTab); + if(r == -1){ + if(!existsOk) + break; + if(pNdb->getDictionary()->getNdbError().code != 721){ + ndbout << pNdb->getDictionary()->getNdbError() << endl; + break; + } + r = 0; + } + + Uint32 i = 0; + for(Uint32 i = 0; indexes[i].m_table != 0; i++){ + if(strcmp(indexes[i].m_table, _name) != 0) + continue; + Uint32 j = 0; + while(indexes[i].m_indexes[j] != 0){ + NdbDictionary::Index tmpIndx; + BaseString name; + name.assfmt("%s$NDBT_IDX%d", _name, j); + tmpIndx.setName(name.c_str()); + tmpIndx.setTable(_name); + bool logging = !_temp; + if(strcmp(indexes[i].m_indexes[j], "ORDERED") == 0){ + logging = false; + tmpIndx.setType(NdbDictionary::Index::OrderedIndex); + } else if(strcmp(indexes[i].m_indexes[j], "UNIQUE") == 0){ + tmpIndx.setType(NdbDictionary::Index::UniqueHashIndex); + } else { + ndbout << "Unknown index type"; + abort(); + } + tmpIndx.setLogging(logging); + + j++; + while(indexes[i].m_indexes[j] != 0){ + tmpIndx.addIndexColumn(indexes[i].m_indexes[j]); + j++; + } + j++; + if(pNdb->getDictionary()->createIndex(tmpIndx) != 0){ + ndbout << pNdb->getDictionary()->getNdbError() << endl; + return NDBT_FAILED; + } + } + } + } while(false); - int r = pNdb->getDictionary()->createTable(tmpTab); return r; } diff --git a/ndb/test/src/NDBT_Test.cpp b/ndb/test/src/NDBT_Test.cpp index e5ad531675d..a93c85d3bbe 100644 --- a/ndb/test/src/NDBT_Test.cpp +++ b/ndb/test/src/NDBT_Test.cpp @@ -828,7 +828,7 @@ void NDBT_TestSuite::execute(Ndb* ndb, const NdbDictionary::Table* pTab, continue; } - if(pDict->createTable(* pTab) != 0){ + if(NDBT_Tables::createTable(ndb, pTab->getName()) != 0){ numTestsFail++; numTestsExecuted++; g_err << "ERROR1: Failed to create table " << pTab->getName()