⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testdict.cpp

📁 mysql-5.0.22.tar.gz源码包
💻 CPP
📖 第 1 页 / 共 4 页
字号:
    UtilTransactions utilTrans(*pTab2);    if ((res = utilTrans.clearTable(pNdb,  records)) != 0){      NdbError err = pNdb->getNdbError(res);      if(err.classification == NdbError::SchemaError){	pNdb->getDictionary()->invalidateTable(pTab->getName());      }      continue;    }  }  g_info << endl;  return NDBT_OK;}intrunCreateMaxTables(NDBT_Context* ctx, NDBT_Step* step){  char tabName[256];  int numTables = ctx->getProperty("tables", 1000);  Ndb* pNdb = GETNDB(step);  NdbDictionary::Dictionary* pDic = pNdb->getDictionary();  int i = 0;  for (i = 0; i < numTables; i++) {    BaseString::snprintf(tabName, 256, "MAXTAB%d", i);    if (pNdb->waitUntilReady(30) != 0) {      // Db is not ready, return with failure      return NDBT_FAILED;    }    const NdbDictionary::Table* pTab = ctx->getTab();    //ndbout << "|- " << tabName << endl;    // Set new name for T1    NdbDictionary::Table newTab(* pTab);    newTab.setName(tabName);    // Drop any old (or try to)    (void)pDic->dropTable(newTab.getName());    // Try to create table in db    if (newTab.createTableInDb(pNdb) != 0) {      ndbout << tabName << " could not be created: "             << pDic->getNdbError() << endl;      if (pDic->getNdbError().code == 707 ||          pDic->getNdbError().code == 708 ||          pDic->getNdbError().code == 826 ||          pDic->getNdbError().code == 827)        break;      return NDBT_FAILED;    }    // Verify that table exists in db        const NdbDictionary::Table* pTab3 =       NDBT_Table::discoverTableFromDb(pNdb, tabName) ;    if (pTab3 == NULL){      ndbout << tabName << " was not found in DB: "             << pDic->getNdbError() << endl;      return NDBT_FAILED;    }    if (! newTab.equal(*pTab3)) {      ndbout << "It was not equal" << endl; abort();      return NDBT_FAILED;    }    int records = ctx->getNumRecords();    HugoTransactions hugoTrans(*pTab3);    if (hugoTrans.loadTable(pNdb, records) != 0) {      ndbout << "It can NOT be loaded" << endl;      return NDBT_FAILED;    }    UtilTransactions utilTrans(*pTab3);    if (utilTrans.clearTable(pNdb, records, 64) != 0) {      ndbout << "It can NOT be cleared" << endl;      return NDBT_FAILED;    }  }  if (pNdb->waitUntilReady(30) != 0) {    // Db is not ready, return with failure    return NDBT_FAILED;  }  ctx->setProperty("maxtables", i);  // HURRAAA!  return NDBT_OK;}int runDropMaxTables(NDBT_Context* ctx, NDBT_Step* step){  char tabName[256];  int numTables = ctx->getProperty("maxtables", (Uint32)0);  Ndb* pNdb = GETNDB(step);  NdbDictionary::Dictionary* pDic = pNdb->getDictionary();  for (int i = 0; i < numTables; i++) {    BaseString::snprintf(tabName, 256, "MAXTAB%d", i);    if (pNdb->waitUntilReady(30) != 0) {      // Db is not ready, return with failure      return NDBT_FAILED;    }    // Verify that table exists in db        const NdbDictionary::Table* pTab3 =       NDBT_Table::discoverTableFromDb(pNdb, tabName) ;    if (pTab3 == NULL) {      ndbout << tabName << " was not found in DB: "             << pDic->getNdbError() << endl;      return NDBT_FAILED;    }    // Try to drop table in db    if (pDic->dropTable(pTab3->getName()) != 0) {      ndbout << tabName << " could not be dropped: "             << pDic->getNdbError() << endl;      return NDBT_FAILED;    }  }  return NDBT_OK;}int runTestFragmentTypes(NDBT_Context* ctx, NDBT_Step* step){  int records = ctx->getNumRecords();  int fragTtype = ctx->getProperty("FragmentType");  Ndb* pNdb = GETNDB(step);  int result = NDBT_OK;  NdbRestarter restarter;  if (pNdb->waitUntilReady(30) != 0){    // Db is not ready, return with failure    return NDBT_FAILED;  }    const NdbDictionary::Table* pTab = ctx->getTab();  pNdb->getDictionary()->dropTable(pTab->getName());  NdbDictionary::Table newTab(* pTab);  // Set fragment type for table      newTab.setFragmentType((NdbDictionary::Object::FragmentType)fragTtype);    // Try to create table in db  if (newTab.createTableInDb(pNdb) != 0){    ndbout << newTab.getName() << " could not be created"	   << ", fragmentType = "<<fragTtype <<endl;    ndbout << pNdb->getDictionary()->getNdbError() << endl;    return NDBT_FAILED;  }    // Verify that table exists in db      const NdbDictionary::Table* pTab3 =     NDBT_Table::discoverTableFromDb(pNdb, pTab->getName()) ;  if (pTab3 == NULL){    ndbout << pTab->getName() << " was not found in DB"<< endl;    return NDBT_FAILED;      }    if (pTab3->getFragmentType() != fragTtype){    ndbout << pTab->getName() << " fragmentType error "<< endl;    result = NDBT_FAILED;    goto drop_the_tab;  }/**   This test does not work since fragmentation is   decided by the kernel, hence the fragementation   attribute on the column will differ  if (newTab.equal(*pTab3) == false){    ndbout << "It was not equal" << endl;    result = NDBT_FAILED;    goto drop_the_tab;  } */  do {        HugoTransactions hugoTrans(*pTab3);    UtilTransactions utilTrans(*pTab3);    int count;    CHECK(hugoTrans.loadTable(pNdb, records) == 0);    CHECK(hugoTrans.pkUpdateRecords(pNdb, records) == 0);    CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);    CHECK(count == records);    CHECK(hugoTrans.pkDelRecords(pNdb, records/2) == 0);    CHECK(hugoTrans.scanUpdateRecords(pNdb, records) == 0);    CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);    CHECK(count == (records/2));    // restart all    ndbout << "Restarting cluster" << endl;    CHECK(restarter.restartAll() == 0);    int timeout = 120;    CHECK(restarter.waitClusterStarted(timeout) == 0);    CHECK(pNdb->waitUntilReady(timeout) == 0);    // Verify content    CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);    CHECK(count == (records/2));    CHECK(utilTrans.clearTable(pNdb, records) == 0);    CHECK(hugoTrans.loadTable(pNdb, records) == 0);    CHECK(utilTrans.clearTable(pNdb, records) == 0);    CHECK(hugoTrans.loadTable(pNdb, records) == 0);    CHECK(hugoTrans.pkUpdateRecords(pNdb, records) == 0);    CHECK(utilTrans.clearTable(pNdb, records, 64) == 0);      } while(false);   drop_the_tab:    // Try to drop table in db  if (pNdb->getDictionary()->dropTable(pTab3->getName()) != 0){    ndbout << pTab3->getName()  << " could not be dropped"<< endl;    result =  NDBT_FAILED;  }    return result;}int runTestTemporaryTables(NDBT_Context* ctx, NDBT_Step* step){  int result = NDBT_OK;  int loops = ctx->getNumLoops();  int records = ctx->getNumRecords();  Ndb* pNdb = GETNDB(step);  int i = 0;  NdbRestarter restarter;    const NdbDictionary::Table* pTab = ctx->getTab();  ndbout << "|- " << pTab->getName() << endl;    NdbDictionary::Table newTab(* pTab);  // Set table as temporary  newTab.setStoredTable(false);    // Try to create table in db  if (newTab.createTableInDb(pNdb) != 0){    return NDBT_FAILED;  }    // Verify that table is in db       const NdbDictionary::Table* pTab2 =     NDBT_Table::discoverTableFromDb(pNdb, pTab->getName());  if (pTab2 == NULL){    ndbout << pTab->getName() << " was not found in DB"<< endl;    return NDBT_FAILED;  }  if (pTab2->getStoredTable() != false){    ndbout << pTab->getName() << " was not temporary in DB"<< endl;    result = NDBT_FAILED;    goto drop_the_tab;  }    while (i < loops && result == NDBT_OK){    ndbout << i << ": ";    HugoTransactions hugoTrans(*pTab2);    CHECK(hugoTrans.loadTable(pNdb, records) == 0);    int count = 0;    UtilTransactions utilTrans(*pTab2);    CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);    CHECK(count == records);    // restart all    ndbout << "Restarting cluster" << endl;    CHECK(restarter.restartAll() == 0);    int timeout = 120;    CHECK(restarter.waitClusterStarted(timeout) == 0);    CHECK(pNdb->waitUntilReady(timeout) == 0);    ndbout << "Verifying records..." << endl;    CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);    CHECK(count == 0);    i++;  } drop_the_tab:     if (pNdb->getDictionary()->dropTable(pTab2->getName()) != 0){    ndbout << "Failed to drop "<<pTab2->getName()<<" in db" << endl;    result = NDBT_FAILED;  }    // Verify that table is not in db       const NdbDictionary::Table* pTab3 =     NDBT_Table::discoverTableFromDb(pNdb, pTab->getName());  if (pTab3 != NULL){    ndbout << pTab3->getName() << " was found in DB"<< endl;    result = NDBT_FAILED;  }      return result;}int runPkSizes(NDBT_Context* ctx, NDBT_Step* step){  int result = NDBT_OK;  char tabName[256];  int minPkSize = 1;  ndbout << "minPkSize=" <<minPkSize<<endl;  int maxPkSize = MAX_KEY_SIZE_IN_WORDS * 4;  ndbout << "maxPkSize=" <<maxPkSize<<endl;  Ndb* pNdb = GETNDB(step);  int numRecords = ctx->getNumRecords();  for (int i = minPkSize; i < maxPkSize; i++){    BaseString::snprintf(tabName, 256, "TPK_%d", i);    int records = numRecords;    int max = ~0;    // Limit num records for small PKs    if (i == 1)      max = 99;    if (i == 2)      max = 999;    if (i == 3)      max = 9999;    if (records > max)      records = max;    ndbout << "records =" << records << endl;    if (pNdb->waitUntilReady(30) != 0){      // Db is not ready, return with failure      return NDBT_FAILED;    }      ndbout << "|- " << tabName << endl;    if (NDBT_Tables::createTable(pNdb, tabName) != 0){      ndbout << tabName << " could not be created"<< endl;      return NDBT_FAILED;    }        // Verify that table exists in db        const NdbDictionary::Table* pTab3 =       NDBT_Table::discoverTableFromDb(pNdb, tabName) ;    if (pTab3 == NULL){      g_err << tabName << " was not found in DB"<< endl;      return NDBT_FAILED;    }    //    ndbout << *pTab3 << endl;    if (pTab3->equal(*NDBT_Tables::getTable(tabName)) == false){      g_err << "It was not equal" << endl;      return NDBT_FAILED;    }    do {      // Do it all      HugoTransactions hugoTrans(*pTab3);      UtilTransactions utilTrans(*pTab3);      int count;      CHECK(hugoTrans.loadTable(pNdb, records) == 0);      CHECK(hugoTrans.pkUpdateRecords(pNdb, records) == 0);      CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);      CHECK(count == records);      CHECK(hugoTrans.pkDelRecords(pNdb, records/2) == 0);      CHECK(hugoTrans.scanUpdateRecords(pNdb, records) == 0);      CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);      CHECK(count == (records/2));      CHECK(utilTrans.clearTable(pNdb, records) == 0);      #if 0      // Fill table      CHECK(hugoTrans.fillTable(pNdb) == 0);              CHECK(utilTrans.clearTable2(pNdb, records) == 0);      CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);      CHECK(count == 0);#endif    } while(false);    // Drop table    if (pNdb->getDictionary()->dropTable(pTab3->getName()) != 0){      ndbout << "Failed to drop "<<pTab3->getName()<<" in db" << endl;      return NDBT_FAILED;    }  }  return result;}int runStoreFrm(NDBT_Context* ctx, NDBT_Step* step){  Ndb* pNdb = GETNDB(step);    const NdbDictionary::Table* pTab = ctx->getTab();  int result = NDBT_OK;  int loops = ctx->getNumLoops();  for (int l = 0; l < loops && result == NDBT_OK ; l++){    Uint32 dataLen = (Uint32)myRandom48(MAX_FRM_DATA_SIZE);    // size_t dataLen = 10;    unsigned char data[MAX_FRM_DATA_SIZE];    char start = l + 248;    for(Uint32 i = 0; i < dataLen; i++){      data[i] = start;      start++;    }#if 0    ndbout << "dataLen="<<dataLen<<endl;    for (Uint32 i = 0; i < dataLen; i++){      unsigned char c = data[i];      ndbout << hex << c << ", ";    }    ndbout << endl;#endif            NdbDictionary::Table newTab(* pTab);    void* pData = &data;    newTab.setFrm(pData, dataLen);        // Try to create table in db    if (newTab.createTableInDb(pNdb) != 0){      result = NDBT_FAILED;      continue;    }        // Verify that table is in db         const NdbDictionary::Table* pTab2 =       NDBT_Table::discoverTableFromDb(pNdb, pTab->getName());    if (pTab2 == NULL){      g_err << pTab->getName() << " was not found in DB"<< endl;      result = NDBT_FAILED;      continue;    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -