当前位置: 首页>>代码示例>>C++>>正文


C++ Dictionary::getNdbError方法代码示例

本文整理汇总了C++中ndbdictionary::Dictionary::getNdbError方法的典型用法代码示例。如果您正苦于以下问题:C++ Dictionary::getNdbError方法的具体用法?C++ Dictionary::getNdbError怎么用?C++ Dictionary::getNdbError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ndbdictionary::Dictionary的用法示例。


在下文中一共展示了Dictionary::getNdbError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: createListenerEvent

void TableTailer::createListenerEvent() {
    NdbDictionary::Dictionary *myDict = mNdbConnection->getDictionary();
    if (!myDict) LOG_NDB_API_ERROR(mNdbConnection->getNdbError());

    const NdbDictionary::Table *table = myDict->getTable(mTable.mTableName.c_str());
    if (!table) LOG_NDB_API_ERROR(myDict->getNdbError());

    NdbDictionary::Event myEvent(mEventName.c_str(), *table);
    
    for(int i=0; i< mTable.mNoEvents; i++){
        myEvent.addTableEvent(mTable.mWatchEvents[i]);
    }
    const char* columns[mTable.mNoColumns];
    for(int i=0; i< mTable.mNoColumns; i++){
        columns[i] = mTable.mColumnNames[i].c_str();
    }
    myEvent.addEventColumns(mTable.mNoColumns, columns);
    //myEvent.mergeEvents(merge_events);

    // Add event to database
    if (myDict->createEvent(myEvent) == 0)
        myEvent.print();
    else if (myDict->getNdbError().classification ==
            NdbError::SchemaObjectExists) {
        LOG_ERROR("Event creation failed, event exists, dropping Event...");
        if (myDict->dropEvent(mEventName.c_str())) LOG_NDB_API_ERROR(myDict->getNdbError());
        // try again
        // Add event to database
        if (myDict->createEvent(myEvent)) LOG_NDB_API_ERROR(myDict->getNdbError());
    } else
        LOG_NDB_API_ERROR(myDict->getNdbError());
}
开发者ID:hopshadoop,项目名称:ePipe,代码行数:32,代码来源:TableTailer.cpp

示例2: hugoTrans

int
runDDL(NDBT_Context* ctx, NDBT_Step* step){
  Ndb* pNdb= GETNDB(step);
  NdbDictionary::Dictionary* pDict = pNdb->getDictionary();
  
  const int tables = NDBT_Tables::getNumTables();
  while(!ctx->isTestStopped())
  {
    const int tab_no = rand() % (tables);
    NdbDictionary::Table tab = *NDBT_Tables::getTable(tab_no);
    BaseString name= tab.getName();
    name.appfmt("-%d", step->getStepNo());
    tab.setName(name.c_str());
    if(pDict->createTable(tab) == 0)
    {
      HugoTransactions hugoTrans(* pDict->getTable(name.c_str()));
      if (hugoTrans.loadTable(pNdb, 10000) != 0){
	return NDBT_FAILED;
      }
      
      while(pDict->dropTable(tab.getName()) != 0 &&
	    pDict->getNdbError().code != 4009)
	g_err << pDict->getNdbError() << endl;
      
      sleep(1);

    }
  }
  return NDBT_OK;
}
开发者ID:A-eolus,项目名称:mysql,代码行数:30,代码来源:testBackup.cpp

示例3: GETNDB

int
runCreateIndexT1(NDBT_Context* ctx, NDBT_Step* step)
{
    Ndb* pNdb = GETNDB(step);
    NdbDictionary::Dictionary* pDict = pNdb->getDictionary();
    const NdbDictionary::Table* pTab = pDict->getTable("T1");
    if (pTab == 0)
    {
        g_err << "getTable(T1) error: " << pDict->getNdbError() << endl;
        return NDBT_FAILED;
    }
    NdbDictionary::Index ind;
    ind.setName("T1X1");
    ind.setTable("T1");
    ind.setType(NdbDictionary::Index::OrderedIndex);
    ind.setLogging(false);
    ind.addColumn("KOL2");
    ind.addColumn("KOL3");
    ind.addColumn("KOL4");
    if (pDict->createIndex(ind, *pTab) != 0)
    {
        g_err << "createIndex(T1X1) error: " << pDict->getNdbError() << endl;
        return NDBT_FAILED;
    }
    return NDBT_OK;
}
开发者ID:,项目名称:,代码行数:26,代码来源:

