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 /cpp | |
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
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/src/Freeze/IndexI.cpp | 22 | ||||
-rw-r--r-- | cpp/src/Freeze/MapI.cpp | 21 |
2 files changed, 41 insertions, 2 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; |