本文整理汇总了C++中ndbdictionary::Dictionary类的典型用法代码示例。如果您正苦于以下问题:C++ Dictionary类的具体用法?C++ Dictionary怎么用?C++ Dictionary使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Dictionary类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: tmp
bool
BackupRestore::createSystable(const TableS & tables){
if (!m_restore && !m_restore_meta && !m_restore_epoch)
return true;
const char *tablename = tables.getTableName();
if( strcmp(tablename, NDB_REP_DB "/def/" NDB_APPLY_TABLE) != 0 &&
strcmp(tablename, NDB_REP_DB "/def/" NDB_SCHEMA_TABLE) != 0 )
{
return true;
}
BaseString tmp(tablename);
Vector<BaseString> split;
if(tmp.split(split, "/") != 3){
err << "Invalid table name format " << tablename << endl;
return false;
}
m_ndb->setDatabaseName(split[0].c_str());
m_ndb->setSchemaName(split[1].c_str());
NdbDictionary::Dictionary* dict = m_ndb->getDictionary();
if( dict->getTable(split[2].c_str()) != NULL ){
return true;
}
return table(tables);
}
开发者ID:A-eolus,项目名称:mysql,代码行数:28,代码来源:consumer_restore.cpp
示例2: 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
示例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
static int
runCheckTableExists(NDBT_Context* ctx, NDBT_Step* step)
{
Ndb ndb(&ctx->m_cluster_connection, "TEST_DB");
ndb.init(1);
NdbDictionary::Dictionary* pDict = ndb.getDictionary();
const NdbDictionary::Table* pTab = ctx->getTab();
const char *tab_name= pTab->getName();
const NdbDictionary::Table* pDictTab = pDict->getTable(tab_name);
if (pDictTab == NULL)
{
g_err << "runCheckTableExists : Failed to find table "
<< tab_name << endl;
g_err << "Required schema : " << *((NDBT_Table*)pTab) << endl;
return NDBT_FAILED;
}
/* Todo : better check that table in DB is same as
* table we expect
*/
// Update ctx with a pointer to dict table
ctx->setTab(pDictTab);
ctx->setProperty("$table", tab_name);
return NDBT_OK;
}
开发者ID:carrotli,项目名称:ansql,代码行数:30,代码来源:NDBT_Test.cpp
示例5: 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
示例6: calc
int
runInterpretedUKLookup(NDBT_Context* ctx, NDBT_Step* step)
{
const NdbDictionary::Table * pTab = ctx->getTab();
Ndb* pNdb = GETNDB(step);
NdbDictionary::Dictionary * dict = pNdb->getDictionary();
const NdbDictionary::Index* pIdx= dict->getIndex(pkIdxName, pTab->getName());
CHK_RET_FAILED(pIdx != 0);
const NdbRecord * pRowRecord = pTab->getDefaultRecord();
CHK_RET_FAILED(pRowRecord != 0);
const NdbRecord * pIdxRecord = pIdx->getDefaultRecord();
CHK_RET_FAILED(pIdxRecord != 0);
const Uint32 len = NdbDictionary::getRecordRowLength(pRowRecord);
Uint8 * pRow = new Uint8[len];
bzero(pRow, len);
HugoCalculator calc(* pTab);
calc.equalForRow(pRow, pRowRecord, 0);
NdbTransaction* pTrans = pNdb->startTransaction();
CHK_RET_FAILED(pTrans != 0);
NdbInterpretedCode code;
code.interpret_exit_ok();
code.finalise();
NdbOperation::OperationOptions opts;
bzero(&opts, sizeof(opts));
opts.optionsPresent = NdbOperation::OperationOptions::OO_INTERPRETED;
opts.interpretedCode = &code;
const NdbOperation * pOp = pTrans->readTuple(pIdxRecord, (char*)pRow,
pRowRecord, (char*)pRow,
NdbOperation::LM_Read,
0,
&opts,
sizeof(opts));
CHK_RET_FAILED(pOp);
int res = pTrans->execute(Commit, AbortOnError);
CHK_RET_FAILED(res == 0);
delete [] pRow;
return NDBT_OK;
}
开发者ID:,项目名称:,代码行数:49,代码来源:
示例7: x
int
create_table(){
NdbDictionary::Dictionary* dict = g_ndb->getDictionary();
assert(dict);
if(g_paramters[P_CREATE].value){
g_ndb->getDictionary()->dropTable(g_tablename);
const NdbDictionary::Table * pTab = NDBT_Tables::getTable(g_tablename);
assert(pTab);
NdbDictionary::Table copy = * pTab;
copy.setLogging(false);
if(dict->createTable(copy) != 0){
g_err << "Failed to create table: " << g_tablename << endl;
return -1;
}
NdbDictionary::Index x(g_indexname);
x.setTable(g_tablename);
x.setType(NdbDictionary::Index::OrderedIndex);
x.setLogging(false);
for (unsigned k = 0; k < copy.getNoOfColumns(); k++){
if(copy.getColumn(k)->getPrimaryKey()){
x.addColumnName(copy.getColumn(k)->getName());
}
}
if(dict->createIndex(x) != 0){
g_err << "Failed to create index: " << endl;
return -1;
}
}
g_table = dict->getTable(g_tablename);
g_index = dict->getIndex(g_indexname, g_tablename);
assert(g_table);
assert(g_index);
if(g_paramters[P_CREATE].value)
{
int rows = g_paramters[P_ROWS].value;
HugoTransactions hugoTrans(* g_table);
if (hugoTrans.loadTable(g_ndb, rows)){
g_err.println("Failed to load %s with %d rows",
g_table->getName(), rows);
return -1;
}
}
return 0;
}
开发者ID:4T-Shirt,项目名称:mysql,代码行数:48,代码来源:testScanPerf.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: run
void GetTableCall::run() {
DEBUG_PRINT("GetTableCall::run() [%s.%s]", arg1, arg2);
NdbDictionary::Dictionary * dict;
return_val = -1;
if(strlen(arg1)) {
arg0->ndb->setDatabaseName(arg1);
}
dict = arg0->ndb->getDictionary();
ndb_table = dict->getTable(arg2);
if(ndb_table) {
return_val = dict->listIndexes(idx_list, arg2);
}
if(return_val == 0) {
/* Fetch the indexes now. These calls may perform network IO, populating
the (connection) global and (Ndb) local dictionary caches. Later,
in the JavaScript main thread, we will call getIndex() again knowing
that the caches are populated.
*/
for(unsigned int i = 0 ; i < idx_list.count ; i++) {
const NdbDictionary::Index * idx = dict->getIndex(idx_list.elements[i].name, arg2);
/* It is possible to get an index for a recently dropped table rather
than the desired table. This is a known bug likely to be fixed later.
*/
if(ndb_table->getObjectVersion() !=
dict->getTable(idx->getTable())->getObjectVersion())
{
dict->invalidateIndex(idx);
idx = dict->getIndex(idx_list.elements[i].name, arg2);
}
}
}
}
开发者ID:sikancil,项目名称:mysql-js,代码行数:33,代码来源:DBDictionaryImpl.cpp
示例10: trans
int
runLoadAll(NDBT_Context* ctx, NDBT_Step* step)
{
Ndb* pNdb = GETNDB(step);
NdbDictionary::Dictionary * pDict = pNdb->getDictionary();
int records = ctx->getNumRecords();
int result = NDBT_OK;
for (unsigned i = 0; i<table_list.size(); i++)
{
const NdbDictionary::Table* tab = pDict->getTable(table_list[i].c_str());
HugoTransactions trans(* tab);
trans.loadTable(pNdb, records);
trans.scanUpdateRecords(pNdb, records);
}
return result;
}
开发者ID:,项目名称:,代码行数:18,代码来源:
示例11: 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
示例12: 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,代码来源:
示例13: 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
示例14: 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
示例15: hugoTrans
int
stressNDB_rep1(NDBT_Context* ctx, NDBT_Step* step)
{
Ndb* ndb=GETNDB(step);
NdbDictionary::Dictionary* myDict = ndb->getDictionary();
const NdbDictionary::Table * table = myDict->getTable("rep1");
HugoTransactions hugoTrans(* table);
while(!ctx->isTestStopped())
{
if (hugoTrans.pkUpdateRecords(GETNDB(step), ctx->getNumRecords(), 1, 30)
== NDBT_FAILED)
{
g_err << "pkUpdate Failed!" << endl;
return NDBT_FAILED;
}
if (hugoTrans.scanUpdateRecords(GETNDB(step), ctx->getNumRecords(), 1, 30)
== NDBT_FAILED)
{
g_err << "scanUpdate Failed!" << endl;
return NDBT_FAILED;
}
}
return NDBT_OK;
}
开发者ID:Cona19,项目名称:mysql5.6.24-improve,代码行数:24,代码来源:NdbRepStress.cpp
示例16: x
int
create_table() {
NdbDictionary::Dictionary* dict = g_ndb->getDictionary();
assert(dict);
if(g_paramters[P_CREATE].value) {
const NdbDictionary::Table * pTab = NDBT_Tables::getTable(g_table);
assert(pTab);
NdbDictionary::Table copy = * pTab;
copy.setLogging(false);
if(dict->createTable(copy) != 0) {
g_err << "Failed to create table: " << g_table << endl;
return -1;
}
NdbDictionary::Index x(g_ordered);
x.setTable(g_table);
x.setType(NdbDictionary::Index::OrderedIndex);
x.setLogging(false);
for (unsigned k = 0; k < copy.getNoOfColumns(); k++) {
if(copy.getColumn(k)->getPrimaryKey()) {
x.addColumn(copy.getColumn(k)->getName());
}
}
if(dict->createIndex(x) != 0) {
g_err << "Failed to create index: " << endl;
return -1;
}
x.setName(g_unique);
x.setType(NdbDictionary::Index::UniqueHashIndex);
if(dict->createIndex(x) != 0) {
g_err << "Failed to create index: " << endl;
return -1;
}
}
g_tab = dict->getTable(g_table);
g_i_unique = dict->getIndex(g_unique, g_table);
g_i_ordered = dict->getIndex(g_ordered, g_table);
assert(g_tab);
assert(g_i_unique);
assert(g_i_ordered);
return 0;
}
开发者ID:liuqian1990,项目名称:mariadb-10.0,代码行数:44,代码来源:testReadPerf.cpp
示例17:
/*
* ForeignKeyMetadata = {
name : "" , // Constraint name
columnNames : null , // an ordered array of column numbers
targetTable : "" , // referenced table name
targetDatabase : "" , // referenced database name
targetColumnNames: null , // an ordered array of target column names
};
*/
Handle<Object> GetTableCall::buildDBForeignKey(const NdbDictionary::ForeignKey *fk) {
HandleScope scope;
DictionaryNameSplitter localSplitter;
Local<Object> js_fk = Object::New();
localSplitter.splitName(fk->getName()); // e.g. "12/20/fkname"
js_fk->Set(String::NewSymbol("name"), String::New(localSplitter.part3));
// get child column names
unsigned int childColumnCount = fk->getChildColumnCount();
Local<Array> fk_child_column_names = Array::New(childColumnCount);
for (unsigned i = 0; i < childColumnCount; ++i) {
int columnNumber = fk->getChildColumnNo(i);
const NdbDictionary::Column * column = ndb_table->getColumn(columnNumber);
fk_child_column_names->Set(i, String::New(column->getName()));
}
js_fk->Set(String::NewSymbol("columnNames"), fk_child_column_names);
// get parent table (which might be in a different database)
const char * fk_parent_name = fk->getParentTable();
localSplitter.splitName(fk_parent_name);
const char * parent_db_name = localSplitter.part1;
const char * parent_table_name = localSplitter.part3;
js_fk->Set(String::NewSymbol("targetTable"), String::New(parent_table_name));
js_fk->Set(String::NewSymbol("targetDatabase"), String::New(parent_db_name));
ndb->setDatabaseName(parent_db_name);
const NdbDictionary::Table * parent_table = dict->getTable(parent_table_name);
ndb->setDatabaseName(dbName);
// get parent column names
unsigned int parentColumnCount = fk->getParentColumnCount();
Local<Array> fk_parent_column_names = Array::New(parentColumnCount);
for (unsigned i = 0; i < parentColumnCount; ++i) {
int columnNumber = fk->getParentColumnNo(i);
const NdbDictionary::Column * column = parent_table->getColumn(columnNumber);
fk_parent_column_names->Set(i, String::New( column->getName()));
}
js_fk->Set(String::NewSymbol("targetColumnNames"), fk_parent_column_names);
return scope.Close(js_fk);
}
开发者ID:bear-qv,项目名称:mysql-js,代码行数:50,代码来源:DBDictionaryImpl.cpp
示例18: NDBT_ProgramExit
int
main(int argc, char** argv)
{
NDB_INIT(argv[0]);
const char *load_default_groups[]= { "mysql_cluster",0 };
load_defaults("my",load_default_groups,&argc,&argv);
int ho_error;
#ifndef DBUG_OFF
opt_debug= "d:t:F:L";
#endif
if ((ho_error=handle_options(&argc, &argv, my_long_options,
ndb_std_get_one_option)))
return NDBT_ProgramExit(NDBT_WRONGARGS);
DBUG_ENTER("main");
Ndb_cluster_connection con(opt_connect_str);
if(con.connect(12, 5, 1))
{
DBUG_RETURN(NDBT_ProgramExit(NDBT_FAILED));
}
Ndb ndb(&con,_dbname);
ndb.init();
while (ndb.waitUntilReady() != 0);
NdbDictionary::Dictionary * dict = ndb.getDictionary();
int no_error= 1;
int i;
// create all tables
Vector<const NdbDictionary::Table*> pTabs;
if (argc == 0)
{
NDBT_Tables::dropAllTables(&ndb);
NDBT_Tables::createAllTables(&ndb);
for (i= 0; no_error && i < NDBT_Tables::getNumTables(); i++)
{
const NdbDictionary::Table *pTab= dict->getTable(NDBT_Tables::getTable(i)->getName());
if (pTab == 0)
{
ndbout << "Failed to create table" << endl;
ndbout << dict->getNdbError() << endl;
no_error= 0;
break;
}
pTabs.push_back(pTab);
}
}
else
{
for (i= 0; no_error && argc; argc--, i++)
{
dict->dropTable(argv[i]);
NDBT_Tables::createTable(&ndb, argv[i]);
const NdbDictionary::Table *pTab= dict->getTable(argv[i]);
if (pTab == 0)
{
ndbout << "Failed to create table" << endl;
ndbout << dict->getNdbError() << endl;
no_error= 0;
break;
}
pTabs.push_back(pTab);
}
}
pTabs.push_back(NULL);
// create an event for each table
for (i= 0; no_error && pTabs[i]; i++)
{
HugoTransactions ht(*pTabs[i]);
if (ht.createEvent(&ndb)){
no_error= 0;
break;
}
}
// create an event operation for each event
Vector<NdbEventOperation *> pOps;
for (i= 0; no_error && pTabs[i]; i++)
{
char buf[1024];
sprintf(buf, "%s_EVENT", pTabs[i]->getName());
NdbEventOperation *pOp= ndb.createEventOperation(buf, 1000);
if ( pOp == NULL )
{
no_error= 0;
break;
}
pOps.push_back(pOp);
}
// get storage for each event operation
for (i= 0; no_error && pTabs[i]; i++)
{
int n_columns= pTabs[i]->getNoOfColumns();
for (int j = 0; j < n_columns; j++) {
pOps[i]->getValue(pTabs[i]->getColumn(j)->getName());
//.........这里部分代码省略.........
开发者ID:A-eolus,项目名称:mysql,代码行数:101,代码来源:test_event_multi_table.cpp
示例19: old
bool
BackupRestore::object(Uint32 type, const void * ptr)
{
if (!m_restore_meta)
return true;
NdbDictionary::Dictionary* dict = m_ndb->getDictionary();
switch(type){
case DictTabInfo::Tablespace:
{
NdbDictionary::Tablespace old(*(NdbDictionary::Tablespace*)ptr);
Uint32 id = old.getObjectId();
if (!m_no_restore_disk)
{
NdbDictionary::LogfileGroup * lg = m_logfilegroups[old.getDefaultLogfileGroupId()];
old.setDefaultLogfileGroup(* lg);
info << "Creating tablespace: " << old.getName() << "..." << flush;
int ret = dict->createTablespace(old);
if (ret)
{
NdbError errobj= dict->getNdbError();
info << "FAILED" << endl;
err << "Create tablespace failed: " << old.getName() << ": " << errobj << endl;
return false;
}
info << "done" << endl;
}
NdbDictionary::Tablespace curr = dict->getTablespace(old.getName());
NdbError errobj = dict->getNdbError();
if ((int) errobj.classification == (int) ndberror_cl_none)
{
NdbDictionary::Tablespace* currptr = new NdbDictionary::Tablespace(curr);
NdbDictionary::Tablespace * null = 0;
m_tablespaces.set(currptr, id, null);
debug << "Retreived tablespace: " << currptr->getName()
<< " oldid: " << id << " newid: " << currptr->getObjectId()
<< " " << (void*)currptr << endl;
return true;
}
err << "Failed to retrieve tablespace \"" << old.getName() << "\": "
<< errobj << endl;
return false;
break;
}
case DictTabInfo::LogfileGroup:
{
NdbDictionary::LogfileGroup old(*(NdbDictionary::LogfileGroup*)ptr);
Uint32 id = old.getObjectId();
if (!m_no_restore_disk)
{
info << "Creating logfile group: " << old.getName() << "..." << flush;
int ret = dict->createLogfileGroup(old);
if (ret)
{
NdbError errobj= dict->getNdbError();
info << "FAILED" << endl;
err << "Create logfile group failed: " << old.getName() << ": " << errobj << endl;
return false;
}
info << "done" << endl;
}
NdbDictionary::LogfileGroup curr = dict->getLogfileGroup(old.getName());
NdbError errobj = dict->getNdbError();
if ((int) errobj.classification == (int) ndberror_cl_none)
{
NdbDictionary::LogfileGroup* currptr =
new NdbDictionary::LogfileGroup(curr);
NdbDictionary::LogfileGroup * null = 0;
m_logfilegroups.set(currptr, id, null);
debug << "Retreived logfile group: " << currptr->getName()
<< " oldid: " << id << " newid: " << currptr->getObjectId()
<< " " << (void*)currptr << endl;
return true;
}
err << "Failed to retrieve logfile group \"" << old.getName() << "\": "
<< errobj << endl;
return false;
break;
}
case DictTabInfo::Datafile:
{
if (!m_no_restore_disk)
{
NdbDictionary::Datafile old(*(NdbDictionary::Datafile*)ptr);
NdbDictionary::ObjectId objid;
old.getTablespaceId(&objid);
NdbDictionary::Tablespace * ts = m_tablespaces[objid.getObjectId()];
debug << "Connecting datafile " << old.getPath()
<< " to tablespace: oldid: " << objid.getObjectId()
<< " newid: " << ts->getObjectId() << endl;
//.........这里部分代码省略.........
开发者ID:A-eolus,项目名称:mysql,代码行数:101,代码来源:consumer_restore.cpp
示例20: copy_events
static int copy_events(Ndb *ndb)
{
DBUG_ENTER("copy_events");
int r= 0;
NdbDictionary::Dictionary * dict = ndb->getDictionary();
while (1)
{
int res= ndb->pollEvents(1000); // wait for event or 1000 ms
DBUG_PRINT("info", ("pollEvents res=%d", res));
if (res <= 0)
{
break;
}
int error= 0;
NdbEventOperation *pOp;
while ((pOp= ndb->nextEvent(&error)))
{
char buf[1024];
sprintf(buf, "%s_SHADOW", pOp->getTable()->getName());
const NdbDictionary::Table *table= dict->getTable(buf);
if (table == 0)
{
g_err << "unable to find table " << buf << endl;
DBUG_RETURN(-1);
}
if (pOp->isOverrun())
{
g_err << "buffer overrun\n";
DBUG_RETURN(-1);
}
r++;
Uint32 gci= pOp->getGCI();
if (!pOp->isConsistent()) {
g_err << "A node failure has occured and events might be missing\n";
DBUG_RETURN(-1);
}
int noRetries= 0;
do
{
NdbTransaction *trans= ndb->startTransaction();
if (trans == 0)
{
g_err << "startTransaction failed "
<< ndb->getNdbError().code << " "
<< ndb->getNdbError().message << endl;
DBUG_RETURN(-1);
}
NdbOperation *op= trans->getNdbOperation(table);
if (op == 0)
{
g_err << "getNdbOperation failed "
<< trans->getNdbError().code << " "
<< trans->getNdbError().message << endl;
DBUG_RETURN(-1);
}
switch (pOp->getEventType()) {
case NdbDictionary::Event::TE_INSERT:
if (op->insertTuple())
{
g_err << "insertTuple "
<< op->getNdbError().code << " "
<< op->getNdbError().message << endl;
DBUG_RETURN(-1);
}
break;
case NdbDictionary::Event::TE_DELETE:
if (op->deleteTuple())
{
g_err << "deleteTuple "
<< op->getNdbError().code << " "
<< op->getNdbError().message << endl;
DBUG_RETURN(-1);
}
break;
case NdbDictionary::Event::TE_UPDATE:
if (op->updateTuple())
{
g_err << "updateTuple "
<< op->getNdbError().code << " "
<< op->getNdbError().message << endl;
DBUG_RETURN(-1);
}
break;
default:
abort();
}
{
for (const NdbRecAttr *pk= pOp->getFirstPkAttr(); pk; pk= pk->next())
{
if (pk->isNULL())
{
g_err << "internal error: primary key isNull()="
//.........这里部分代码省略.........
开发者ID:A-eolus,项目名称:mysql,代码行数:101,代码来源:test_event_multi_table.cpp
注:本文中的ndbdictionary::Dictionary类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论