示例4: ndb

int
NDBT_TestSuite::createTables(Ndb_cluster_connection& con) const
{
  Ndb ndb(&con, "TEST_DB");
  ndb.init(1);

  NdbDictionary::Dictionary* pDict = ndb.getDictionary();
  for(unsigned i = 0; i<m_tables_in_test.size(); i++)
  {
    const char *tab_name=  m_tables_in_test[i].c_str();
    if (pDict->dropTable(tab_name) != 0 &&
        pDict->getNdbError().code != 723) // No such table
    {
      g_err << "runCreateTables: Failed to drop table " << tab_name << endl
            << pDict->getNdbError() << endl;
      return NDBT_FAILED;
    }
    if(NDBT_Tables::createTable(&ndb, tab_name, !getLogging()) != 0)
    {
      g_err << "runCreateTables: Failed to create table " << tab_name << endl
            << pDict->getNdbError() << endl;
      return NDBT_FAILED;
    }

    if (i == 0){
      // Update ctx with a pointer to the first created table
      const NdbDictionary::Table* pTab2 = pDict->getTable(tab_name);
      ctx->setTab(pTab2);
    }
    g_info << "created " << tab_name << endl;
  }

  return NDBT_OK;
}
开发者ID:carrotli,项目名称:ansql,代码行数:34,代码来源:NDBT_Test.cpp

示例5: createIndex

static void createIndex(Ndb &myNdb, bool includePrimary, unsigned int noOfIndexes)
{
  Uint64 before, after;
  NdbDictionary::Dictionary* dict = myNdb.getDictionary();
  char indexName[] = "PNUMINDEX0000";
  int res;

  for(unsigned int indexNum = 0; indexNum < noOfIndexes; indexNum++) {
    sprintf(indexName, "PNUMINDEX%.4u", indexNum);
    NdbDictionary::Index index(indexName);
    index.setTable("PERSON");
    index.setType(NdbDictionary::Index::UniqueHashIndex);
    if (includePrimary) {
      const char* attr_arr[] = {"NAME", "PNUM1", "PNUM3"};
      index.addIndexColumns(3, attr_arr);
    }
    else {
      const char* attr_arr[] = {"PNUM1", "PNUM3"};
      index.addIndexColumns(2, attr_arr);
    }
    before = NdbTick_CurrentMillisecond();
    if ((res = dict->createIndex(index)) == -1) {
      error_handler(dict->getNdbError());
    }    
    after = NdbTick_CurrentMillisecond();
    ndbout << "Created index " << indexName << ", " << after - before << " msec" << endl;
  }
}
开发者ID:4T-Shirt,项目名称:mysql,代码行数:28,代码来源:index.cpp

示例6: doAsyncCallback

void ListTablesCall::doAsyncCallback(Local<Object> ctx) {
  DEBUG_MARKER(UDEB_DETAIL);
  Handle<Value> cb_args[2];
  const char * & dbName = arg1;
  
  DEBUG_PRINT("RETURN VAL: %d", return_val);
  if(return_val == -1) {
    cb_args[0] = NdbError_Wrapper(dict->getNdbError());
    cb_args[1] = Null();
  }
  else {
    cb_args[0] = Null(); // no error
    /* ListObjects has returned tables in all databases; 
       we need to filter here on database name. */
    int * stack = new int[list.count];
    unsigned int nmatch = 0;
    for(unsigned i = 0; i < list.count ; i++) {
      if(strcmp(dbName, list.elements[i].database) == 0) {
        stack[nmatch++] = i;
      }
    }
    DEBUG_PRINT("arg1/nmatch/list.count: %s/%d/%d", arg1,nmatch,list.count);

    Local<Array> cb_list = Array::New(nmatch);
    for(unsigned int i = 0; i < nmatch ; i++) {
      cb_list->Set(i, String::New(list.elements[stack[i]].name));
    }
    cb_args[1] = cb_list;
    delete[] stack;
  }
  callback->Call(ctx, 2, cb_args);
}
开发者ID:bear-qv,项目名称:mysql-js,代码行数:32,代码来源:DBDictionaryImpl.cpp

