summaryrefslogtreecommitdiff
path: root/cpp/src/FreezeScript
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/FreezeScript')
-rwxr-xr-xcpp/src/FreezeScript/DumpDB.cpp54
-rwxr-xr-xcpp/src/FreezeScript/transformdb.cpp129
2 files changed, 90 insertions, 93 deletions
diff --git a/cpp/src/FreezeScript/DumpDB.cpp b/cpp/src/FreezeScript/DumpDB.cpp
index 955cbcf66af..b2da041ec3d 100755
--- a/cpp/src/FreezeScript/DumpDB.cpp
+++ b/cpp/src/FreezeScript/DumpDB.cpp
@@ -106,7 +106,6 @@ usage(const string& n)
"--select EXPR Dump a record only if EXPR is true.\n"
"-c, --catalog Display information about the databases in an\n"
" environment, or about a particular database.\n"
- "--encoding VERSION Sets the encoding version for the database environment.\n"
;
}
@@ -159,7 +158,6 @@ run(const Ice::StringSeq& originalArgs, const Ice::CommunicatorPtr& communicator
opts.addOpt("", "value", IceUtilInternal::Options::NeedArg);
opts.addOpt("", "select", IceUtilInternal::Options::NeedArg);
opts.addOpt("c", "catalog");
- opts.addOpt("", "encoding", IceUtilInternal::Options::NeedArg);
vector<string> args;
try
@@ -173,8 +171,6 @@ run(const Ice::StringSeq& originalArgs, const Ice::CommunicatorPtr& communicator
return EXIT_FAILURE;
}
- Ice::EncodingVersion encoding = Ice::currentEncoding;
-
//
// Freeze creates a lock file by default to prevent multiple processes from opening
// the same database environment simultaneously. In the case of a read-only program
@@ -193,9 +189,6 @@ run(const Ice::StringSeq& originalArgs, const Ice::CommunicatorPtr& communicator
{
props->setProperty(prefix + ".LockFile", "0");
}
-
- encoding = Ice::stringToEncodingVersion(
- props->getPropertyWithDefault(prefix + ".Encoding", Ice::encodingVersionToString(encoding)));
}
if(opts.isSet("h"))
@@ -321,17 +314,7 @@ run(const Ice::StringSeq& originalArgs, const Ice::CommunicatorPtr& communicator
{
selectExpr = opts.optArg("select");
}
- if(opts.isSet("encoding"))
- {
- encoding = Ice::stringToEncodingVersion(opts.optArg("encoding"));
- }
-
- if(!IceInternal::isSupported(encoding, Ice::currentEncoding))
- {
- cerr << appName << ": " << "unsupported encoding" << endl;
- return EXIT_FAILURE;
- }
-
+
if(outputFile.empty() && args.size() != 2)
{
usage(appName);
@@ -374,15 +357,16 @@ run(const Ice::StringSeq& originalArgs, const Ice::CommunicatorPtr& communicator
if(inputFile.empty())
{
const string evictorKeyTypeName = "::Ice::Identity";
- const string evictorValueTypeName = (encoding == Ice::Encoding_1_0) ? "::Freeze::ObjectRecord" : "Object";
+ const string oldEvictorValueTypeName = "::Freeze::ObjectRecord";
+ const string newEvictorValueTypeName = "Object";
- if((!keyTypeName.empty() && valueTypeName.empty()) || (keyTypeName.empty() && !valueTypeName.empty()))
+ if((!keyTypeName.empty() && valueTypeName.empty()) || (keyTypeName.empty() && !valueTypeName.empty() && !evictor))
{
cerr << appName << ": a key type and a value type must be specified" << endl;
usage(appName);
return EXIT_FAILURE;
}
- else if(!evictor && keyTypeName.empty() && valueTypeName.empty())
+ else if(valueTypeName.empty())
{
try
{
@@ -404,24 +388,32 @@ run(const Ice::StringSeq& originalArgs, const Ice::CommunicatorPtr& communicator
{
evictor = true;
}
- else
- {
- keyTypeName = p->second.key;
- valueTypeName = p->second.value;
- }
+ keyTypeName = p->second.key;
+ valueTypeName = p->second.value;
+
+ if(evictor && valueTypeName.empty())
+ {
+ valueTypeName = oldEvictorValueTypeName;
+ }
}
}
catch(const FreezeScript::FailureException& ex)
{
- cerr << appName << ": " << ex.reason() << endl;
- return EXIT_FAILURE;
+ cerr << appName << ": " << ex.reason() << endl;
+ return EXIT_FAILURE;
}
}
if(evictor)
{
- keyTypeName = evictorKeyTypeName;
- valueTypeName = evictorValueTypeName;
+ if(keyTypeName.empty())
+ {
+ keyTypeName = evictorKeyTypeName;
+ }
+ if(valueTypeName.empty())
+ {
+ valueTypeName = newEvictorValueTypeName;
+ }
}
Slice::TypePtr keyType, valueType;
@@ -553,7 +545,7 @@ run(const Ice::StringSeq& originalArgs, const Ice::CommunicatorPtr& communicator
dbValue.set_flags(DB_DBT_USERMEM | DB_DBT_PARTIAL);
Dbc* dbc = 0;
- db.cursor(0, &dbc, 0);
+ db.cursor(txn, &dbc, 0);
while(dbc->get(&dbKey, &dbValue, DB_NEXT) == 0)
{
diff --git a/cpp/src/FreezeScript/transformdb.cpp b/cpp/src/FreezeScript/transformdb.cpp
index b9f6e9774ef..24bfdd71d1e 100755
--- a/cpp/src/FreezeScript/transformdb.cpp
+++ b/cpp/src/FreezeScript/transformdb.cpp
@@ -83,10 +83,8 @@ usage(const std::string& n)
"-p Purge objects whose types no longer exist.\n"
"-c Use catastrophic recovery on the old database environment.\n"
"-w Suppress duplicate warnings during migration.\n"
- "--encoding VER[,VER] Specifies the Ice encoding version for the database\n"
- " environments. If the encoding version remains the same,\n"
- " only one needs to be specified. Otherwise, the versions\n"
- " are specified as old-version,new-version.\n"
+ "--encoding VERSION Set the Ice encoding version for the new database\n"
+ " environment.\n"
"-f FILE Execute the transformation descriptors in the file FILE.\n"
;
}
@@ -236,7 +234,6 @@ run(const Ice::StringSeq& originalArgs, const Ice::CommunicatorPtr& communicator
string valueTypeNames;
string dbEnvName, dbName, dbEnvNameNew;
bool allDb = false;
- Ice::EncodingVersion oldEncoding = Ice::currentEncoding;
Ice::EncodingVersion newEncoding = Ice::currentEncoding;
IceUtilInternal::Options opts;
@@ -440,38 +437,17 @@ run(const Ice::StringSeq& originalArgs, const Ice::CommunicatorPtr& communicator
{
props->setProperty(prefix + ".LockFile", "0");
}
-
- oldEncoding = Ice::stringToEncodingVersion(
- props->getPropertyWithDefault(prefix + ".Encoding", Ice::encodingVersionToString(oldEncoding)));
}
if(opts.isSet("encoding"))
{
- string encodingList = opts.optArg("encoding");
- string::size_type pos = encodingList.find(",");
+ newEncoding = Ice::stringToEncodingVersion(opts.optArg("encoding"));
- if(pos == 0 || pos == encodingList.size())
+ if(!IceInternal::isSupported(newEncoding, Ice::currentEncoding))
{
cerr << appName << ": " << "unsupported encoding" << endl;
return EXIT_FAILURE;
}
- if(pos == string::npos)
- {
- oldEncoding = Ice::stringToEncodingVersion(encodingList);
- newEncoding = oldEncoding;
- }
- else
- {
- oldEncoding = Ice::stringToEncodingVersion(encodingList.substr(0, pos));
- newEncoding = Ice::stringToEncodingVersion(encodingList.substr(pos + 1));
- }
- }
-
- if(!IceInternal::isSupported(oldEncoding, Ice::currentEncoding) ||
- !IceInternal::isSupported(newEncoding, Ice::currentEncoding))
- {
- cerr << appName << ": " << "unsupported encoding" << endl;
- return EXIT_FAILURE;
}
Slice::UnitPtr oldUnit = Slice::Unit::createUnit(true, true, ice, underscore);
@@ -530,8 +506,8 @@ run(const Ice::StringSeq& originalArgs, const Ice::CommunicatorPtr& communicator
FreezeScript::TransformAnalyzer analyzer(oldUnit, newUnit, ignoreTypeChanges, out, missingTypes, analyzeErrors);
const string evictorKeyName = "::Ice::Identity";
- const string oldEvictorValueTypeName = (oldEncoding == Ice::Encoding_1_0) ? "::Freeze::ObjectRecord" : "Object";
- const string newEvictorValueTypeName = (newEncoding == Ice::Encoding_1_0) ? "::Freeze::ObjectRecord" : "Object";
+ const string oldEvictorValueName = "::Freeze::ObjectRecord";
+ const string newEvictorValueName = "Object";
if(allDb)
{
@@ -544,8 +520,17 @@ run(const Ice::StringSeq& originalArgs, const Ice::CommunicatorPtr& communicator
if(p->second.evictor)
{
- keyName = evictorKeyName;
- valueName = oldEvictorValueTypeName;
+ keyName = p->second.key;
+ valueName = p->second.value;
+
+ if(keyName.empty())
+ {
+ keyName = evictorKeyName;
+ }
+ if(valueName.empty())
+ {
+ valueName = oldEvictorValueName;
+ }
}
else
{
@@ -578,7 +563,10 @@ run(const Ice::StringSeq& originalArgs, const Ice::CommunicatorPtr& communicator
Slice::TypePtr newValueType;
if(p->second.evictor)
{
- newValueType = findType(newUnit, newEvictorValueTypeName);
+ //
+ // The new evictor does not keep stats
+ //
+ newValueType = findType(newUnit, newEvictorValueName);
}
else
{
@@ -604,47 +592,44 @@ run(const Ice::StringSeq& originalArgs, const Ice::CommunicatorPtr& communicator
{
return EXIT_FAILURE;
}
-
+
analyzer.addDatabase(p->first, oldKeyType, newKeyType, oldValueType, newValueType);
}
}
else
{
string oldKeyName, newKeyName, oldValueName, newValueName;
-
- if(evictor)
- {
- oldKeyName = newKeyName = evictorKeyName;
- oldValueName = oldEvictorValueTypeName;
- newValueName = newEvictorValueTypeName;
- }
- else
- {
- string::size_type pos;
-
- if(keyTypeNames.empty() || valueTypeNames.empty())
- {
- usage(appName);
- return EXIT_FAILURE;
- }
-
- pos = keyTypeNames.find(',');
- if(pos == 0 || pos == keyTypeNames.size())
- {
- usage(appName);
- return EXIT_FAILURE;
- }
- if(pos == string::npos)
- {
- oldKeyName = keyTypeNames;
- newKeyName = keyTypeNames;
- }
+
+ string::size_type pos;
+
+ if(!evictor && (keyTypeNames.empty() || valueTypeNames.empty()))
+ {
+ usage(appName);
+ return EXIT_FAILURE;
+ }
+
+ if(!keyTypeNames.empty())
+ {
+ pos = keyTypeNames.find(',');
+ if(pos == 0 || pos == keyTypeNames.size())
+ {
+ usage(appName);
+ return EXIT_FAILURE;
+ }
+ if(pos == string::npos)
+ {
+ oldKeyName = keyTypeNames;
+ newKeyName = keyTypeNames;
+ }
else
{
oldKeyName = keyTypeNames.substr(0, pos);
newKeyName = keyTypeNames.substr(pos + 1);
}
+ }
+ if(!valueTypeNames.empty())
+ {
pos = valueTypeNames.find(',');
if(pos == 0 || pos == valueTypeNames.size())
{
@@ -662,6 +647,26 @@ run(const Ice::StringSeq& originalArgs, const Ice::CommunicatorPtr& communicator
newValueName = valueTypeNames.substr(pos + 1);
}
}
+
+ if(evictor)
+ {
+ if(oldKeyName.empty())
+ {
+ oldKeyName = evictorKeyName;
+ }
+ if(newKeyName.empty())
+ {
+ newKeyName = evictorKeyName;
+ }
+ if(oldValueName.empty())
+ {
+ oldValueName = newEvictorValueName;
+ }
+ if(newValueName.empty())
+ {
+ newValueName = newEvictorValueName;
+ }
+ }
//
// Look up the key and value types in the old and new Slice definitions.