summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cpp/src/Freeze/IndexI.cpp22
-rw-r--r--cpp/src/Freeze/MapI.cpp21
-rw-r--r--java/src/Freeze/Index.java20
-rw-r--r--java/src/Freeze/MapInternal/Index.java10
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