diff options
author | Jose <jose@zeroc.com> | 2012-08-07 23:07:11 +0200 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2012-08-07 23:07:11 +0200 |
commit | 1ff2551957f6af61808a0182da4063cd3a77bc44 (patch) | |
tree | 16fe0ab00248a5888f47542db883e9302658114f | |
parent | VS2012 build fixes (diff) | |
parent | ICE-4755 - Freeze and DB 5.x (diff) | |
download | ice-1ff2551957f6af61808a0182da4063cd3a77bc44.tar.bz2 ice-1ff2551957f6af61808a0182da4063cd3a77bc44.tar.xz ice-1ff2551957f6af61808a0182da4063cd3a77bc44.zip |
Merge branch 'master' into encoding11
-rw-r--r-- | cpp/src/Freeze/IndexI.cpp | 22 | ||||
-rw-r--r-- | cpp/src/Freeze/MapI.cpp | 21 | ||||
-rw-r--r-- | java/src/Freeze/Index.java | 20 | ||||
-rw-r--r-- | java/src/Freeze/MapInternal/Index.java | 10 |
4 files changed, 68 insertions, 5 deletions
diff --git a/cpp/src/Freeze/IndexI.cpp b/cpp/src/Freeze/IndexI.cpp index 6323c052373..f0910bb2452 100644 --- a/cpp/src/Freeze/IndexI.cpp +++ b/cpp/src/Freeze/IndexI.cpp @@ -43,13 +43,23 @@ Freeze::IndexI::untypedFindFirst(const Key& bytes, Int firstN) const Dbt dbKey; initializeInDbt(bytes, dbKey); +#if (DB_VERSION_MAJOR <= 4) || (DB_VERSION_MAJOR == 5 && DB_VERSION_MINOR <= 1) // // When we have a custom-comparison function, Berkeley DB returns // the key on-disk (when it finds one). We disable this behavior: // (ref Oracle SR 5925672.992) // dbKey.set_flags(DB_DBT_USERMEM | DB_DBT_PARTIAL); - +#else + // + // In DB > 5.1 we can not set DB_DBT_PARTIAL in the key Dbt, + // when using DB_SET, we must resize the Dbt key param to hold enought + // space or Dbc::get fails with DB_BUFFER_SMALL. + // + dbKey.set_flags(DB_DBT_USERMEM); + dbKey.set_ulen(static_cast<u_int32_t>(bytes.size())); +#endif + Key pkey(1024); Dbt pdbKey; initializeOutDbt(pkey, pdbKey); @@ -201,12 +211,22 @@ Freeze::IndexI::untypedCount(const Key& bytes) const Dbt dbKey; initializeInDbt(bytes, dbKey); +#if (DB_VERSION_MAJOR <= 4) || (DB_VERSION_MAJOR == 5 && DB_VERSION_MINOR <= 1) // // When we have a custom-comparison function, Berkeley DB returns // the key on-disk (when it finds one). We disable this behavior: // (ref Oracle SR 5925672.992) // dbKey.set_flags(DB_DBT_USERMEM | DB_DBT_PARTIAL); +#else + // + // In DB > 5.1 we can not set DB_DBT_PARTIAL in the key Dbt, + // when using DB_SET, we must resize the Dbt key param to hold enought + // space or Dbc::get fails with DB_BUFFER_SMALL. + // + dbKey.set_flags(DB_DBT_USERMEM); + dbKey.set_ulen(static_cast<u_int32_t>(bytes.size())); +#endif Dbt dbValue; dbValue.set_flags(DB_DBT_USERMEM | DB_DBT_PARTIAL); diff --git a/cpp/src/Freeze/MapI.cpp b/cpp/src/Freeze/MapI.cpp index 782736c701c..a419f5ad447 100644 --- a/cpp/src/Freeze/MapI.cpp +++ b/cpp/src/Freeze/MapI.cpp @@ -438,13 +438,22 @@ Freeze::IteratorHelperI::find(const Key& key) const { Dbt dbKey; initializeInDbt(key, dbKey); +#if (DB_VERSION_MAJOR <= 4) || (DB_VERSION_MAJOR == 5 && DB_VERSION_MINOR <= 1) // // When we have a custom-comparison function, Berkeley DB returns // the key on-disk (when it finds one). We disable this behavior: // (ref Oracle SR 5925672.992) // dbKey.set_flags(DB_DBT_USERMEM | DB_DBT_PARTIAL); - +#else + // + // In DB > 5.1 we can not set DB_DBT_PARTIAL in the key Dbt, + // when using DB_SET, we must resize the Dbt key param to hold enought + // space or Dbc::get fails with DB_BUFFER_SMALL. + // + dbKey.set_flags(DB_DBT_USERMEM); + dbKey.set_ulen(static_cast<u_int32_t>(key.size())); +#endif // // Keep 0 length since we're not interested in the data // @@ -1763,12 +1772,22 @@ Freeze::MapIndexI::untypedCount(const Key& k, const ConnectionIPtr& connection) { Dbt dbKey; initializeInDbt(k, dbKey); +#if (DB_VERSION_MAJOR <= 4) // // When we have a custom-comparison function, Berkeley DB returns // the key on-disk (when it finds one). We disable this behavior: // (ref Oracle SR 5925672.992) // dbKey.set_flags(DB_DBT_USERMEM | DB_DBT_PARTIAL); +#else + // + // In DB 5.x we can not set DB_DBT_PARTIAL in the key Dbt, + // when using DB_SET, we must resize the Dbt key param to hold enought + // space or Dbc::get fails with DB_BUFFER_SMALL. + // + dbKey.set_flags(DB_DBT_USERMEM); + dbKey.set_ulen(static_cast<u_int32_t>(k.size())); +#endif Dbt dbValue; diff --git a/java/src/Freeze/Index.java b/java/src/Freeze/Index.java index 684621985bd..adf803a9615 100644 --- a/java/src/Freeze/Index.java +++ b/java/src/Freeze/Index.java @@ -77,7 +77,15 @@ public abstract class Index implements com.sleepycat.db.SecondaryKeyCreator // the key on-disk (when it finds one). We disable this behavior: // (ref Oracle SR 5925672.992) // - key.setPartial(true); + // In DB > 5.1.x we can not set DB_DBT_PARTIAL in the key Dbt when calling + // getSearchKey. + // + if(com.sleepycat.db.Environment.getVersionMajor() < 5 || + (com.sleepycat.db.Environment.getVersionMajor() == 5 && + com.sleepycat.db.Environment.getVersionMinor() <= 1)) + { + key.setPartial(true); + } com.sleepycat.db.DatabaseEntry pkey = new com.sleepycat.db.DatabaseEntry(); com.sleepycat.db.DatabaseEntry value = new com.sleepycat.db.DatabaseEntry(); @@ -219,7 +227,15 @@ public abstract class Index implements com.sleepycat.db.SecondaryKeyCreator // the key on-disk (when it finds one). We disable this behavior: // (ref Oracle SR 5925672.992) // - key.setPartial(true); + // In DB > 5.1.x we can not set DB_DBT_PARTIAL in the key Dbt when calling + // getSearchKey. + // + if(com.sleepycat.db.Environment.getVersionMajor() < 5 || + (com.sleepycat.db.Environment.getVersionMajor() == 5 && + com.sleepycat.db.Environment.getVersionMinor() <= 1)) + { + key.setPartial(true); + } com.sleepycat.db.DatabaseEntry value = new com.sleepycat.db.DatabaseEntry(); // diff --git a/java/src/Freeze/MapInternal/Index.java b/java/src/Freeze/MapInternal/Index.java index 841eaf16de0..9f8bcb44491 100644 --- a/java/src/Freeze/MapInternal/Index.java +++ b/java/src/Freeze/MapInternal/Index.java @@ -240,7 +240,15 @@ public abstract class Index<K, V, I> // the key on-disk (when it finds one). We disable this behavior: // (ref Oracle SR 5925672.992) // - dbKey.setPartial(true); + // In DB > 5.1.x we can not set DB_DBT_PARTIAL in the key Dbt when calling + // getSearchKey. + // + if(com.sleepycat.db.Environment.getVersionMajor() < 5 || + (com.sleepycat.db.Environment.getVersionMajor() == 5 && + com.sleepycat.db.Environment.getVersionMinor() <= 1)) + { + dbKey.setPartial(true); + } // // dlen is 0, so we should not retrieve any value |