diff options
author | Mark Spruiell <mes@zeroc.com> | 2004-04-22 21:12:37 +0000 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2004-04-22 21:12:37 +0000 |
commit | a70e936cacb21eba2638f8a1d15c6359db0c10ff (patch) | |
tree | 0ea769fd8237c3d4c354f7445bc27ed68c67ce77 /cpp/src/FreezeScript/DumpDB.cpp | |
parent | bug fix for Ice::Identity definition (diff) | |
download | ice-a70e936cacb21eba2638f8a1d15c6359db0c10ff.tar.bz2 ice-a70e936cacb21eba2638f8a1d15c6359db0c10ff.tar.xz ice-a70e936cacb21eba2638f8a1d15c6359db0c10ff.zip |
fixes for new evictor database format
Diffstat (limited to 'cpp/src/FreezeScript/DumpDB.cpp')
-rw-r--r-- | cpp/src/FreezeScript/DumpDB.cpp | 71 |
1 files changed, 49 insertions, 22 deletions
diff --git a/cpp/src/FreezeScript/DumpDB.cpp b/cpp/src/FreezeScript/DumpDB.cpp index 67f30332d52..654d19927c3 100644 --- a/cpp/src/FreezeScript/DumpDB.cpp +++ b/cpp/src/FreezeScript/DumpDB.cpp @@ -412,7 +412,6 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator) DbEnv dbEnv(0); DbTxn* txn = 0; - Db* db = 0; int status = EXIT_SUCCESS; try { @@ -424,33 +423,71 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator) #endif // - // Open the database environment. + // Open the database environment and start a transaction. // { u_int32_t flags = DB_INIT_LOG | DB_INIT_MPOOL | DB_INIT_TXN | DB_RECOVER | DB_CREATE; dbEnv.open(dbEnvName.c_str(), flags, FREEZE_SCRIPT_DB_MODE); } - - // - // Open the database in a transaction. - // - db = new Db(&dbEnv, 0); dbEnv.txn_begin(0, &txn, 0); - db->open(txn, dbName.c_str(), 0, DB_BTREE, DB_RDONLY, FREEZE_SCRIPT_DB_MODE); - - istringstream istr(descriptors); FreezeScript::ErrorReporterPtr errorReporter = new FreezeScript::ErrorReporter(cerr, false); - try { FreezeScript::DataFactoryPtr factory = new FreezeScript::DataFactory(communicator, unit, errorReporter); FreezeScript::DescriptorHandler dh(factory, unit, errorReporter); + + istringstream istr(descriptors); IceXML::Parser::parse(istr, dh); FreezeScript::DumpDBDescriptorPtr descriptor = dh.descriptor(); descriptor->validate(); - descriptor->dump(communicator, db, txn); + + if(evictor) + { + // + // Open the database and collect the names of the embedded databases. + // + vector<string> dbNames; + { + Db db(&dbEnv, 0); + db.open(txn, dbName.c_str(), 0, DB_UNKNOWN, DB_RDONLY, 0); + Dbt dbKey, dbValue; + dbKey.set_flags(DB_DBT_MALLOC); + dbValue.set_flags(DB_DBT_USERMEM | DB_DBT_PARTIAL); + + Dbc* dbc = 0; + db.cursor(0, &dbc, 0); + + while(dbc->get(&dbKey, &dbValue, DB_NEXT) == 0) + { + string s(static_cast<char*>(dbKey.get_data()), dbKey.get_size()); + if(s.find("$index:") != 0) + { + dbNames.push_back(s); + } + free(dbKey.get_data()); + } + + dbc->close(); + db.close(0); + } + + for(vector<string>::iterator p = dbNames.begin(); p != dbNames.end(); ++p) + { + Db db(&dbEnv, 0); + db.open(txn, dbName.c_str(), p->c_str(), DB_BTREE, DB_RDONLY, FREEZE_SCRIPT_DB_MODE); + descriptor->dump(communicator, &db, txn); + db.close(0); + } + } + else + { + Db db(&dbEnv, 0); + db.open(txn, dbName.c_str(), 0, DB_BTREE, DB_RDONLY, FREEZE_SCRIPT_DB_MODE); + descriptor->dump(communicator, &db, txn); + db.close(0); + } } catch(const IceXML::ParserException& ex) { @@ -468,11 +505,6 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator) { txn->abort(); } - if(db) - { - db->close(0); - delete db; - } dbEnv.close(0); throw; } @@ -481,11 +513,6 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator) { txn->abort(); } - if(db) - { - db->close(0); - delete db; - } dbEnv.close(0); return status; |