示例7: drop_all_tables

static int drop_all_tables()
{
  NdbDictionary::Dictionary * dict = g_ndb->getDictionary();
  require(dict);

  BaseString db = g_ndb->getDatabaseName();
  BaseString schema = g_ndb->getSchemaName();

  NdbDictionary::Dictionary::List list;
  if (dict->listObjects(list, NdbDictionary::Object::TypeUndefined) == -1){
      g_err << "Failed to list tables: " << endl
	    << dict->getNdbError() << endl;
      return -1;
  }
  for (unsigned i = 0; i < list.count; i++) {
    NdbDictionary::Dictionary::List::Element& elt = list.elements[i];
    switch (elt.type) {
    case NdbDictionary::Object::SystemTable:
    case NdbDictionary::Object::UserTable:
      g_ndb->setDatabaseName(elt.database);
      g_ndb->setSchemaName(elt.schema);
      if(dict->dropTable(elt.name) != 0){
	g_err << "Failed to drop table: " 
	      << elt.database << "/" << elt.schema << "/" << elt.name <<endl;
	g_err << dict->getNdbError() << endl;
	return -1;
      }
      break;
    case NdbDictionary::Object::UniqueHashIndex:
    case NdbDictionary::Object::OrderedIndex:
    case NdbDictionary::Object::HashIndexTrigger:
    case NdbDictionary::Object::IndexTrigger:
    case NdbDictionary::Object::SubscriptionTrigger:
    case NdbDictionary::Object::ReadOnlyConstraint:
    default:
      break;
    }
  }
  
  g_ndb->setDatabaseName(db.c_str());
  g_ndb->setSchemaName(schema.c_str());
  
  return 0;
}
开发者ID:4T-Shirt,项目名称:mysql,代码行数:44,代码来源:testLcp.cpp

示例8:

bool
BackupRestore::table(const TableS & table){
  if (!m_restore_meta) 
  {
    return true;
  }
  NdbDictionary::Dictionary* dict = m_ndb->getDictionary();
  if (dict->createTable(*table.m_dictTable) == -1) 
  {
    err << "Create table " << table.getTableName() << " failed: "
	<< dict->getNdbError() << endl;
    return false;
  }
  info << "Successfully restored table " << table.getTableName()<< endl ;
  return true;
}
开发者ID:SunguckLee,项目名称:MariaDB,代码行数:16,代码来源:consumer_restorem.cpp

示例9: sprintf

static
int
dropEvent(Ndb *pNdb, const NdbDictionary::Table &tab)
{
    char eventName[1024];
    sprintf(eventName,"%s_EVENT",tab.getName());
    NdbDictionary::Dictionary *myDict = pNdb->getDictionary();
    if (!myDict) {
        g_err << "Dictionary not found "
              << pNdb->getNdbError().code << " "
              << pNdb->getNdbError().message << endl;
        return NDBT_FAILED;
    }
    if (myDict->dropEvent(eventName)) {
        g_err << "Failed to drop event: "
              << myDict->getNdbError().code << " : "
              << myDict->getNdbError().message << endl;
        return NDBT_FAILED;
    }
    return NDBT_OK;
}
开发者ID:,项目名称:,代码行数:21,代码来源:

示例10: GETNDB

static int
runDropIndex(NDBT_Context* ctx, NDBT_Step* step)
{
  const NdbDictionary::Table* pTab = ctx->getTab();
  Ndb* pNdb = GETNDB(step);
  NdbDictionary::Dictionary* pDic = pNdb->getDictionary();
  NdbDictionary::Dictionary::List list;
  if (pDic->listIndexes(list, pTab->getName()) != 0) {
    g_err << pTab->getName() << ": listIndexes failed" << endl;
    ERR(pDic->getNdbError());
    return NDBT_FAILED;
  }
  for (unsigned i = 0; i < list.count; i++) {
    NDBT_Index* pInd = new NDBT_Index(list.elements[i].name);
    pInd->setTable(pTab->getName());
    g_info << "Drop index:" << endl << *pInd;
    if (pInd->dropIndexInDb(pNdb) != 0) {
      return NDBT_FAILED;
    }
  }
  return NDBT_OK;
}
开发者ID:4T-Shirt,项目名称:mysql,代码行数:22,代码来源:testOrderedIndex.cpp

