summaryrefslogtreecommitdiff
path: root/cpp/src/Freeze/IndexI.cpp
diff options
context:
space:
mode:
authorJose <jose@zeroc.com>2012-08-07 23:07:11 +0200
committerJose <jose@zeroc.com>2012-08-07 23:07:11 +0200
commit1ff2551957f6af61808a0182da4063cd3a77bc44 (patch)
tree16fe0ab00248a5888f47542db883e9302658114f /cpp/src/Freeze/IndexI.cpp
parentVS2012 build fixes (diff)
parentICE-4755 - Freeze and DB 5.x (diff)
downloadice-1ff2551957f6af61808a0182da4063cd3a77bc44.tar.bz2
ice-1ff2551957f6af61808a0182da4063cd3a77bc44.tar.xz
ice-1ff2551957f6af61808a0182da4063cd3a77bc44.zip
Merge branch 'master' into encoding11
Diffstat (limited to 'cpp/src/Freeze/IndexI.cpp')
-rw-r--r--cpp/src/Freeze/IndexI.cpp22
1 files changed, 21 insertions, 1 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);