示例11:

int
NDBT_Tables::create_default_tablespace(Ndb* pNdb)
{
  NdbDictionary::Dictionary* pDict = pNdb->getDictionary();

  int res;
  NdbDictionary::LogfileGroup lg = pDict->getLogfileGroup("DEFAULT-LG");
  if (strcmp(lg.getName(), "DEFAULT-LG") != 0)
  {
    lg.setName("DEFAULT-LG");
    lg.setUndoBufferSize(8*1024*1024);
    res = pDict->createLogfileGroup(lg);
    if(res != 0){
      g_err << "Failed to create logfilegroup:"
	    << endl << pDict->getNdbError() << endl;
      return NDBT_FAILED;
    }
  }
  {
    NdbDictionary::Undofile uf = pDict->getUndofile(0, "undofile01.dat");
    if (strcmp(uf.getPath(), "undofile01.dat") != 0)
    {
      uf.setPath("undofile01.dat");
      uf.setSize(32*1024*1024);
      uf.setLogfileGroup("DEFAULT-LG");
      
      res = pDict->createUndofile(uf, true);
      if(res != 0){
	g_err << "Failed to create undofile:"
	      << endl << pDict->getNdbError() << endl;
	return NDBT_FAILED;
      }
    }
  }
  {
    NdbDictionary::Undofile uf = pDict->getUndofile(0, "undofile02.dat");
    if (strcmp(uf.getPath(), "undofile02.dat") != 0)
    {
      uf.setPath("undofile02.dat");
      uf.setSize(32*1024*1024);
      uf.setLogfileGroup("DEFAULT-LG");
      
      res = pDict->createUndofile(uf, true);
      if(res != 0){
	g_err << "Failed to create undofile:"
	      << endl << pDict->getNdbError() << endl;
	return NDBT_FAILED;
      }
    }
  }
  NdbDictionary::Tablespace ts = pDict->getTablespace("DEFAULT-TS");
  if (strcmp(ts.getName(), "DEFAULT-TS") != 0)
  {
    ts.setName("DEFAULT-TS");
    ts.setExtentSize(1024*1024);
    ts.setDefaultLogfileGroup("DEFAULT-LG");
    
    res = pDict->createTablespace(ts);
    if(res != 0){
      g_err << "Failed to create tablespace:"
	    << endl << pDict->getNdbError() << endl;
      return NDBT_FAILED;
    }
  }
  
  {
    NdbDictionary::Datafile df = pDict->getDatafile(0, "datafile01.dat");
    if (strcmp(df.getPath(), "datafile01.dat") != 0)
    {
      df.setPath("datafile01.dat");
      df.setSize(64*1024*1024);
      df.setTablespace("DEFAULT-TS");
      
      res = pDict->createDatafile(df, true);
      if(res != 0){
	g_err << "Failed to create datafile:"
	      << endl << pDict->getNdbError() << endl;
	return NDBT_FAILED;
      }
    }
  }

  {
    NdbDictionary::Datafile df = pDict->getDatafile(0, "datafile02.dat");
    if (strcmp(df.getPath(), "datafile02.dat") != 0)
    {
      df.setPath("datafile02.dat");
      df.setSize(64*1024*1024);
      df.setTablespace("DEFAULT-TS");
      
      res = pDict->createDatafile(df, true);
      if(res != 0){
	g_err << "Failed to create datafile:"
	      << endl << pDict->getNdbError() << endl;
	return NDBT_FAILED;
      }
    }
  }
  
  return NDBT_OK;
//.........这里部分代码省略.........
开发者ID:A-eolus,项目名称:mysql,代码行数:101,代码来源:NDBT_Tables.cpp

示例12: trans

static int
runBug14702377(NDBT_Context* ctx, NDBT_Step* step)
{
    Ndb* pNdb = GETNDB(step);
    NdbDictionary::Dictionary * pDict = pNdb->getDictionary();
    int records = ctx->getNumRecords();
    int result = NDBT_OK;

    while (ctx->getProperty("HalfStartedDone", (Uint32)0) == 0)
    {
        ndbout << "Wait for half started..." << endl;
        NdbSleep_SecSleep(15);
    }
    ndbout << "Got half started" << endl;

    while (1)
    {
        require(table_list.size() == 1);
        const char* tabname = table_list[0].c_str();
        const NdbDictionary::Table* tab = 0;
        CHK2((tab = pDict->getTable(tabname)) != 0,
             tabname << ": " << pDict->getNdbError());
        const int ncol = tab->getNoOfColumns();

        {
            HugoTransactions trans(*tab);
            CHK2(trans.loadTable(pNdb, records) == 0, trans.getNdbError());
        }

        for (int r = 0; r < records; r++)
        {
            // with 1000 records will surely hit bug case
            const int lm = myRandom48(4); // 2
            const int nval = myRandom48(ncol + 1); // most
            const bool exist = myRandom48(2); // false

            NdbTransaction* pTx = 0;
            NdbOperation* pOp = 0;
            CHK2((pTx = pNdb->startTransaction()) != 0,
                 pNdb->getNdbError());
            CHK2((pOp = pTx->getNdbOperation(tab)) != 0,
                 pTx->getNdbError());
            CHK2((pOp->readTuple((NdbOperation::LockMode)lm)) == 0,
                 pOp->getNdbError());

            for (int id = 0; id <= 0; id++)
            {
                const NdbDictionary::Column* c = tab->getColumn(id);
                require(c != 0 && c->getPrimaryKey() &&
                        c->getType() == NdbDictionary::Column::Unsigned);
                Uint32 val = myRandom48(records);
                if (!exist)
                    val = 0xaaaa0000 + myRandom48(0xffff + 1);
                const char* valp = (const char*)&val;
                CHK2(pOp->equal(id, valp) == 0, pOp->getNdbError());
            }
            CHK2(result == NDBT_OK, "failed");

            for (int id = 0; id < nval; id++)
            {
                const NdbDictionary::Column* c = tab->getColumn(id);
                require(c != 0 && (id == 0 || !c->getPrimaryKey()));
                CHK2(pOp->getValue(id) != 0, pOp->getNdbError());
            }
            CHK2(result == NDBT_OK, "failed");

            char info1[200];
            sprintf(info1, "lm=%d nval=%d exist=%d",
                    lm, nval, exist);
            g_info << "PK read T1 exec: " << info1 << endl;
            Uint64 t1 = NdbTick_CurrentMillisecond();
            int ret = pTx->execute(NdbTransaction::NoCommit);
            Uint64 t2 = NdbTick_CurrentMillisecond();
            int msec = (int)(t2-t1);
            const NdbError& txerr = pTx->getNdbError();
            const NdbError& operr = pOp->getNdbError();
            char info2[200];
            sprintf(info2, "%s msec=%d ret=%d txerr=%d operr=%d",
                    info1, msec, ret, txerr.code, operr.code);
            g_info << "PK read T1 done: " << info2 << endl;

            if (ret == 0 && txerr.code == 0 && operr.code == 0)
            {
                CHK2(exist, "row should not be found: " << info2);
            }
            else if (ret == 0 && txerr.code == 626 && operr.code == 626)
            {
                CHK2(!exist, "row should be found: " << info2);
            }
            else if (txerr.status == NdbError::TemporaryError)
            {
                g_err << "PK read T1 temporary error (tx): " << info2 << endl;
                NdbSleep_MilliSleep(50);
            }
            else if (operr.status == NdbError::TemporaryError)
            {
                g_err << "PK read T1 temporary error (op): " << info2 << endl;
                NdbSleep_MilliSleep(50);
            }
            else
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例13: myEvent

static
int
createEvent(Ndb *pNdb,
            const NdbDictionary::Table &tab,
            bool merge_events = true,
            bool report = true)
{
    char eventName[1024];
    sprintf(eventName,"%s_EVENT",tab.getName());

    NdbDictionary::Dictionary *myDict = pNdb->getDictionary();

    if (!myDict) {
        g_err << "Dictionary not found "
              << pNdb->getNdbError().code << " "
              << pNdb->getNdbError().message << endl;
        return NDBT_FAILED;
    }

    myDict->dropEvent(eventName);

    NdbDictionary::Event myEvent(eventName);
    myEvent.setTable(tab.getName());
    myEvent.addTableEvent(NdbDictionary::Event::TE_ALL);
    for(int a = 0; a < tab.getNoOfColumns(); a++) {
        myEvent.addEventColumn(a);
    }
    myEvent.mergeEvents(merge_events);

    if (report)
        myEvent.setReport(NdbDictionary::Event::ER_SUBSCRIBE);

    int res = myDict->createEvent(myEvent); // Add event to database

    if (res == 0)
        myEvent.print();
    else if (myDict->getNdbError().classification ==
             NdbError::SchemaObjectExists)
    {
        g_info << "Event creation failed event exists\n";
        res = myDict->dropEvent(eventName);
        if (res) {
            g_err << "Failed to drop event: "
                  << myDict->getNdbError().code << " : "
                  << myDict->getNdbError().message << endl;
            return NDBT_FAILED;
        }
        // try again
        res = myDict->createEvent(myEvent); // Add event to database
        if (res) {
            g_err << "Failed to create event (1): "
                  << myDict->getNdbError().code << " : "
                  << myDict->getNdbError().message << endl;
            return NDBT_FAILED;
        }
    }
    else
    {
        g_err << "Failed to create event (2): "
              << myDict->getNdbError().code << " : "
              << myDict->getNdbError().message << endl;
        return NDBT_FAILED;
    }

    return NDBT_OK;
}
开发者ID:,项目名称:,代码行数:66,代码来源:

示例14: main

int main(int argc, const char** argv){
  ndb_init();

  int _temp = false;
  int _help = 0;
  int _all = 0;
  int _print = 0;
  const char* _connectstr = NULL;
  int _diskbased = 0;
  const char* _tsname = NULL;
  int _trans = false;

  struct getargs args[] = {
    { "all", 'a', arg_flag, &_all, "Create/print all tables", 0 },
    { "print", 'p', arg_flag, &_print, "Print table(s) instead of creating it", 0},
    { "temp", 't', arg_flag, &_temp, "Temporary table", 0 },
    { "trans", 'x', arg_flag, &_trans, "Use single schema trans", 0 },
    { "connstr", 'c', arg_string, &_connectstr, "Connect string", "cs" }, 
    { "diskbased", 0, arg_flag, &_diskbased, "Store attrs on disk if possible", 0 },
    { "tsname", 0, arg_string, &_tsname, "Tablespace name", "ts" },
    { "usage", '?', arg_flag, &_help, "Print help", "" }
  };
  int num_args = sizeof(args) / sizeof(args[0]);
  int optind = 0;
  char desc[] = 
    "tabname\n"\
    "This program will create one table in Ndb.\n"\
    "The tables may be selected from a fixed list of tables\n"\
    "defined in NDBT_Tables class\n";

  if(getarg(args, num_args, argc, argv, &optind) || _help){
    arg_printusage(args, num_args, argv[0], desc);
    return NDBT_ProgramExit(NDBT_WRONGARGS);
  }

  if(argv[optind] == NULL && !_all){
    arg_printusage(args, num_args, argv[0], desc);
    return NDBT_ProgramExit(NDBT_WRONGARGS);
  }

  g_diskbased = _diskbased;
  g_tsname = _tsname;

  int res = 0;
  if(_print){
    /**
     * Print instead of creating
     */
    if(optind < argc){
      for(int i = optind; i<argc; i++){
	NDBT_Tables::print(argv[i]);
      }
    } else {
      NDBT_Tables::printAll();
    }
  } else {
    /**
     * Creating
     */
    
    // Connect to Ndb
    Ndb_cluster_connection con(_connectstr);
    if(con.connect(12, 5, 1) != 0)
    {
      return NDBT_ProgramExit(NDBT_FAILED);
    }
    Ndb MyNdb(&con, "TEST_DB" );
    
    if(MyNdb.init() != 0){
      ERR(MyNdb.getNdbError());
      return NDBT_ProgramExit(NDBT_FAILED);
    }
    
    while(MyNdb.waitUntilReady() != 0)
      ndbout << "Waiting for ndb to become ready..." << endl;

    NdbDictionary::Dictionary* MyDic = MyNdb.getDictionary();
    
    if (_trans) {
      if (MyDic->beginSchemaTrans() == -1) {
        ERR(MyDic->getNdbError());
        return NDBT_ProgramExit(NDBT_FAILED);
      }
    }

    if(_all){
      res = NDBT_Tables::createAllTables(&MyNdb, _temp);
    } else {
      int tmp;
      for(int i = optind; i<argc; i++){
	ndbout << "Trying to create " <<  argv[i] << endl;
	if((tmp = NDBT_Tables::createTable(&MyNdb, argv[i], _temp, false,
                                           g_create_hook)) != 0)
	  res = tmp;
      }
    } 
    
    if (_trans) {
      if (MyDic->endSchemaTrans() == -1) {
        ERR(MyDic->getNdbError());
//.........这里部分代码省略.........
开发者ID:Cona19,项目名称:mysql5.6.24-improve,代码行数:101,代码来源:create_tab.cpp

示例15: main

int main(int argc, const char** argv){
  ndb_init();

  int _help = 0;
  int _p = 0;
  const char * db = "TEST_DB";
  const char* _connectstr = NULL;

  struct getargs args[] = {
    { "database", 'd', arg_string, &db, "database", 0 },
    { "connstr", 'c', arg_string, &_connectstr, "Connect string", "cs" },
    { "partitions", 'p', arg_integer, &_p, "New no of partitions", 0},
    { "usage", '?', arg_flag, &_help, "Print help", "" }
  };
  int num_args = sizeof(args) / sizeof(args[0]);
  int optind = 0;
  char desc[] =
    "tabname\n"                                                         \
    "This program will alter no of partitions of table in Ndb.\n";

  if(getarg(args, num_args, argc, argv, &optind) || _help){
    arg_printusage(args, num_args, argv[0], desc);
    return NDBT_ProgramExit(NDBT_WRONGARGS);
  }

  if(argv[optind] == NULL)
  {
    arg_printusage(args, num_args, argv[0], desc);
    return NDBT_ProgramExit(NDBT_WRONGARGS);
  }


  // Connect to Ndb
  Ndb_cluster_connection con(_connectstr);
  if(con.connect(12, 5, 1) != 0)
  {
    return NDBT_ProgramExit(NDBT_FAILED);
  }
  Ndb MyNdb(&con, db );

  if(MyNdb.init() != 0){
    ERR(MyNdb.getNdbError());
    return NDBT_ProgramExit(NDBT_FAILED);
  }

  while(MyNdb.waitUntilReady() != 0)
    ndbout << "Waiting for ndb to become ready..." << endl;

  NdbDictionary::Dictionary* MyDic = MyNdb.getDictionary();
  for (int i = optind; i<argc; i++)
  {
    printf("altering %s/%s...", db, argv[i]);
    const NdbDictionary::Table* oldTable = MyDic->getTable(argv[i]);

    if (oldTable == 0)
    {
      ndbout << "Failed to retrieve table " << argv[i]
             << ": " << MyDic->getNdbError() << endl;
      return NDBT_ProgramExit(NDBT_FAILED);
    }

    NdbDictionary::Table newTable = *oldTable;
    newTable.setFragmentCount(_p);

    if (MyDic->beginSchemaTrans() != 0)
      goto err;

    if (MyDic->prepareHashMap(*oldTable, newTable) != 0)
      goto err;

    if (MyDic->alterTable(*oldTable, newTable) != 0)
      goto err;

    if (MyDic->endSchemaTrans())
      goto err;

    ndbout_c("done");
  }

  return NDBT_ProgramExit(NDBT_OK);

err:
  NdbError err = MyDic->getNdbError();
  if (MyDic->hasSchemaTrans())
    MyDic->endSchemaTrans(NdbDictionary::Dictionary::SchemaTransAbort);

  ndbout << "Failed! "
         << err << endl;
  return NDBT_ProgramExit(NDBT_FAILED);

}
开发者ID:hobbytp,项目名称:percona-xtrabackup,代码行数:91,代码来源:reorg_tab.cpp


注:本文中的ndbdictionary::Dictionary::getNdbError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。