mvadkert / rpms / python2.7

Forked from rpms/python2.7 3 years ago
Clone

Blame python-2.6-update-bsddb3-4.8.patch

562f19e
diff -Nupr Python-2.6.4.orig/Lib/bsddb/dbobj.py Python-2.6.4/Lib/bsddb/dbobj.py
562f19e
--- Python-2.6.4.orig/Lib/bsddb/dbobj.py	2008-07-23 07:38:42.000000000 -0400
562f19e
+++ Python-2.6.4/Lib/bsddb/dbobj.py	2009-12-04 07:36:00.000000000 -0500
562f19e
@@ -110,15 +110,17 @@ class DBEnv:
562f19e
     def log_stat(self, *args, **kwargs):
562f19e
         return apply(self._cobj.log_stat, args, kwargs)
562f19e
 
562f19e
-    if db.version() >= (4,1):
562f19e
-        def dbremove(self, *args, **kwargs):
562f19e
-            return apply(self._cobj.dbremove, args, kwargs)
562f19e
-        def dbrename(self, *args, **kwargs):
562f19e
-            return apply(self._cobj.dbrename, args, kwargs)
562f19e
-        def set_encrypt(self, *args, **kwargs):
562f19e
-            return apply(self._cobj.set_encrypt, args, kwargs)
562f19e
+    def dbremove(self, *args, **kwargs):
562f19e
+        return apply(self._cobj.dbremove, args, kwargs)
562f19e
+    def dbrename(self, *args, **kwargs):
562f19e
+        return apply(self._cobj.dbrename, args, kwargs)
562f19e
+    def set_encrypt(self, *args, **kwargs):
562f19e
+        return apply(self._cobj.set_encrypt, args, kwargs)
562f19e
 
562f19e
     if db.version() >= (4,4):
562f19e
+        def fileid_reset(self, *args, **kwargs):
562f19e
+            return self._cobj.fileid_reset(*args, **kwargs)
562f19e
+
562f19e
         def lsn_reset(self, *args, **kwargs):
562f19e
             return apply(self._cobj.lsn_reset, args, kwargs)
562f19e
 
562f19e
@@ -229,9 +231,8 @@ class DB(MutableMapping):
562f19e
     def set_get_returns_none(self, *args, **kwargs):
562f19e
         return apply(self._cobj.set_get_returns_none, args, kwargs)
562f19e
 
562f19e
-    if db.version() >= (4,1):
562f19e
-        def set_encrypt(self, *args, **kwargs):
562f19e
-            return apply(self._cobj.set_encrypt, args, kwargs)
562f19e
+    def set_encrypt(self, *args, **kwargs):
562f19e
+        return apply(self._cobj.set_encrypt, args, kwargs)
562f19e
 
562f19e
 
562f19e
 class DBSequence:
562f19e
diff -Nupr Python-2.6.4.orig/Lib/bsddb/dbtables.py Python-2.6.4/Lib/bsddb/dbtables.py
562f19e
--- Python-2.6.4.orig/Lib/bsddb/dbtables.py	2008-08-31 10:00:51.000000000 -0400
562f19e
+++ Python-2.6.4/Lib/bsddb/dbtables.py	2009-12-04 07:36:00.000000000 -0500
562f19e
@@ -15,7 +15,7 @@
562f19e
 # This provides a simple database table interface built on top of
562f19e
 # the Python Berkeley DB 3 interface.
562f19e
 #
562f19e
-_cvsid = '$Id: dbtables.py 66088 2008-08-31 14:00:51Z jesus.cea $'
562f19e
+_cvsid = '$Id: dbtables.py 58758 2007-11-01 21:15:36Z gregory.p.smith $'
562f19e
 
562f19e
 import re
562f19e
 import sys
562f19e
@@ -659,6 +659,13 @@ class bsdTableDB :
562f19e
             a = atuple[1]
562f19e
             b = btuple[1]
562f19e
             if type(a) is type(b):
562f19e
+
562f19e
+                # Needed for python 3. "cmp" vanished in 3.0.1
562f19e
+                def cmp(a, b) :
562f19e
+                    if a==b : return 0
562f19e
+                    if a
562f19e
+                    return 1
562f19e
+
562f19e
                 if isinstance(a, PrefixCond) and isinstance(b, PrefixCond):
562f19e
                     # longest prefix first
562f19e
                     return cmp(len(b.prefix), len(a.prefix))
562f19e
diff -Nupr Python-2.6.4.orig/Lib/bsddb/dbutils.py Python-2.6.4/Lib/bsddb/dbutils.py
562f19e
--- Python-2.6.4.orig/Lib/bsddb/dbutils.py	2008-08-31 10:00:51.000000000 -0400
562f19e
+++ Python-2.6.4/Lib/bsddb/dbutils.py	2009-12-04 07:36:00.000000000 -0500
562f19e
@@ -61,7 +61,7 @@ def DeadlockWrap(function, *_args, **_kw
562f19e
     """
562f19e
     sleeptime = _deadlock_MinSleepTime
562f19e
     max_retries = _kwargs.get('max_retries', -1)
562f19e
-    if _kwargs.has_key('max_retries'):
562f19e
+    if 'max_retries' in _kwargs:
562f19e
         del _kwargs['max_retries']
562f19e
     while True:
562f19e
         try:
562f19e
diff -Nupr Python-2.6.4.orig/Lib/bsddb/__init__.py Python-2.6.4/Lib/bsddb/__init__.py
562f19e
--- Python-2.6.4.orig/Lib/bsddb/__init__.py	2008-09-05 14:33:51.000000000 -0400
562f19e
+++ Python-2.6.4/Lib/bsddb/__init__.py	2009-12-04 07:36:00.000000000 -0500
562f19e
@@ -33,7 +33,7 @@
562f19e
 #----------------------------------------------------------------------
562f19e
 
562f19e
 
562f19e
-"""Support for Berkeley DB 4.0 through 4.7 with a simple interface.
562f19e
+"""Support for Berkeley DB 4.1 through 4.8 with a simple interface.
562f19e
 
562f19e
 For the full featured object oriented interface use the bsddb.db module
562f19e
 instead.  It mirrors the Oracle Berkeley DB C API.
562f19e
@@ -42,12 +42,6 @@ instead.  It mirrors the Oracle Berkeley
562f19e
 import sys
562f19e
 absolute_import = (sys.version_info[0] >= 3)
562f19e
 
562f19e
-if sys.py3kwarning:
562f19e
-    import warnings
562f19e
-    warnings.warnpy3k("in 3.x, bsddb has been removed; "
562f19e
-                      "please use the pybsddb project instead",
562f19e
-                      DeprecationWarning, 2)
562f19e
-
562f19e
 try:
562f19e
     if __name__ == 'bsddb3':
562f19e
         # import _pybsddb binary as it should be the more recent version from
562f19e
@@ -442,8 +436,10 @@ def _checkflag(flag, file):
562f19e
 # Berkeley DB was too.
562f19e
 
562f19e
 try:
562f19e
-    import thread
562f19e
-    del thread
562f19e
+    # 2to3 automatically changes "import thread" to "import _thread"
562f19e
+    import thread as T
562f19e
+    del T
562f19e
+
562f19e
 except ImportError:
562f19e
     db.DB_THREAD = 0
562f19e
 
562f19e
diff -Nupr Python-2.6.4.orig/Lib/bsddb/test/test_all.py Python-2.6.4/Lib/bsddb/test/test_all.py
562f19e
--- Python-2.6.4.orig/Lib/bsddb/test/test_all.py	2008-09-03 18:07:11.000000000 -0400
562f19e
+++ Python-2.6.4/Lib/bsddb/test/test_all.py	2009-12-04 07:36:00.000000000 -0500
562f19e
@@ -203,6 +203,16 @@ if sys.version_info[0] >= 3 :
562f19e
                 k = bytes(k, charset)
562f19e
             return self._db.has_key(k, txn=txn)
562f19e
 
562f19e
+        def set_re_delim(self, c) :
562f19e
+            if isinstance(c, str) :  # We can use a numeric value byte too
562f19e
+                c = bytes(c, charset)
562f19e
+            return self._db.set_re_delim(c)
562f19e
+
562f19e
+        def set_re_pad(self, c) :
562f19e
+            if isinstance(c, str) :  # We can use a numeric value byte too
562f19e
+               c = bytes(c, charset)
562f19e
+            return self._db.set_re_pad(c)
562f19e
+
562f19e
         def put(self, key, value, txn=None, flags=0, dlen=-1, doff=-1) :
562f19e
             if isinstance(key, str) :
562f19e
                 key = bytes(key, charset)
562f19e
@@ -221,6 +231,11 @@ if sys.version_info[0] >= 3 :
562f19e
                 key = bytes(key, charset)
562f19e
             return self._db.get_size(key)
562f19e
 
562f19e
+        def exists(self, key, *args, **kwargs) :
562f19e
+            if isinstance(key, str) :
562f19e
+                key = bytes(key, charset)
562f19e
+            return self._db.exists(key, *args, **kwargs)
562f19e
+
562f19e
         def get(self, key, default="MagicCookie", txn=None, flags=0, dlen=-1, doff=-1) :
562f19e
             if isinstance(key, str) :
562f19e
                 key = bytes(key, charset)
562f19e
@@ -288,13 +303,21 @@ if sys.version_info[0] >= 3 :
562f19e
                         key = key.decode(charset)
562f19e
                     data = data.decode(charset)
562f19e
                     key = self._callback(key, data)
562f19e
-                    if (key != bsddb._db.DB_DONOTINDEX) and isinstance(key,
562f19e
-                            str) :
562f19e
-                        key = bytes(key, charset)
562f19e
+                    if (key != bsddb._db.DB_DONOTINDEX) :
562f19e
+                        if isinstance(key, str) :
562f19e
+                            key = bytes(key, charset)
562f19e
+                        elif isinstance(key, list) :
562f19e
+                            key2 = []
562f19e
+                            for i in key :
562f19e
+                                if isinstance(i, str) :
562f19e
+                                    i = bytes(i, charset)
562f19e
+                                key2.append(i)
562f19e
+                            key = key2
562f19e
                     return key
562f19e
 
562f19e
             return self._db.associate(secondarydb._db,
562f19e
-                    associate_callback(callback).callback, flags=flags, txn=txn)
562f19e
+                    associate_callback(callback).callback, flags=flags,
562f19e
+                    txn=txn)
562f19e
 
562f19e
         def cursor(self, txn=None, flags=0) :
562f19e
             return cursor_py3k(self._db, txn=txn, flags=flags)
562f19e
@@ -310,6 +333,12 @@ if sys.version_info[0] >= 3 :
562f19e
         def __getattr__(self, v) :
562f19e
             return getattr(self._dbenv, v)
562f19e
 
562f19e
+        def get_data_dirs(self) :
562f19e
+            # Have to use a list comprehension and not
562f19e
+            # generators, because we are supporting Python 2.3.
562f19e
+            return tuple(
562f19e
+                [i.decode(charset) for i in self._dbenv.get_data_dirs()])
562f19e
+
562f19e
     class DBSequence_py3k(object) :
562f19e
         def __init__(self, db, *args, **kwargs) :
562f19e
             self._db=db
562f19e
@@ -332,7 +361,10 @@ if sys.version_info[0] >= 3 :
562f19e
 
562f19e
     bsddb._db.DBEnv_orig = bsddb._db.DBEnv
562f19e
     bsddb._db.DB_orig = bsddb._db.DB
562f19e
-    bsddb._db.DBSequence_orig = bsddb._db.DBSequence
562f19e
+    if bsddb.db.version() <= (4, 3) :
562f19e
+        bsddb._db.DBSequence_orig = None
562f19e
+    else :
562f19e
+        bsddb._db.DBSequence_orig = bsddb._db.DBSequence
562f19e
 
562f19e
     def do_proxy_db_py3k(flag) :
562f19e
         flag2 = do_proxy_db_py3k.flag
562f19e
@@ -481,6 +513,7 @@ def suite(module_prefix='', timing_check
562f19e
     test_modules = [
562f19e
         'test_associate',
562f19e
         'test_basics',
562f19e
+        'test_dbenv',
562f19e
         'test_compare',
562f19e
         'test_compat',
562f19e
         'test_cursor_pget_bug',
562f19e
@@ -489,6 +522,7 @@ def suite(module_prefix='', timing_check
562f19e
         'test_dbtables',
562f19e
         'test_distributed_transactions',
562f19e
         'test_early_close',
562f19e
+        'test_fileid',
562f19e
         'test_get_none',
562f19e
         'test_join',
562f19e
         'test_lock',
562f19e
diff -Nupr Python-2.6.4.orig/Lib/bsddb/test/test_associate.py Python-2.6.4/Lib/bsddb/test/test_associate.py
562f19e
--- Python-2.6.4.orig/Lib/bsddb/test/test_associate.py	2008-08-31 10:00:51.000000000 -0400
562f19e
+++ Python-2.6.4/Lib/bsddb/test/test_associate.py	2009-12-04 07:36:00.000000000 -0500
562f19e
@@ -148,12 +148,8 @@ class AssociateTestCase(unittest.TestCas
562f19e
         self.secDB = None
562f19e
         self.primary = db.DB(self.env)
562f19e
         self.primary.set_get_returns_none(2)
562f19e
-        if db.version() >= (4, 1):
562f19e
-            self.primary.open(self.filename, "primary", self.dbtype,
562f19e
-                          db.DB_CREATE | db.DB_THREAD | self.dbFlags, txn=txn)
562f19e
-        else:
562f19e
-            self.primary.open(self.filename, "primary", self.dbtype,
562f19e
-                          db.DB_CREATE | db.DB_THREAD | self.dbFlags)
562f19e
+        self.primary.open(self.filename, "primary", self.dbtype,
562f19e
+                      db.DB_CREATE | db.DB_THREAD | self.dbFlags, txn=txn)
562f19e
 
562f19e
     def closeDB(self):
562f19e
         if self.cur:
562f19e
@@ -169,12 +165,7 @@ class AssociateTestCase(unittest.TestCas
562f19e
         return self.primary
562f19e
 
562f19e
 
562f19e
-    def test01_associateWithDB(self):
562f19e
-        if verbose:
562f19e
-            print '\n', '-=' * 30
562f19e
-            print "Running %s.test01_associateWithDB..." % \
562f19e
-                  self.__class__.__name__
562f19e
-
562f19e
+    def _associateWithDB(self, getGenre):
562f19e
         self.createDB()
562f19e
 
562f19e
         self.secDB = db.DB(self.env)
562f19e
@@ -182,19 +173,21 @@ class AssociateTestCase(unittest.TestCas
562f19e
         self.secDB.set_get_returns_none(2)
562f19e
         self.secDB.open(self.filename, "secondary", db.DB_BTREE,
562f19e
                    db.DB_CREATE | db.DB_THREAD | self.dbFlags)
562f19e
-        self.getDB().associate(self.secDB, self.getGenre)
562f19e
+        self.getDB().associate(self.secDB, getGenre)
562f19e
 
562f19e
         self.addDataToDB(self.getDB())
562f19e
 
562f19e
         self.finish_test(self.secDB)
562f19e
 
562f19e
-
562f19e
-    def test02_associateAfterDB(self):
562f19e
+    def test01_associateWithDB(self):
562f19e
         if verbose:
562f19e
             print '\n', '-=' * 30
562f19e
-            print "Running %s.test02_associateAfterDB..." % \
562f19e
+            print "Running %s.test01_associateWithDB..." % \
562f19e
                   self.__class__.__name__
562f19e
 
562f19e
+        return self._associateWithDB(self.getGenre)
562f19e
+
562f19e
+    def _associateAfterDB(self, getGenre) :
562f19e
         self.createDB()
562f19e
         self.addDataToDB(self.getDB())
562f19e
 
562f19e
@@ -204,10 +197,35 @@ class AssociateTestCase(unittest.TestCas
562f19e
                    db.DB_CREATE | db.DB_THREAD | self.dbFlags)
562f19e
 
562f19e
         # adding the DB_CREATE flag will cause it to index existing records
562f19e
-        self.getDB().associate(self.secDB, self.getGenre, db.DB_CREATE)
562f19e
+        self.getDB().associate(self.secDB, getGenre, db.DB_CREATE)
562f19e
 
562f19e
         self.finish_test(self.secDB)
562f19e
 
562f19e
+    def test02_associateAfterDB(self):
562f19e
+        if verbose:
562f19e
+            print '\n', '-=' * 30
562f19e
+            print "Running %s.test02_associateAfterDB..." % \
562f19e
+                  self.__class__.__name__
562f19e
+
562f19e
+        return self._associateAfterDB(self.getGenre)
562f19e
+
562f19e
+    if db.version() >= (4, 6):
562f19e
+        def test03_associateWithDB(self):
562f19e
+            if verbose:
562f19e
+                print '\n', '-=' * 30
562f19e
+                print "Running %s.test03_associateWithDB..." % \
562f19e
+                      self.__class__.__name__
562f19e
+
562f19e
+            return self._associateWithDB(self.getGenreList)
562f19e
+
562f19e
+        def test04_associateAfterDB(self):
562f19e
+            if verbose:
562f19e
+                print '\n', '-=' * 30
562f19e
+                print "Running %s.test04_associateAfterDB..." % \
562f19e
+                      self.__class__.__name__
562f19e
+
562f19e
+            return self._associateAfterDB(self.getGenreList)
562f19e
+
562f19e
 
562f19e
     def finish_test(self, secDB, txn=None):
562f19e
         # 'Blues' should not be in the secondary database
562f19e
@@ -277,6 +295,12 @@ class AssociateTestCase(unittest.TestCas
562f19e
         else:
562f19e
             return genre
562f19e
 
562f19e
+    def getGenreList(self, priKey, PriData) :
562f19e
+        v = self.getGenre(priKey, PriData)
562f19e
+        if type(v) == type("") :
562f19e
+            v = [v]
562f19e
+        return v
562f19e
+
562f19e
 
562f19e
 #----------------------------------------------------------------------
562f19e
 
562f19e
@@ -322,10 +346,7 @@ class AssociateBTreeTxnTestCase(Associat
562f19e
             self.secDB.set_get_returns_none(2)
562f19e
             self.secDB.open(self.filename, "secondary", db.DB_BTREE,
562f19e
                        db.DB_CREATE | db.DB_THREAD, txn=txn)
562f19e
-            if db.version() >= (4,1):
562f19e
-                self.getDB().associate(self.secDB, self.getGenre, txn=txn)
562f19e
-            else:
562f19e
-                self.getDB().associate(self.secDB, self.getGenre)
562f19e
+            self.getDB().associate(self.secDB, self.getGenre, txn=txn)
562f19e
 
562f19e
             self.addDataToDB(self.getDB(), txn=txn)
562f19e
         except:
562f19e
@@ -426,8 +447,7 @@ def test_suite():
562f19e
     suite.addTest(unittest.makeSuite(AssociateBTreeTestCase))
562f19e
     suite.addTest(unittest.makeSuite(AssociateRecnoTestCase))
562f19e
 
562f19e
-    if db.version() >= (4, 1):
562f19e
-        suite.addTest(unittest.makeSuite(AssociateBTreeTxnTestCase))
562f19e
+    suite.addTest(unittest.makeSuite(AssociateBTreeTxnTestCase))
562f19e
 
562f19e
     suite.addTest(unittest.makeSuite(ShelveAssociateHashTestCase))
562f19e
     suite.addTest(unittest.makeSuite(ShelveAssociateBTreeTestCase))
562f19e
diff -Nupr Python-2.6.4.orig/Lib/bsddb/test/test_basics.py Python-2.6.4/Lib/bsddb/test/test_basics.py
562f19e
--- Python-2.6.4.orig/Lib/bsddb/test/test_basics.py	2009-07-02 11:37:21.000000000 -0400
562f19e
+++ Python-2.6.4/Lib/bsddb/test/test_basics.py	2009-12-04 07:36:00.000000000 -0500
562f19e
@@ -33,6 +33,7 @@ class VersionTestCase(unittest.TestCase)
562f19e
 
562f19e
 class BasicTestCase(unittest.TestCase):
562f19e
     dbtype       = db.DB_UNKNOWN  # must be set in derived class
562f19e
+    cachesize    = (0, 1024*1024, 1)
562f19e
     dbopenflags  = 0
562f19e
     dbsetflags   = 0
562f19e
     dbmode       = 0660
562f19e
@@ -43,6 +44,13 @@ class BasicTestCase(unittest.TestCase):
562f19e
 
562f19e
     _numKeys      = 1002    # PRIVATE.  NOTE: must be an even value
562f19e
 
562f19e
+    import sys
562f19e
+    if sys.version_info[:3] < (2, 4, 0):
562f19e
+        def assertTrue(self, expr, msg=None):
562f19e
+            self.failUnless(expr,msg=msg)
562f19e
+        def assertFalse(self, expr, msg=None):
562f19e
+            self.failIf(expr,msg=msg)
562f19e
+
562f19e
     def setUp(self):
562f19e
         if self.useEnv:
562f19e
             self.homeDir=get_new_environment_path()
562f19e
@@ -50,7 +58,8 @@ class BasicTestCase(unittest.TestCase):
562f19e
                 self.env = db.DBEnv()
562f19e
                 self.env.set_lg_max(1024*1024)
562f19e
                 self.env.set_tx_max(30)
562f19e
-                self.env.set_tx_timestamp(int(time.time()))
562f19e
+                self._t = int(time.time())
562f19e
+                self.env.set_tx_timestamp(self._t)
562f19e
                 self.env.set_flags(self.envsetflags, 1)
562f19e
                 self.env.open(self.homeDir, self.envflags | db.DB_CREATE)
562f19e
                 self.filename = "test"
562f19e
@@ -64,6 +73,15 @@ class BasicTestCase(unittest.TestCase):
562f19e
 
562f19e
         # create and open the DB
562f19e
         self.d = db.DB(self.env)
562f19e
+        if not self.useEnv :
562f19e
+            if db.version() >= (4, 2) :
562f19e
+                self.d.set_cachesize(*self.cachesize)
562f19e
+                cachesize = self.d.get_cachesize()
562f19e
+                self.assertEqual(cachesize[0], self.cachesize[0])
562f19e
+                self.assertEqual(cachesize[2], self.cachesize[2])
562f19e
+                # Berkeley DB expands the cache 25% accounting overhead,
562f19e
+                # if the cache is small.
562f19e
+                self.assertEqual(125, int(100.0*cachesize[1]/self.cachesize[1]))
562f19e
         self.d.set_flags(self.dbsetflags)
562f19e
         if self.dbname:
562f19e
             self.d.open(self.filename, self.dbname, self.dbtype,
562f19e
@@ -74,6 +92,10 @@ class BasicTestCase(unittest.TestCase):
562f19e
                         dbtype = self.dbtype,
562f19e
                         flags = self.dbopenflags|db.DB_CREATE)
562f19e
 
562f19e
+        if not self.useEnv:
562f19e
+            self.assertRaises(db.DBInvalidArgError,
562f19e
+                    self.d.set_cachesize, *self.cachesize)
562f19e
+
562f19e
         self.populateDB()
562f19e
 
562f19e
 
562f19e
@@ -131,7 +153,7 @@ class BasicTestCase(unittest.TestCase):
562f19e
 
562f19e
         self.assertEqual(d.get('0321'), '0321-0321-0321-0321-0321')
562f19e
 
562f19e
-        # By default non-existent keys return None...
562f19e
+        # By default non-existant keys return None...
562f19e
         self.assertEqual(d.get('abcd'), None)
562f19e
 
562f19e
         # ...but they raise exceptions in other situations.  Call
562f19e
@@ -276,6 +298,21 @@ class BasicTestCase(unittest.TestCase):
562f19e
             pprint(values[:10])
562f19e
 
562f19e
 
562f19e
+    #----------------------------------------
562f19e
+
562f19e
+    def test02b_SequenceMethods(self):
562f19e
+        d = self.d
562f19e
+
562f19e
+        for key in ['0002', '0101', '0401', '0701', '0998']:
562f19e
+            data = d[key]
562f19e
+            self.assertEqual(data, self.makeData(key))
562f19e
+            if verbose:
562f19e
+                print data
562f19e
+
562f19e
+        self.assertTrue(hasattr(d, "__contains__"))
562f19e
+        self.assertTrue("0401" in d)
562f19e
+        self.assertFalse("1234" in d)
562f19e
+
562f19e
 
562f19e
     #----------------------------------------
562f19e
 
562f19e
@@ -509,6 +546,15 @@ class BasicTestCase(unittest.TestCase):
562f19e
         self.assertEqual(old, 1)
562f19e
         self.test03_SimpleCursorStuff(get_raises_error=0, set_raises_error=0)
562f19e
 
562f19e
+    if db.version() >= (4, 6):
562f19e
+        def test03d_SimpleCursorPriority(self) :
562f19e
+            c = self.d.cursor()
562f19e
+            c.set_priority(db.DB_PRIORITY_VERY_LOW)  # Positional
562f19e
+            self.assertEqual(db.DB_PRIORITY_VERY_LOW, c.get_priority())
562f19e
+            c.set_priority(priority=db.DB_PRIORITY_HIGH)  # Keyword
562f19e
+            self.assertEqual(db.DB_PRIORITY_HIGH, c.get_priority())
562f19e
+            c.close()
562f19e
+
562f19e
     #----------------------------------------
562f19e
 
562f19e
     def test04_PartialGetAndPut(self):
562f19e
@@ -562,7 +608,7 @@ class BasicTestCase(unittest.TestCase):
562f19e
         d = self.d
562f19e
         if verbose:
562f19e
             print '\n', '-=' * 30
562f19e
-            print "Running %s.test99_Truncate..." % self.__class__.__name__
562f19e
+            print "Running %s.test06_Truncate..." % self.__class__.__name__
562f19e
 
562f19e
         d.put("abcde", "ABCDE");
562f19e
         num = d.truncate()
562f19e
@@ -582,6 +628,33 @@ class BasicTestCase(unittest.TestCase):
562f19e
 
562f19e
     #----------------------------------------
562f19e
 
562f19e
+    if db.version() >= (4, 6):
562f19e
+        def test08_exists(self) :
562f19e
+            self.d.put("abcde", "ABCDE")
562f19e
+            self.assert_(self.d.exists("abcde") == True,
562f19e
+                    "DB->exists() returns wrong value")
562f19e
+            self.assert_(self.d.exists("x") == False,
562f19e
+                    "DB->exists() returns wrong value")
562f19e
+
562f19e
+    #----------------------------------------
562f19e
+
562f19e
+    if db.version() >= (4, 7):
562f19e
+        def test_compact(self) :
562f19e
+            d = self.d
562f19e
+            self.assertEqual(0, d.compact(flags=db.DB_FREELIST_ONLY))
562f19e
+            self.assertEqual(0, d.compact(flags=db.DB_FREELIST_ONLY))
562f19e
+            d.put("abcde", "ABCDE");
562f19e
+            d.put("bcde", "BCDE");
562f19e
+            d.put("abc", "ABC");
562f19e
+            d.put("monty", "python");
562f19e
+            d.delete("abc")
562f19e
+            d.delete("bcde")
562f19e
+            d.compact(start='abcde', stop='monty', txn=None,
562f19e
+                    compact_fillpercent=42, compact_pages=1,
562f19e
+                    compact_timeout=50000000,
562f19e
+                    flags=db.DB_FREELIST_ONLY|db.DB_FREE_SPACE)
562f19e
+
562f19e
+    #----------------------------------------
562f19e
 
562f19e
 #----------------------------------------------------------------------
562f19e
 
562f19e
@@ -611,13 +684,13 @@ class BasicWithEnvTestCase(BasicTestCase
562f19e
 
562f19e
     #----------------------------------------
562f19e
 
562f19e
-    def test08_EnvRemoveAndRename(self):
562f19e
+    def test09_EnvRemoveAndRename(self):
562f19e
         if not self.env:
562f19e
             return
562f19e
 
562f19e
         if verbose:
562f19e
             print '\n', '-=' * 30
562f19e
-            print "Running %s.test08_EnvRemoveAndRename..." % self.__class__.__name__
562f19e
+            print "Running %s.test09_EnvRemoveAndRename..." % self.__class__.__name__
562f19e
 
562f19e
         # can't rename or remove an open DB
562f19e
         self.d.close()
562f19e
@@ -626,10 +699,6 @@ class BasicWithEnvTestCase(BasicTestCase
562f19e
         self.env.dbrename(self.filename, None, newname)
562f19e
         self.env.dbremove(newname)
562f19e
 
562f19e
-    # dbremove and dbrename are in 4.1 and later
562f19e
-    if db.version() < (4,1):
562f19e
-        del test08_EnvRemoveAndRename
562f19e
-
562f19e
     #----------------------------------------
562f19e
 
562f19e
 class BasicBTreeWithEnvTestCase(BasicWithEnvTestCase):
562f19e
@@ -729,11 +798,25 @@ class BasicTransactionTestCase(BasicTest
562f19e
 
562f19e
     #----------------------------------------
562f19e
 
562f19e
-    def test08_TxnTruncate(self):
562f19e
+    if db.version() >= (4, 6):
562f19e
+        def test08_exists(self) :
562f19e
+            txn = self.env.txn_begin()
562f19e
+            self.d.put("abcde", "ABCDE", txn=txn)
562f19e
+            txn.commit()
562f19e
+            txn = self.env.txn_begin()
562f19e
+            self.assert_(self.d.exists("abcde", txn=txn) == True,
562f19e
+                    "DB->exists() returns wrong value")
562f19e
+            self.assert_(self.d.exists("x", txn=txn) == False,
562f19e
+                    "DB->exists() returns wrong value")
562f19e
+            txn.abort()
562f19e
+
562f19e
+    #----------------------------------------
562f19e
+
562f19e
+    def test09_TxnTruncate(self):
562f19e
         d = self.d
562f19e
         if verbose:
562f19e
             print '\n', '-=' * 30
562f19e
-            print "Running %s.test08_TxnTruncate..." % self.__class__.__name__
562f19e
+            print "Running %s.test09_TxnTruncate..." % self.__class__.__name__
562f19e
 
562f19e
         d.put("abcde", "ABCDE");
562f19e
         txn = self.env.txn_begin()
562f19e
@@ -746,7 +829,7 @@ class BasicTransactionTestCase(BasicTest
562f19e
 
562f19e
     #----------------------------------------
562f19e
 
562f19e
-    def test09_TxnLateUse(self):
562f19e
+    def test10_TxnLateUse(self):
562f19e
         txn = self.env.txn_begin()
562f19e
         txn.abort()
562f19e
         try:
562f19e
@@ -766,6 +849,39 @@ class BasicTransactionTestCase(BasicTest
562f19e
             raise RuntimeError, "DBTxn.commit() called after DB_TXN no longer valid w/o an exception"
562f19e
 
562f19e
 
562f19e
+    #----------------------------------------
562f19e
+
562f19e
+
562f19e
+    if db.version() >= (4, 4):
562f19e
+        def test_txn_name(self) :
562f19e
+            txn=self.env.txn_begin()
562f19e
+            self.assertEqual(txn.get_name(), "")
562f19e
+            txn.set_name("XXYY")
562f19e
+            self.assertEqual(txn.get_name(), "XXYY")
562f19e
+            txn.set_name("")
562f19e
+            self.assertEqual(txn.get_name(), "")
562f19e
+            txn.abort()
562f19e
+
562f19e
+    #----------------------------------------
562f19e
+
562f19e
+
562f19e
+        def test_txn_set_timeout(self) :
562f19e
+            txn=self.env.txn_begin()
562f19e
+            txn.set_timeout(1234567, db.DB_SET_LOCK_TIMEOUT)
562f19e
+            txn.set_timeout(2345678, flags=db.DB_SET_TXN_TIMEOUT)
562f19e
+            txn.abort()
562f19e
+
562f19e
+    #----------------------------------------
562f19e
+
562f19e
+    if db.version() >= (4, 2) :
562f19e
+        def test_get_tx_max(self) :
562f19e
+            self.assertEqual(self.env.get_tx_max(), 30)
562f19e
+
562f19e
+        def test_get_tx_timestamp(self) :
562f19e
+            self.assertEqual(self.env.get_tx_timestamp(), self._t)
562f19e
+
562f19e
+
562f19e
+
562f19e
 class BTreeTransactionTestCase(BasicTransactionTestCase):
562f19e
     dbtype = db.DB_BTREE
562f19e
 
562f19e
@@ -780,11 +896,11 @@ class BTreeRecnoTestCase(BasicTestCase):
562f19e
     dbtype     = db.DB_BTREE
562f19e
     dbsetflags = db.DB_RECNUM
562f19e
 
562f19e
-    def test08_RecnoInBTree(self):
562f19e
+    def test09_RecnoInBTree(self):
562f19e
         d = self.d
562f19e
         if verbose:
562f19e
             print '\n', '-=' * 30
562f19e
-            print "Running %s.test08_RecnoInBTree..." % self.__class__.__name__
562f19e
+            print "Running %s.test09_RecnoInBTree..." % self.__class__.__name__
562f19e
 
562f19e
         rec = d.get(200)
562f19e
         self.assertEqual(type(rec), type(()))
562f19e
@@ -814,11 +930,11 @@ class BTreeRecnoWithThreadFlagTestCase(B
562f19e
 class BasicDUPTestCase(BasicTestCase):
562f19e
     dbsetflags = db.DB_DUP
562f19e
 
562f19e
-    def test09_DuplicateKeys(self):
562f19e
+    def test10_DuplicateKeys(self):
562f19e
         d = self.d
562f19e
         if verbose:
562f19e
             print '\n', '-=' * 30
562f19e
-            print "Running %s.test09_DuplicateKeys..." % \
562f19e
+            print "Running %s.test10_DuplicateKeys..." % \
562f19e
                   self.__class__.__name__
562f19e
 
562f19e
         d.put("dup0", "before")
562f19e
@@ -887,11 +1003,11 @@ class BasicMultiDBTestCase(BasicTestCase
562f19e
         else:
562f19e
             return db.DB_BTREE
562f19e
 
562f19e
-    def test10_MultiDB(self):
562f19e
+    def test11_MultiDB(self):
562f19e
         d1 = self.d
562f19e
         if verbose:
562f19e
             print '\n', '-=' * 30
562f19e
-            print "Running %s.test10_MultiDB..." % self.__class__.__name__
562f19e
+            print "Running %s.test11_MultiDB..." % self.__class__.__name__
562f19e
 
562f19e
         d2 = db.DB(self.env)
562f19e
         d2.open(self.filename, "second", self.dbtype,
562f19e
@@ -1032,11 +1148,12 @@ class CrashAndBurn(unittest.TestCase) :
562f19e
     #    # See http://bugs.python.org/issue3307
562f19e
     #    self.assertRaises(db.DBInvalidArgError, db.DB, None, 65535)
562f19e
 
562f19e
-    def test02_DBEnv_dealloc(self):
562f19e
-        # http://bugs.python.org/issue3885
562f19e
-        import gc
562f19e
-        self.assertRaises(db.DBInvalidArgError, db.DBEnv, ~db.DB_RPCCLIENT)
562f19e
-        gc.collect()
562f19e
+    if db.version() < (4, 8) :
562f19e
+        def test02_DBEnv_dealloc(self):
562f19e
+            # http://bugs.python.org/issue3885
562f19e
+            import gc
562f19e
+            self.assertRaises(db.DBInvalidArgError, db.DBEnv, ~db.DB_RPCCLIENT)
562f19e
+            gc.collect()
562f19e
 
562f19e
 
562f19e
 #----------------------------------------------------------------------
562f19e
diff -Nupr Python-2.6.4.orig/Lib/bsddb/test/test_compare.py Python-2.6.4/Lib/bsddb/test/test_compare.py
562f19e
--- Python-2.6.4.orig/Lib/bsddb/test/test_compare.py	2008-08-31 10:00:51.000000000 -0400
562f19e
+++ Python-2.6.4/Lib/bsddb/test/test_compare.py	2009-12-04 07:36:00.000000000 -0500
562f19e
@@ -12,6 +12,12 @@ from test_all import db, dbshelve, test_
562f19e
         get_new_environment_path, get_new_database_path
562f19e
 
562f19e
 
562f19e
+# Needed for python 3. "cmp" vanished in 3.0.1
562f19e
+def cmp(a, b) :
562f19e
+    if a==b : return 0
562f19e
+    if a
562f19e
+    return 1
562f19e
+
562f19e
 lexical_cmp = cmp
562f19e
 
562f19e
 def lowercase_cmp(left, right):
562f19e
@@ -26,6 +32,10 @@ _expected_lexical_test_data = ['', 'CCCP
562f19e
 _expected_lowercase_test_data = ['', 'a', 'aaa', 'b', 'c', 'CC', 'cccce', 'ccccf', 'CCCP']
562f19e
 
562f19e
 class ComparatorTests (unittest.TestCase):
562f19e
+    if sys.version_info[:3] < (2, 4, 0):
562f19e
+        def assertTrue(self, expr, msg=None):
562f19e
+            self.failUnless(expr,msg=msg)
562f19e
+
562f19e
     def comparator_test_helper (self, comparator, expected_data):
562f19e
         data = expected_data[:]
562f19e
 
562f19e
@@ -47,7 +57,7 @@ class ComparatorTests (unittest.TestCase
562f19e
                     data2.append(i)
562f19e
             data = data2
562f19e
 
562f19e
-        self.failUnless (data == expected_data,
562f19e
+        self.assertTrue (data == expected_data,
562f19e
                          "comparator `%s' is not right: %s vs. %s"
562f19e
                          % (comparator, expected_data, data))
562f19e
     def test_lexical_comparator (self):
562f19e
@@ -65,6 +75,10 @@ class AbstractBtreeKeyCompareTestCase (u
562f19e
     env = None
562f19e
     db = None
562f19e
 
562f19e
+    if sys.version_info[:3] < (2, 4, 0):
562f19e
+        def assertTrue(self, expr, msg=None):
562f19e
+            self.failUnless(expr,msg=msg)
562f19e
+
562f19e
     def setUp (self):
562f19e
         self.filename = self.__class__.__name__ + '.db'
562f19e
         self.homeDir = get_new_environment_path()
562f19e
@@ -115,14 +129,14 @@ class AbstractBtreeKeyCompareTestCase (u
562f19e
             rec = curs.first ()
562f19e
             while rec:
562f19e
                 key, ignore = rec
562f19e
-                self.failUnless (index < len (expected),
562f19e
+                self.assertTrue(index < len (expected),
562f19e
                                  "to many values returned from cursor")
562f19e
-                self.failUnless (expected[index] == key,
562f19e
+                self.assertTrue(expected[index] == key,
562f19e
                                  "expected value `%s' at %d but got `%s'"
562f19e
                                  % (expected[index], index, key))
562f19e
                 index = index + 1
562f19e
                 rec = curs.next ()
562f19e
-            self.failUnless (index == len (expected),
562f19e
+            self.assertTrue(index == len (expected),
562f19e
                              "not enough values returned from cursor")
562f19e
         finally:
562f19e
             curs.close ()
562f19e
diff -Nupr Python-2.6.4.orig/Lib/bsddb/test/test_compat.py Python-2.6.4/Lib/bsddb/test/test_compat.py
562f19e
--- Python-2.6.4.orig/Lib/bsddb/test/test_compat.py	2009-07-02 11:37:21.000000000 -0400
562f19e
+++ Python-2.6.4/Lib/bsddb/test/test_compat.py	2009-12-04 07:36:00.000000000 -0500
562f19e
@@ -133,7 +133,7 @@ class CompatibilityTestCase(unittest.Tes
562f19e
             except KeyError:
562f19e
                 pass
562f19e
             else:
562f19e
-                self.fail("set_location on non-existent key did not raise KeyError")
562f19e
+                self.fail("set_location on non-existant key did not raise KeyError")
562f19e
 
562f19e
         f.sync()
562f19e
         f.close()
562f19e
diff -Nupr Python-2.6.4.orig/Lib/bsddb/test/test_dbenv.py Python-2.6.4/Lib/bsddb/test/test_dbenv.py
562f19e
--- Python-2.6.4.orig/Lib/bsddb/test/test_dbenv.py	1969-12-31 19:00:00.000000000 -0500
562f19e
+++ Python-2.6.4/Lib/bsddb/test/test_dbenv.py	2009-12-04 07:36:00.000000000 -0500
562f19e
@@ -0,0 +1,148 @@
562f19e
+import unittest
562f19e
+import os, glob
562f19e
+
562f19e
+from test_all import db, test_support, get_new_environment_path, \
562f19e
+        get_new_database_path
562f19e
+
562f19e
+#----------------------------------------------------------------------
562f19e
+
562f19e
+class DBEnv(unittest.TestCase):
562f19e
+    def setUp(self):
562f19e
+        self.homeDir = get_new_environment_path()
562f19e
+        self.env = db.DBEnv()
562f19e
+
562f19e
+    def tearDown(self):
562f19e
+        del self.env
562f19e
+        test_support.rmtree(self.homeDir)
562f19e
+
562f19e
+    if db.version() >= (4, 2) :
562f19e
+        def test_setget_data_dirs(self) :
562f19e
+            dirs = ("a", "b", "c", "d")
562f19e
+            for i in dirs :
562f19e
+                self.env.set_data_dir(i)
562f19e
+            self.assertEqual(dirs, self.env.get_data_dirs())
562f19e
+
562f19e
+        def test_setget_cachesize(self) :
562f19e
+            cachesize = (0, 512*1024*1024, 3)
562f19e
+            self.env.set_cachesize(*cachesize)
562f19e
+            self.assertEqual(cachesize, self.env.get_cachesize())
562f19e
+
562f19e
+            cachesize = (0, 1*1024*1024, 5)
562f19e
+            self.env.set_cachesize(*cachesize)
562f19e
+            cachesize2 = self.env.get_cachesize()
562f19e
+            self.assertEqual(cachesize[0], cachesize2[0])
562f19e
+            self.assertEqual(cachesize[2], cachesize2[2])
562f19e
+            # Berkeley DB expands the cache 25% accounting overhead,
562f19e
+            # if the cache is small.
562f19e
+            self.assertEqual(125, int(100.0*cachesize2[1]/cachesize[1]))
562f19e
+
562f19e
+            # You can not change configuration after opening
562f19e
+            # the environment.
562f19e
+            self.env.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL)
562f19e
+            cachesize = (0, 2*1024*1024, 1)
562f19e
+            self.assertRaises(db.DBInvalidArgError,
562f19e
+                self.env.set_cachesize, *cachesize)
562f19e
+            self.assertEqual(cachesize2, self.env.get_cachesize())
562f19e
+
562f19e
+        def test_set_cachesize_dbenv_db(self) :
562f19e
+            # You can not configure the cachesize using
562f19e
+            # the database handle, if you are using an environment.
562f19e
+            d = db.DB(self.env)
562f19e
+            self.assertRaises(db.DBInvalidArgError,
562f19e
+                d.set_cachesize, 0, 1024*1024, 1)
562f19e
+
562f19e
+        def test_setget_shm_key(self) :
562f19e
+            shm_key=137
562f19e
+            self.env.set_shm_key(shm_key)
562f19e
+            self.assertEqual(shm_key, self.env.get_shm_key())
562f19e
+            self.env.set_shm_key(shm_key+1)
562f19e
+            self.assertEqual(shm_key+1, self.env.get_shm_key())
562f19e
+
562f19e
+            # You can not change configuration after opening
562f19e
+            # the environment.
562f19e
+            self.env.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL)
562f19e
+            # If we try to reconfigure cache after opening the
562f19e
+            # environment, core dump.
562f19e
+            self.assertRaises(db.DBInvalidArgError,
562f19e
+                self.env.set_shm_key, shm_key)
562f19e
+            self.assertEqual(shm_key+1, self.env.get_shm_key())
562f19e
+
562f19e
+    if db.version() >= (4, 4) :
562f19e
+        def test_mutex_setget_max(self) :
562f19e
+            v = self.env.mutex_get_max()
562f19e
+            v2 = v*2+1
562f19e
+
562f19e
+            self.env.mutex_set_max(v2)
562f19e
+            self.assertEqual(v2, self.env.mutex_get_max())
562f19e
+
562f19e
+            self.env.mutex_set_max(v)
562f19e
+            self.assertEqual(v, self.env.mutex_get_max())
562f19e
+
562f19e
+            # You can not change configuration after opening
562f19e
+            # the environment.
562f19e
+            self.env.open(self.homeDir, db.DB_CREATE)
562f19e
+            self.assertRaises(db.DBInvalidArgError,
562f19e
+                    self.env.mutex_set_max, v2)
562f19e
+
562f19e
+        def test_mutex_setget_increment(self) :
562f19e
+            v = self.env.mutex_get_increment()
562f19e
+            v2 = 127
562f19e
+
562f19e
+            self.env.mutex_set_increment(v2)
562f19e
+            self.assertEqual(v2, self.env.mutex_get_increment())
562f19e
+
562f19e
+            self.env.mutex_set_increment(v)
562f19e
+            self.assertEqual(v, self.env.mutex_get_increment())
562f19e
+
562f19e
+            # You can not change configuration after opening
562f19e
+            # the environment.
562f19e
+            self.env.open(self.homeDir, db.DB_CREATE)
562f19e
+            self.assertRaises(db.DBInvalidArgError,
562f19e
+                    self.env.mutex_set_increment, v2)
562f19e
+
562f19e
+        def test_mutex_setget_tas_spins(self) :
562f19e
+            self.env.mutex_set_tas_spins(0)  # Default = BDB decides
562f19e
+            v = self.env.mutex_get_tas_spins()
562f19e
+            v2 = v*2+1
562f19e
+
562f19e
+            self.env.mutex_set_tas_spins(v2)
562f19e
+            self.assertEqual(v2, self.env.mutex_get_tas_spins())
562f19e
+
562f19e
+            self.env.mutex_set_tas_spins(v)
562f19e
+            self.assertEqual(v, self.env.mutex_get_tas_spins())
562f19e
+
562f19e
+            # In this case, you can change configuration
562f19e
+            # after opening the environment.
562f19e
+            self.env.open(self.homeDir, db.DB_CREATE)
562f19e
+            self.env.mutex_set_tas_spins(v2)
562f19e
+
562f19e
+        def test_mutex_setget_align(self) :
562f19e
+            v = self.env.mutex_get_align()
562f19e
+            v2 = 64
562f19e
+            if v == 64 :
562f19e
+                v2 = 128
562f19e
+
562f19e
+            self.env.mutex_set_align(v2)
562f19e
+            self.assertEqual(v2, self.env.mutex_get_align())
562f19e
+
562f19e
+            # Requires a nonzero power of two
562f19e
+            self.assertRaises(db.DBInvalidArgError,
562f19e
+                    self.env.mutex_set_align, 0)
562f19e
+            self.assertRaises(db.DBInvalidArgError,
562f19e
+                    self.env.mutex_set_align, 17)
562f19e
+
562f19e
+            self.env.mutex_set_align(2*v2)
562f19e
+            self.assertEqual(2*v2, self.env.mutex_get_align())
562f19e
+
562f19e
+            # You can not change configuration after opening
562f19e
+            # the environment.
562f19e
+            self.env.open(self.homeDir, db.DB_CREATE)
562f19e
+            self.assertRaises(db.DBInvalidArgError,
562f19e
+                    self.env.mutex_set_align, v2)
562f19e
+
562f19e
+
562f19e
+def test_suite():
562f19e
+    return unittest.makeSuite(DBEnv)
562f19e
+
562f19e
+if __name__ == '__main__':
562f19e
+    unittest.main(defaultTest='test_suite')
562f19e
diff -Nupr Python-2.6.4.orig/Lib/bsddb/test/test_dbtables.py Python-2.6.4/Lib/bsddb/test/test_dbtables.py
562f19e
--- Python-2.6.4.orig/Lib/bsddb/test/test_dbtables.py	2008-08-31 10:00:51.000000000 -0400
562f19e
+++ Python-2.6.4/Lib/bsddb/test/test_dbtables.py	2009-12-04 07:36:00.000000000 -0500
562f19e
@@ -18,13 +18,17 @@
562f19e
 #
562f19e
 #   --  Gregory P. Smith <greg@krypto.org>
562f19e
 #
562f19e
-# $Id: test_dbtables.py 66088 2008-08-31 14:00:51Z jesus.cea $
562f19e
+# $Id: test_dbtables.py 58532 2007-10-18 07:56:54Z gregory.p.smith $
562f19e
 
562f19e
-import os, re
562f19e
-try:
562f19e
-    import cPickle
562f19e
-    pickle = cPickle
562f19e
-except ImportError:
562f19e
+import os, re, sys
562f19e
+
562f19e
+if sys.version_info[0] < 3 :
562f19e
+    try:
562f19e
+        import cPickle
562f19e
+        pickle = cPickle
562f19e
+    except ImportError:
562f19e
+        import pickle
562f19e
+else :
562f19e
     import pickle
562f19e
 
562f19e
 import unittest
562f19e
diff -Nupr Python-2.6.4.orig/Lib/bsddb/test/test_distributed_transactions.py Python-2.6.4/Lib/bsddb/test/test_distributed_transactions.py
562f19e
--- Python-2.6.4.orig/Lib/bsddb/test/test_distributed_transactions.py	2008-08-31 10:00:51.000000000 -0400
562f19e
+++ Python-2.6.4/Lib/bsddb/test/test_distributed_transactions.py	2009-12-04 07:36:00.000000000 -0500
562f19e
@@ -35,9 +35,9 @@ class DBTxn_distributed(unittest.TestCas
562f19e
                 db.DB_INIT_TXN | db.DB_INIT_LOG | db.DB_INIT_MPOOL |
562f19e
                 db.DB_INIT_LOCK, 0666)
562f19e
         self.db = db.DB(self.dbenv)
562f19e
-        self.db.set_re_len(db.DB_XIDDATASIZE)
562f19e
+        self.db.set_re_len(db.DB_GID_SIZE)
562f19e
         if must_open_db :
562f19e
-            if db.version() > (4,1) :
562f19e
+            if db.version() >= (4,2) :
562f19e
                 txn=self.dbenv.txn_begin()
562f19e
                 self.db.open(self.filename,
562f19e
                         db.DB_QUEUE, db.DB_CREATE | db.DB_THREAD, 0666,
562f19e
@@ -76,7 +76,7 @@ class DBTxn_distributed(unittest.TestCas
562f19e
     # let them be garbage collected.
562f19e
         for i in xrange(self.num_txns) :
562f19e
             txn = self.dbenv.txn_begin()
562f19e
-            gid = "%%%dd" %db.DB_XIDDATASIZE
562f19e
+            gid = "%%%dd" %db.DB_GID_SIZE
562f19e
             gid = adapt(gid %i)
562f19e
             self.db.put(i, gid, txn=txn, flags=db.DB_APPEND)
562f19e
             txns.add(gid)
562f19e
diff -Nupr Python-2.6.4.orig/Lib/bsddb/test/test_early_close.py Python-2.6.4/Lib/bsddb/test/test_early_close.py
562f19e
--- Python-2.6.4.orig/Lib/bsddb/test/test_early_close.py	2008-09-08 20:49:16.000000000 -0400
562f19e
+++ Python-2.6.4/Lib/bsddb/test/test_early_close.py	2009-12-04 07:36:00.000000000 -0500
562f19e
@@ -155,11 +155,8 @@ class DBEnvClosedEarlyCrash(unittest.Tes
562f19e
                 db.DB_INIT_LOG | db.DB_CREATE)
562f19e
         d = db.DB(dbenv)
562f19e
         txn = dbenv.txn_begin()
562f19e
-        if db.version() < (4,1) :
562f19e
-            d.open(self.filename, dbtype = db.DB_HASH, flags = db.DB_CREATE)
562f19e
-        else :
562f19e
-            d.open(self.filename, dbtype = db.DB_HASH, flags = db.DB_CREATE,
562f19e
-                    txn=txn)
562f19e
+        d.open(self.filename, dbtype = db.DB_HASH, flags = db.DB_CREATE,
562f19e
+                txn=txn)
562f19e
         d.put("XXX", "yyy", txn=txn)
562f19e
         txn.commit()
562f19e
         txn = dbenv.txn_begin()
562f19e
@@ -168,9 +165,9 @@ class DBEnvClosedEarlyCrash(unittest.Tes
562f19e
         self.assertEquals(("XXX", "yyy"), c1.first())
562f19e
         import warnings
562f19e
         # Not interested in warnings about implicit close.
562f19e
-        with warnings.catch_warnings():
562f19e
-            warnings.simplefilter("ignore")
562f19e
-            txn.commit()
562f19e
+        warnings.simplefilter("ignore")
562f19e
+        txn.commit()
562f19e
+        warnings.resetwarnings()
562f19e
         self.assertRaises(db.DBCursorClosedError, c2.first)
562f19e
 
562f19e
     if db.version() > (4,3,0) :
562f19e
diff -Nupr Python-2.6.4.orig/Lib/bsddb/test/test_fileid.py Python-2.6.4/Lib/bsddb/test/test_fileid.py
562f19e
--- Python-2.6.4.orig/Lib/bsddb/test/test_fileid.py	1969-12-31 19:00:00.000000000 -0500
562f19e
+++ Python-2.6.4/Lib/bsddb/test/test_fileid.py	2009-12-04 07:36:00.000000000 -0500
562f19e
@@ -0,0 +1,63 @@
562f19e
+"""TestCase for reseting File ID.
562f19e
+"""
562f19e
+
562f19e
+import os
562f19e
+import shutil
562f19e
+import unittest
562f19e
+
562f19e
+from test_all import db, test_support, get_new_environment_path, get_new_database_path
562f19e
+
562f19e
+class FileidResetTestCase(unittest.TestCase):
562f19e
+    def setUp(self):
562f19e
+        self.db_path_1 = get_new_database_path()
562f19e
+        self.db_path_2 = get_new_database_path()
562f19e
+        self.db_env_path = get_new_environment_path()
562f19e
+
562f19e
+    def test_fileid_reset(self):
562f19e
+        # create DB 1
562f19e
+        self.db1 = db.DB()
562f19e
+        self.db1.open(self.db_path_1, dbtype=db.DB_HASH, flags=(db.DB_CREATE|db.DB_EXCL))
562f19e
+        self.db1.put('spam', 'eggs')
562f19e
+        self.db1.close()
562f19e
+
562f19e
+        shutil.copy(self.db_path_1, self.db_path_2)
562f19e
+
562f19e
+        self.db2 = db.DB()
562f19e
+        self.db2.open(self.db_path_2, dbtype=db.DB_HASH)
562f19e
+        self.db2.put('spam', 'spam')
562f19e
+        self.db2.close()
562f19e
+
562f19e
+        self.db_env = db.DBEnv()
562f19e
+        self.db_env.open(self.db_env_path, db.DB_CREATE|db.DB_INIT_MPOOL)
562f19e
+
562f19e
+        # use fileid_reset() here
562f19e
+        self.db_env.fileid_reset(self.db_path_2)
562f19e
+
562f19e
+        self.db1 = db.DB(self.db_env)
562f19e
+        self.db1.open(self.db_path_1, dbtype=db.DB_HASH, flags=db.DB_RDONLY)
562f19e
+        self.assertEquals(self.db1.get('spam'), 'eggs')
562f19e
+
562f19e
+        self.db2 = db.DB(self.db_env)
562f19e
+        self.db2.open(self.db_path_2, dbtype=db.DB_HASH, flags=db.DB_RDONLY)
562f19e
+        self.assertEquals(self.db2.get('spam'), 'spam')
562f19e
+
562f19e
+        self.db1.close()
562f19e
+        self.db2.close()
562f19e
+
562f19e
+        self.db_env.close()
562f19e
+
562f19e
+    def tearDown(self):
562f19e
+        test_support.unlink(self.db_path_1)
562f19e
+        test_support.unlink(self.db_path_2)
562f19e
+        test_support.rmtree(self.db_env_path)
562f19e
+
562f19e
+def test_suite():
562f19e
+    suite = unittest.TestSuite()
562f19e
+    if db.version() >= (4, 4):
562f19e
+        suite.addTest(unittest.makeSuite(FileidResetTestCase))
562f19e
+    return suite
562f19e
+
562f19e
+if __name__ == '__main__':
562f19e
+    unittest.main(defaultTest='test_suite')
562f19e
+
562f19e
+
562f19e
diff -Nupr Python-2.6.4.orig/Lib/bsddb/test/test_lock.py Python-2.6.4/Lib/bsddb/test/test_lock.py
562f19e
--- Python-2.6.4.orig/Lib/bsddb/test/test_lock.py	2009-01-26 16:53:32.000000000 -0500
562f19e
+++ Python-2.6.4/Lib/bsddb/test/test_lock.py	2009-12-04 07:36:00.000000000 -0500
562f19e
@@ -89,7 +89,18 @@ class LockingTestCase(unittest.TestCase)
562f19e
         for t in threads:
562f19e
             t.join()
562f19e
 
562f19e
-    def test03_lock_timeout(self):
562f19e
+    if db.version() >= (4, 2) :
562f19e
+        def test03_lock_timeout(self):
562f19e
+            self.env.set_timeout(0, db.DB_SET_LOCK_TIMEOUT)
562f19e
+            self.assertEqual(self.env.get_timeout(db.DB_SET_LOCK_TIMEOUT), 0)
562f19e
+            self.env.set_timeout(0, db.DB_SET_TXN_TIMEOUT)
562f19e
+            self.assertEqual(self.env.get_timeout(db.DB_SET_TXN_TIMEOUT), 0)
562f19e
+            self.env.set_timeout(123456, db.DB_SET_LOCK_TIMEOUT)
562f19e
+            self.assertEqual(self.env.get_timeout(db.DB_SET_LOCK_TIMEOUT), 123456)
562f19e
+            self.env.set_timeout(7890123, db.DB_SET_TXN_TIMEOUT)
562f19e
+            self.assertEqual(self.env.get_timeout(db.DB_SET_TXN_TIMEOUT), 7890123)
562f19e
+
562f19e
+    def test04_lock_timeout2(self):
562f19e
         self.env.set_timeout(0, db.DB_SET_LOCK_TIMEOUT)
562f19e
         self.env.set_timeout(0, db.DB_SET_TXN_TIMEOUT)
562f19e
         self.env.set_timeout(123456, db.DB_SET_LOCK_TIMEOUT)
562f19e
@@ -124,7 +135,7 @@ class LockingTestCase(unittest.TestCase)
562f19e
                 self.env.lock_get,anID2, "shared lock", db.DB_LOCK_READ)
562f19e
         end_time=time.time()
562f19e
         deadlock_detection.end=True
562f19e
-        self.assertTrue((end_time-start_time) >= 0.0999)
562f19e
+        self.assertTrue((end_time-start_time) >= 0.1)
562f19e
         self.env.lock_put(lock)
562f19e
         t.join()
562f19e
 
562f19e
diff -Nupr Python-2.6.4.orig/Lib/bsddb/test/test_pickle.py Python-2.6.4/Lib/bsddb/test/test_pickle.py
562f19e
--- Python-2.6.4.orig/Lib/bsddb/test/test_pickle.py	2008-08-31 10:00:51.000000000 -0400
562f19e
+++ Python-2.6.4/Lib/bsddb/test/test_pickle.py	2009-12-04 07:36:00.000000000 -0500
562f19e
@@ -1,10 +1,16 @@
562f19e
 
562f19e
 import os
562f19e
 import pickle
562f19e
-try:
562f19e
-    import cPickle
562f19e
-except ImportError:
562f19e
+import sys
562f19e
+
562f19e
+if sys.version_info[0] < 3 :
562f19e
+    try:
562f19e
+        import cPickle
562f19e
+    except ImportError:
562f19e
+        cPickle = None
562f19e
+else :
562f19e
     cPickle = None
562f19e
+
562f19e
 import unittest
562f19e
 
562f19e
 from test_all import db, test_support, get_new_environment_path, get_new_database_path
562f19e
diff -Nupr Python-2.6.4.orig/Lib/bsddb/test/test_recno.py Python-2.6.4/Lib/bsddb/test/test_recno.py
562f19e
--- Python-2.6.4.orig/Lib/bsddb/test/test_recno.py	2009-07-02 11:37:21.000000000 -0400
562f19e
+++ Python-2.6.4/Lib/bsddb/test/test_recno.py	2009-12-04 07:36:00.000000000 -0500
562f19e
@@ -150,7 +150,7 @@ class SimpleRecnoTestCase(unittest.TestC
562f19e
         if verbose:
562f19e
             print rec
562f19e
 
562f19e
-        # test that non-existent key lookups work (and that
562f19e
+        # test that non-existant key lookups work (and that
562f19e
         # DBC_set_range doesn't have a memleak under valgrind)
562f19e
         rec = c.set_range(999999)
562f19e
         self.assertEqual(rec, None)
562f19e
diff -Nupr Python-2.6.4.orig/Lib/bsddb/test/test_replication.py Python-2.6.4/Lib/bsddb/test/test_replication.py
562f19e
--- Python-2.6.4.orig/Lib/bsddb/test/test_replication.py	2008-09-17 22:47:35.000000000 -0400
562f19e
+++ Python-2.6.4/Lib/bsddb/test/test_replication.py	2009-12-04 07:36:00.000000000 -0500
562f19e
@@ -119,19 +119,7 @@ class DBReplicationManager(unittest.Test
562f19e
         timeout = time.time()+10
562f19e
         while (time.time()
562f19e
             time.sleep(0.02)
562f19e
-        # this fails on Windows as self.client_startupdone never gets set
562f19e
-        # to True - see bug 3892.  BUT - even though this assertion
562f19e
-        # fails on Windows the rest of the test passes - so to prove
562f19e
-        # that we let the rest of the test run.  Sadly we can't
562f19e
-        # make use of raising TestSkipped() here (unittest still
562f19e
-        # reports it as an error), so we yell to stderr.
562f19e
-        import sys
562f19e
-        if sys.platform=="win32":
562f19e
-            print >> sys.stderr, \
562f19e
-                "XXX - windows bsddb replication fails on windows and is skipped"
562f19e
-            print >> sys.stderr, "XXX - Please see issue #3892"
562f19e
-        else:
562f19e
-            self.assertTrue(time.time()
562f19e
+        self.assertTrue(time.time()
562f19e
 
562f19e
         d = self.dbenvMaster.repmgr_site_list()
562f19e
         self.assertEquals(len(d), 1)
562f19e
@@ -340,6 +328,9 @@ class DBBaseReplication(DBReplicationMan
562f19e
             txn.commit()
562f19e
             break
562f19e
 
562f19e
+        d = self.dbenvMaster.rep_stat(flags=db.DB_STAT_CLEAR);
562f19e
+        self.assertTrue("master_changes" in d)
562f19e
+
562f19e
         txn=self.dbenvMaster.txn_begin()
562f19e
         self.dbMaster.put("ABC", "123", txn=txn)
562f19e
         txn.commit()
562f19e
@@ -430,6 +421,14 @@ class DBBaseReplication(DBReplicationMan
562f19e
 
562f19e
             self.assertTrue(self.confirmed_master)
562f19e
 
562f19e
+    if db.version() >= (4,7) :
562f19e
+        def test04_test_clockskew(self) :
562f19e
+            fast, slow = 1234, 1230
562f19e
+            self.dbenvMaster.rep_set_clockskew(fast, slow)
562f19e
+            self.assertEqual((fast, slow),
562f19e
+                    self.dbenvMaster.rep_get_clockskew())
562f19e
+            self.basic_rep_threading()
562f19e
+
562f19e
 #----------------------------------------------------------------------
562f19e
 
562f19e
 def test_suite():
562f19e
diff -Nupr Python-2.6.4.orig/Lib/bsddb/test/test_sequence.py Python-2.6.4/Lib/bsddb/test/test_sequence.py
562f19e
--- Python-2.6.4.orig/Lib/bsddb/test/test_sequence.py	2008-08-31 10:00:51.000000000 -0400
562f19e
+++ Python-2.6.4/Lib/bsddb/test/test_sequence.py	2009-12-04 07:36:00.000000000 -0500
562f19e
@@ -37,7 +37,7 @@ class DBSequenceTest(unittest.TestCase):
562f19e
         self.seq = db.DBSequence(self.d, flags=0)
562f19e
         start_value = 10 * self.int_32_max
562f19e
         self.assertEqual(0xA00000000, start_value)
562f19e
-        self.assertEquals(None, self.seq.init_value(start_value))
562f19e
+        self.assertEquals(None, self.seq.initial_value(start_value))
562f19e
         self.assertEquals(None, self.seq.open(key='id', txn=None, flags=db.DB_CREATE))
562f19e
         self.assertEquals(start_value, self.seq.get(5))
562f19e
         self.assertEquals(start_value + 5, self.seq.get())
562f19e
@@ -77,7 +77,7 @@ class DBSequenceTest(unittest.TestCase):
562f19e
         self.seq = db.DBSequence(self.d, flags=0)
562f19e
         seq_range = (10 * self.int_32_max, 11 * self.int_32_max - 1)
562f19e
         self.assertEquals(None, self.seq.set_range(seq_range))
562f19e
-        self.seq.init_value(seq_range[0])
562f19e
+        self.seq.initial_value(seq_range[0])
562f19e
         self.assertEquals(None, self.seq.open(key='foo', txn=None, flags=db.DB_CREATE))
562f19e
         self.assertEquals(seq_range, self.seq.get_range())
562f19e
 
562f19e
@@ -110,7 +110,7 @@ class DBSequenceTest(unittest.TestCase):
562f19e
         value_minus=(-1L<<63)+1  # Two complement
562f19e
         self.assertEquals(-9223372036854775807L,value_minus)
562f19e
         self.seq = db.DBSequence(self.d, flags=0)
562f19e
-        self.assertEquals(None, self.seq.init_value(value_plus-1))
562f19e
+        self.assertEquals(None, self.seq.initial_value(value_plus-1))
562f19e
         self.assertEquals(None, self.seq.open(key='id', txn=None,
562f19e
             flags=db.DB_CREATE))
562f19e
         self.assertEquals(value_plus-1, self.seq.get(1))
562f19e
@@ -119,7 +119,7 @@ class DBSequenceTest(unittest.TestCase):
562f19e
         self.seq.remove(txn=None, flags=0)
562f19e
 
562f19e
         self.seq = db.DBSequence(self.d, flags=0)
562f19e
-        self.assertEquals(None, self.seq.init_value(value_minus))
562f19e
+        self.assertEquals(None, self.seq.initial_value(value_minus))
562f19e
         self.assertEquals(None, self.seq.open(key='id', txn=None,
562f19e
             flags=db.DB_CREATE))
562f19e
         self.assertEquals(value_minus, self.seq.get(1))
562f19e
diff -Nupr Python-2.6.4.orig/Lib/bsddb/test_support.py Python-2.6.4/Lib/bsddb/test_support.py
562f19e
--- Python-2.6.4.orig/Lib/bsddb/test_support.py	1969-12-31 19:00:00.000000000 -0500
562f19e
+++ Python-2.6.4/Lib/bsddb/test_support.py	2009-12-04 07:36:00.000000000 -0500
562f19e
@@ -0,0 +1,54 @@
562f19e
+# This module is a bridge.
562f19e
+#
562f19e
+# Code is copied from Python 2.6 (trunk) Lib/test/test_support.py that
562f19e
+# the bsddb test suite needs even when run standalone on a python
562f19e
+# version that may not have all of these.
562f19e
+
562f19e
+# DO NOT ADD NEW UNIQUE CODE.  Copy code from the python trunk
562f19e
+# trunk test_support module into here.  If you need a place for your
562f19e
+# own stuff specific to bsddb tests, make a bsddb.test.foo module.
562f19e
+
562f19e
+import errno
562f19e
+import os
562f19e
+import shutil
562f19e
+import socket
562f19e
+
562f19e
+def unlink(filename):
562f19e
+    try:
562f19e
+        os.unlink(filename)
562f19e
+    except OSError:
562f19e
+        pass
562f19e
+
562f19e
+def rmtree(path):
562f19e
+    try:
562f19e
+        shutil.rmtree(path)
562f19e
+    except OSError, e:
562f19e
+        # Unix returns ENOENT, Windows returns ESRCH.
562f19e
+        if e.errno not in (errno.ENOENT, errno.ESRCH):
562f19e
+            raise
562f19e
+
562f19e
+def find_unused_port(family=socket.AF_INET, socktype=socket.SOCK_STREAM):
562f19e
+    tempsock = socket.socket(family, socktype)
562f19e
+    port = bind_port(tempsock, family=family, socktype=socktype)
562f19e
+    tempsock.close()
562f19e
+    del tempsock
562f19e
+    return port
562f19e
+
562f19e
+HOST = 'localhost'
562f19e
+def bind_port(sock, family, socktype, host=HOST):
562f19e
+    if family == socket.AF_INET and type == socket.SOCK_STREAM:
562f19e
+        if hasattr(socket, 'SO_REUSEADDR'):
562f19e
+            if sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR) == 1:
562f19e
+                raise TestFailed("tests should never set the SO_REUSEADDR "   \
562f19e
+                                 "socket option on TCP/IP sockets!")
562f19e
+        if hasattr(socket, 'SO_REUSEPORT'):
562f19e
+            if sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT) == 1:
562f19e
+                raise TestFailed("tests should never set the SO_REUSEPORT "   \
562f19e
+                                 "socket option on TCP/IP sockets!")
562f19e
+        if hasattr(socket, 'SO_EXCLUSIVEADDRUSE'):
562f19e
+            sock.setsockopt(socket.SOL_SOCKET, socket.SO_EXCLUSIVEADDRUSE, 1)
562f19e
+
562f19e
+    sock.bind((host, 0))
562f19e
+    port = sock.getsockname()[1]
562f19e
+    return port
562f19e
+
562f19e
diff -Nupr Python-2.6.4.orig/Modules/_bsddb.c Python-2.6.4/Modules/_bsddb.c
562f19e
--- Python-2.6.4.orig/Modules/_bsddb.c	2008-09-23 14:54:08.000000000 -0400
562f19e
+++ Python-2.6.4/Modules/_bsddb.c	2009-12-04 07:34:56.000000000 -0500
562f19e
@@ -95,7 +95,7 @@
562f19e
 #include "bsddb.h"
562f19e
 #undef COMPILING_BSDDB_C
562f19e
 
562f19e
-static char *rcs_id = "$Id: _bsddb.c 66568 2008-09-23 18:54:08Z jesus.cea $";
562f19e
+static char *rcs_id = "$Id: _bsddb.c 732 2009-11-05 19:39:04Z jcea $";
562f19e
 
562f19e
 /* --------------------------------------------------------------------- */
562f19e
 /* Various macro definitions */
562f19e
@@ -169,9 +169,6 @@ static PyInterpreterState* _db_interpret
562f19e
 
562f19e
 #endif
562f19e
 
562f19e
-/* Should DB_INCOMPLETE be turned into a warning or an exception? */
562f19e
-#define INCOMPLETE_IS_WARNING 1
562f19e
-
562f19e
 /* --------------------------------------------------------------------- */
562f19e
 /* Exceptions */
562f19e
 
562f19e
@@ -191,10 +188,6 @@ static PyObject* DBNoServerIDError;     
562f19e
 static PyObject* DBPageNotFoundError;   /* DB_PAGE_NOTFOUND */
562f19e
 static PyObject* DBSecondaryBadError;   /* DB_SECONDARY_BAD */
562f19e
 
562f19e
-#if !INCOMPLETE_IS_WARNING
562f19e
-static PyObject* DBIncompleteError;     /* DB_INCOMPLETE */
562f19e
-#endif
562f19e
-
562f19e
 static PyObject* DBInvalidArgError;     /* EINVAL */
562f19e
 static PyObject* DBAccessError;         /* EACCES */
562f19e
 static PyObject* DBNoSpaceError;        /* ENOSPC */
562f19e
@@ -208,6 +201,13 @@ static PyObject* DBPermissionsError;    
562f19e
 #if (DBVER >= 42)
562f19e
 static PyObject* DBRepHandleDeadError;  /* DB_REP_HANDLE_DEAD */
562f19e
 #endif
562f19e
+#if (DBVER >= 44)
562f19e
+static PyObject* DBRepLockoutError;     /* DB_REP_LOCKOUT */
562f19e
+#endif
562f19e
+
562f19e
+#if (DBVER >= 46)
562f19e
+static PyObject* DBRepLeaseExpiredError; /* DB_REP_LEASE_EXPIRED */
562f19e
+#endif
562f19e
 
562f19e
 static PyObject* DBRepUnavailError;     /* DB_REP_UNAVAIL */
562f19e
 
562f19e
@@ -215,6 +215,10 @@ static PyObject* DBRepUnavailError;     
562f19e
 #define	DB_BUFFER_SMALL		ENOMEM
562f19e
 #endif
562f19e
 
562f19e
+#if (DBVER < 48)
562f19e
+#define DB_GID_SIZE DB_XIDDATASIZE
562f19e
+#endif
562f19e
+
562f19e
 
562f19e
 /* --------------------------------------------------------------------- */
562f19e
 /* Structure definitions */
562f19e
@@ -667,27 +671,8 @@ static int makeDBError(int err)
562f19e
     unsigned int bytes_left;
562f19e
 
562f19e
     switch (err) {
562f19e
-        case 0:                     /* successful, no error */      break;
562f19e
-
562f19e
-#if (DBVER < 41)
562f19e
-        case DB_INCOMPLETE:
562f19e
-#if INCOMPLETE_IS_WARNING
562f19e
-            bytes_left = our_strlcpy(errTxt, db_strerror(err), sizeof(errTxt));
562f19e
-            /* Ensure that bytes_left never goes negative */
562f19e
-            if (_db_errmsg[0] && bytes_left < (sizeof(errTxt) - 4)) {
562f19e
-                bytes_left = sizeof(errTxt) - bytes_left - 4 - 1;
562f19e
-		assert(bytes_left >= 0);
562f19e
-                strcat(errTxt, " -- ");
562f19e
-                strncat(errTxt, _db_errmsg, bytes_left);
562f19e
-            }
562f19e
-            _db_errmsg[0] = 0;
562f19e
-            exceptionRaised = PyErr_Warn(PyExc_RuntimeWarning, errTxt);
562f19e
-
562f19e
-#else  /* do an exception instead */
562f19e
-        errObj = DBIncompleteError;
562f19e
-#endif
562f19e
-        break;
562f19e
-#endif /* DBVER < 41 */
562f19e
+        case 0:                     /* successful, no error */
562f19e
+            return 0;
562f19e
 
562f19e
         case DB_KEYEMPTY:           errObj = DBKeyEmptyError;       break;
562f19e
         case DB_KEYEXIST:           errObj = DBKeyExistError;       break;
562f19e
@@ -720,6 +705,13 @@ static int makeDBError(int err)
562f19e
 #if (DBVER >= 42)
562f19e
         case DB_REP_HANDLE_DEAD : errObj = DBRepHandleDeadError; break;
562f19e
 #endif
562f19e
+#if (DBVER >= 44)
562f19e
+        case DB_REP_LOCKOUT : errObj = DBRepLockoutError; break;
562f19e
+#endif
562f19e
+
562f19e
+#if (DBVER >= 46)
562f19e
+        case DB_REP_LEASE_EXPIRED : errObj = DBRepLeaseExpiredError; break;
562f19e
+#endif
562f19e
 
562f19e
         case DB_REP_UNAVAIL : errObj = DBRepUnavailError; break;
562f19e
 
562f19e
@@ -1417,10 +1409,70 @@ _db_associateCallback(DB* db, const DBT*
562f19e
 		PyErr_Print();
562f19e
 	    }
562f19e
         }
562f19e
+#if (DBVER >= 46)
562f19e
+        else if (PyList_Check(result))
562f19e
+        {
562f19e
+            char* data;
562f19e
+            Py_ssize_t size;
562f19e
+            int i, listlen;
562f19e
+            DBT* dbts;
562f19e
+
562f19e
+            listlen = PyList_Size(result);
562f19e
+
562f19e
+            dbts = (DBT *)malloc(sizeof(DBT) * listlen);
562f19e
+
562f19e
+            for (i=0; i
562f19e
+            {
562f19e
+                if (!PyBytes_Check(PyList_GetItem(result, i)))
562f19e
+                {
562f19e
+                    PyErr_SetString(
562f19e
+                       PyExc_TypeError,
562f19e
+#if (PY_VERSION_HEX < 0x03000000)
562f19e
+"The list returned by DB->associate callback should be a list of strings.");
562f19e
+#else
562f19e
+"The list returned by DB->associate callback should be a list of bytes.");
562f19e
+#endif
562f19e
+                    PyErr_Print();
562f19e
+                }
562f19e
+
562f19e
+                PyBytes_AsStringAndSize(
562f19e
+                    PyList_GetItem(result, i),
562f19e
+                    &data, &size);
562f19e
+
562f19e
+                CLEAR_DBT(dbts[i]);
562f19e
+                dbts[i].data = malloc(size);          /* TODO, check this */
562f19e
+
562f19e
+                if (dbts[i].data)
562f19e
+                {
562f19e
+                    memcpy(dbts[i].data, data, size);
562f19e
+                    dbts[i].size = size;
562f19e
+                    dbts[i].ulen = dbts[i].size;
562f19e
+                    dbts[i].flags = DB_DBT_APPMALLOC;  /* DB will free */
562f19e
+                }
562f19e
+                else
562f19e
+                {
562f19e
+                    PyErr_SetString(PyExc_MemoryError,
562f19e
+                        "malloc failed in _db_associateCallback (list)");
562f19e
+                    PyErr_Print();
562f19e
+                }
562f19e
+            }
562f19e
+
562f19e
+            CLEAR_DBT(*secKey);
562f19e
+
562f19e
+            secKey->data = dbts;
562f19e
+            secKey->size = listlen;
562f19e
+            secKey->flags = DB_DBT_APPMALLOC | DB_DBT_MULTIPLE;
562f19e
+            retval = 0;
562f19e
+        }
562f19e
+#endif
562f19e
         else {
562f19e
             PyErr_SetString(
562f19e
                PyExc_TypeError,
562f19e
-               "DB associate callback should return DB_DONOTINDEX or string.");
562f19e
+#if (PY_VERSION_HEX < 0x03000000)
562f19e
+"DB associate callback should return DB_DONOTINDEX/string/list of strings.");
562f19e
+#else
562f19e
+"DB associate callback should return DB_DONOTINDEX/bytes/list of bytes.");
562f19e
+#endif
562f19e
             PyErr_Print();
562f19e
         }
562f19e
 
562f19e
@@ -1439,29 +1491,18 @@ DB_associate(DBObject* self, PyObject* a
562f19e
     int err, flags=0;
562f19e
     DBObject* secondaryDB;
562f19e
     PyObject* callback;
562f19e
-#if (DBVER >= 41)
562f19e
     PyObject *txnobj = NULL;
562f19e
     DB_TXN *txn = NULL;
562f19e
     static char* kwnames[] = {"secondaryDB", "callback", "flags", "txn",
562f19e
                                     NULL};
562f19e
-#else
562f19e
-    static char* kwnames[] = {"secondaryDB", "callback", "flags", NULL};
562f19e
-#endif
562f19e
 
562f19e
-#if (DBVER >= 41)
562f19e
     if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|iO:associate", kwnames,
562f19e
                                      &secondaryDB, &callback, &flags,
562f19e
                                      &txnobj)) {
562f19e
-#else
562f19e
-    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|i:associate", kwnames,
562f19e
-                                     &secondaryDB, &callback, &flags)) {
562f19e
-#endif
562f19e
         return NULL;
562f19e
     }
562f19e
 
562f19e
-#if (DBVER >= 41)
562f19e
     if (!checkTxnObj(txnobj, &txn)) return NULL;
562f19e
-#endif
562f19e
 
562f19e
     CHECK_DB_NOT_CLOSED(self);
562f19e
     if (!DBObject_Check(secondaryDB)) {
562f19e
@@ -1497,18 +1538,11 @@ DB_associate(DBObject* self, PyObject* a
562f19e
     PyEval_InitThreads();
562f19e
 #endif
562f19e
     MYDB_BEGIN_ALLOW_THREADS;
562f19e
-#if (DBVER >= 41)
562f19e
     err = self->db->associate(self->db,
562f19e
 	                      txn,
562f19e
                               secondaryDB->db,
562f19e
                               _db_associateCallback,
562f19e
                               flags);
562f19e
-#else
562f19e
-    err = self->db->associate(self->db,
562f19e
-                              secondaryDB->db,
562f19e
-                              _db_associateCallback,
562f19e
-                              flags);
562f19e
-#endif
562f19e
     MYDB_END_ALLOW_THREADS;
562f19e
 
562f19e
     if (err) {
562f19e
@@ -1701,6 +1735,64 @@ DB_delete(DBObject* self, PyObject* args
562f19e
 }
562f19e
 
562f19e
 
562f19e
+#if (DBVER >= 47)
562f19e
+/*
562f19e
+** This function is available since Berkeley DB 4.4,
562f19e
+** but 4.6 version is so buggy that we only support
562f19e
+** it from BDB 4.7 and newer.
562f19e
+*/
562f19e
+static PyObject*
562f19e
+DB_compact(DBObject* self, PyObject* args, PyObject* kwargs)
562f19e
+{
562f19e
+    PyObject* txnobj = NULL;
562f19e
+    PyObject *startobj = NULL, *stopobj = NULL;
562f19e
+    int flags = 0;
562f19e
+    DB_TXN *txn = NULL;
562f19e
+    DBT *start_p = NULL, *stop_p = NULL;
562f19e
+    DBT start, stop;
562f19e
+    int err;
562f19e
+    DB_COMPACT c_data = { 0 };
562f19e
+    static char* kwnames[] = { "txn", "start", "stop", "flags",
562f19e
+                               "compact_fillpercent", "compact_pages",
562f19e
+                               "compact_timeout", NULL };
562f19e
+
562f19e
+
562f19e
+    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OOOiiiI:compact", kwnames,
562f19e
+                                     &txnobj, &startobj, &stopobj, &flags,
562f19e
+                                     &c_data.compact_fillpercent,
562f19e
+                                     &c_data.compact_pages,
562f19e
+                                     &c_data.compact_timeout))
562f19e
+        return NULL;
562f19e
+
562f19e
+    CHECK_DB_NOT_CLOSED(self);
562f19e
+    if (!checkTxnObj(txnobj, &txn)) {
562f19e
+        return NULL;
562f19e
+    }
562f19e
+
562f19e
+    if (startobj && make_key_dbt(self, startobj, &start, NULL)) {
562f19e
+        start_p = &start;
562f19e
+    }
562f19e
+    if (stopobj && make_key_dbt(self, stopobj, &stop, NULL)) {
562f19e
+        stop_p = &sto;;
562f19e
+    }
562f19e
+
562f19e
+    MYDB_BEGIN_ALLOW_THREADS;
562f19e
+    err = self->db->compact(self->db, txn, start_p, stop_p, &c_data,
562f19e
+                            flags, NULL);
562f19e
+    MYDB_END_ALLOW_THREADS;
562f19e
+
562f19e
+    if (startobj)
562f19e
+        FREE_DBT(start);
562f19e
+    if (stopobj)
562f19e
+        FREE_DBT(stop);
562f19e
+ 
562f19e
+    RETURN_IF_ERR();
562f19e
+
562f19e
+    return PyLong_FromUnsignedLong(c_data.compact_pages_truncated);
562f19e
+}
562f19e
+#endif
562f19e
+
562f19e
+
562f19e
 static PyObject*
562f19e
 DB_fd(DBObject* self)
562f19e
 {
562f19e
@@ -1716,6 +1808,55 @@ DB_fd(DBObject* self)
562f19e
 }
562f19e
 
562f19e
 
562f19e
+#if (DBVER >= 46)
562f19e
+static PyObject*
562f19e
+DB_exists(DBObject* self, PyObject* args, PyObject* kwargs)
562f19e
+{
562f19e
+    int err, flags=0;
562f19e
+    PyObject* txnobj = NULL;
562f19e
+    PyObject* keyobj;
562f19e
+    DBT key;
562f19e
+    DB_TXN *txn;
562f19e
+
562f19e
+    static char* kwnames[] = {"key", "txn", "flags", NULL};
562f19e
+
562f19e
+    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|Oi:exists", kwnames,
562f19e
+                &keyobj, &txnobj, &flags))
562f19e
+        return NULL;
562f19e
+
562f19e
+    CHECK_DB_NOT_CLOSED(self);
562f19e
+    if (!make_key_dbt(self, keyobj, &key, NULL))
562f19e
+        return NULL;
562f19e
+    if (!checkTxnObj(txnobj, &txn)) {
562f19e
+        FREE_DBT(key);
562f19e
+        return NULL;
562f19e
+    }
562f19e
+
562f19e
+    MYDB_BEGIN_ALLOW_THREADS;
562f19e
+    err = self->db->exists(self->db, txn, &key, flags);
562f19e
+    MYDB_END_ALLOW_THREADS;
562f19e
+
562f19e
+    FREE_DBT(key);
562f19e
+
562f19e
+    if (!err) {
562f19e
+        Py_INCREF(Py_True);
562f19e
+        return Py_True;
562f19e
+    }
562f19e
+    if ((err == DB_NOTFOUND || err == DB_KEYEMPTY)) {
562f19e
+        Py_INCREF(Py_False);
562f19e
+        return Py_False;
562f19e
+    }
562f19e
+
562f19e
+    /*
562f19e
+    ** If we reach there, there was an error. The
562f19e
+    ** "return" should be unreachable.
562f19e
+    */
562f19e
+    RETURN_IF_ERR();
562f19e
+    assert(0);  /* This coude SHOULD be unreachable */
562f19e
+    return NULL;
562f19e
+}
562f19e
+#endif
562f19e
+
562f19e
 static PyObject*
562f19e
 DB_get(DBObject* self, PyObject* args, PyObject* kwargs)
562f19e
 {
562f19e
@@ -2114,7 +2255,6 @@ DB_open(DBObject* self, PyObject* args, 
562f19e
     int err, type = DB_UNKNOWN, flags=0, mode=0660;
562f19e
     char* filename = NULL;
562f19e
     char* dbname = NULL;
562f19e
-#if (DBVER >= 41)
562f19e
     PyObject *txnobj = NULL;
562f19e
     DB_TXN *txn = NULL;
562f19e
     /* with dbname */
562f19e
@@ -2123,45 +2263,22 @@ DB_open(DBObject* self, PyObject* args, 
562f19e
     /* without dbname */
562f19e
     static char* kwnames_basic[] = {
562f19e
         "filename", "dbtype", "flags", "mode", "txn", NULL};
562f19e
-#else
562f19e
-    /* with dbname */
562f19e
-    static char* kwnames[] = {
562f19e
-        "filename", "dbname", "dbtype", "flags", "mode", NULL};
562f19e
-    /* without dbname */
562f19e
-    static char* kwnames_basic[] = {
562f19e
-        "filename", "dbtype", "flags", "mode", NULL};
562f19e
-#endif
562f19e
 
562f19e
-#if (DBVER >= 41)
562f19e
     if (!PyArg_ParseTupleAndKeywords(args, kwargs, "z|ziiiO:open", kwnames,
562f19e
 				     &filename, &dbname, &type, &flags, &mode,
562f19e
                                      &txnobj))
562f19e
-#else
562f19e
-    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "z|ziii:open", kwnames,
562f19e
-				     &filename, &dbname, &type, &flags,
562f19e
-                                     &mode))
562f19e
-#endif
562f19e
     {
562f19e
 	PyErr_Clear();
562f19e
 	type = DB_UNKNOWN; flags = 0; mode = 0660;
562f19e
 	filename = NULL; dbname = NULL;
562f19e
-#if (DBVER >= 41)
562f19e
 	if (!PyArg_ParseTupleAndKeywords(args, kwargs,"z|iiiO:open",
562f19e
                                          kwnames_basic,
562f19e
 					 &filename, &type, &flags, &mode,
562f19e
                                          &txnobj))
562f19e
 	    return NULL;
562f19e
-#else
562f19e
-	if (!PyArg_ParseTupleAndKeywords(args, kwargs,"z|iii:open",
562f19e
-                                         kwnames_basic,
562f19e
-					 &filename, &type, &flags, &mode))
562f19e
-	    return NULL;
562f19e
-#endif
562f19e
     }
562f19e
 
562f19e
-#if (DBVER >= 41)
562f19e
     if (!checkTxnObj(txnobj, &txn)) return NULL;
562f19e
-#endif
562f19e
 
562f19e
     if (NULL == self->db) {
562f19e
         PyObject *t = Py_BuildValue("(is)", 0,
562f19e
@@ -2173,24 +2290,17 @@ DB_open(DBObject* self, PyObject* args, 
562f19e
         return NULL;
562f19e
     }
562f19e
 
562f19e
-#if (DBVER >= 41)
562f19e
     if (txn) {  /* Can't use 'txnobj' because could be 'txnobj==Py_None' */
562f19e
         INSERT_IN_DOUBLE_LINKED_LIST_TXN(((DBTxnObject *)txnobj)->children_dbs,self);
562f19e
         self->txn=(DBTxnObject *)txnobj;
562f19e
     } else {
562f19e
         self->txn=NULL;
562f19e
     }
562f19e
-#else
562f19e
-    self->txn=NULL;
562f19e
-#endif
562f19e
 
562f19e
     MYDB_BEGIN_ALLOW_THREADS;
562f19e
-#if (DBVER >= 41)
562f19e
     err = self->db->open(self->db, txn, filename, dbname, type, flags, mode);
562f19e
-#else
562f19e
-    err = self->db->open(self->db, filename, dbname, type, flags, mode);
562f19e
-#endif
562f19e
     MYDB_END_ALLOW_THREADS;
562f19e
+
562f19e
     if (makeDBError(err)) {
562f19e
         PyObject *dummy;
562f19e
 
562f19e
@@ -2490,6 +2600,25 @@ DB_set_cachesize(DBObject* self, PyObjec
562f19e
     RETURN_NONE();
562f19e
 }
562f19e
 
562f19e
+#if (DBVER >= 42)
562f19e
+static PyObject*
562f19e
+DB_get_cachesize(DBObject* self)
562f19e
+{
562f19e
+    int err;
562f19e
+    u_int32_t gbytes, bytes;
562f19e
+    int ncache;
562f19e
+
562f19e
+    CHECK_DB_NOT_CLOSED(self);
562f19e
+
562f19e
+    MYDB_BEGIN_ALLOW_THREADS;
562f19e
+    err = self->db->get_cachesize(self->db, &gbytes, &bytes, &ncache);
562f19e
+    MYDB_END_ALLOW_THREADS;
562f19e
+
562f19e
+    RETURN_IF_ERR();
562f19e
+
562f19e
+    return Py_BuildValue("(iii)", gbytes, bytes, ncache);
562f19e
+}
562f19e
+#endif
562f19e
 
562f19e
 static PyObject*
562f19e
 DB_set_flags(DBObject* self, PyObject* args)
562f19e
@@ -2730,9 +2859,6 @@ DB_stat(DBObject* self, PyObject* args, 
562f19e
         MAKE_HASH_ENTRY(pagecnt);
562f19e
 #endif
562f19e
         MAKE_HASH_ENTRY(pagesize);
562f19e
-#if (DBVER < 41)
562f19e
-        MAKE_HASH_ENTRY(nelem);
562f19e
-#endif
562f19e
         MAKE_HASH_ENTRY(ffactor);
562f19e
         MAKE_HASH_ENTRY(buckets);
562f19e
         MAKE_HASH_ENTRY(free);
562f19e
@@ -2779,9 +2905,7 @@ DB_stat(DBObject* self, PyObject* args, 
562f19e
         MAKE_QUEUE_ENTRY(nkeys);
562f19e
         MAKE_QUEUE_ENTRY(ndata);
562f19e
         MAKE_QUEUE_ENTRY(pagesize);
562f19e
-#if (DBVER >= 41)
562f19e
         MAKE_QUEUE_ENTRY(extentsize);
562f19e
-#endif
562f19e
         MAKE_QUEUE_ENTRY(pages);
562f19e
         MAKE_QUEUE_ENTRY(re_len);
562f19e
         MAKE_QUEUE_ENTRY(re_pad);
562f19e
@@ -2892,7 +3016,7 @@ DB_verify(DBObject* self, PyObject* args
562f19e
         PyObject *error;
562f19e
 
562f19e
         error=DB_close_internal(self, 0, 1);
562f19e
-        if (error ) {
562f19e
+        if (error) {
562f19e
           return error;
562f19e
         }
562f19e
      }
562f19e
@@ -2930,7 +3054,6 @@ DB_set_get_returns_none(DBObject* self, 
562f19e
     return NUMBER_FromLong(oldValue);
562f19e
 }
562f19e
 
562f19e
-#if (DBVER >= 41)
562f19e
 static PyObject*
562f19e
 DB_set_encrypt(DBObject* self, PyObject* args, PyObject* kwargs)
562f19e
 {
562f19e
@@ -2951,7 +3074,24 @@ DB_set_encrypt(DBObject* self, PyObject*
562f19e
     RETURN_IF_ERR();
562f19e
     RETURN_NONE();
562f19e
 }
562f19e
-#endif /* DBVER >= 41 */
562f19e
+
562f19e
+#if (DBVER >= 42)
562f19e
+static PyObject*
562f19e
+DB_get_encrypt_flags(DBObject* self)
562f19e
+{
562f19e
+    int err;
562f19e
+    u_int32_t flags;
562f19e
+
562f19e
+    MYDB_BEGIN_ALLOW_THREADS;
562f19e
+    err = self->db->get_encrypt_flags(self->db, &flags);
562f19e
+    MYDB_END_ALLOW_THREADS;
562f19e
+
562f19e
+    RETURN_IF_ERR();
562f19e
+
562f19e
+    return NUMBER_FromLong(flags);
562f19e
+}
562f19e
+#endif
562f19e
+
562f19e
 
562f19e
 
562f19e
 /*-------------------------------------------------------------- */
562f19e
@@ -3097,18 +3237,11 @@ DB_ass_sub(DBObject* self, PyObject* key
562f19e
 
562f19e
 
562f19e
 static PyObject*
562f19e
-DB_has_key(DBObject* self, PyObject* args, PyObject* kwargs)
562f19e
+_DB_has_key(DBObject* self, PyObject* keyobj, PyObject* txnobj)
562f19e
 {
562f19e
     int err;
562f19e
-    PyObject* keyobj;
562f19e
-    DBT key, data;
562f19e
-    PyObject* txnobj = NULL;
562f19e
+    DBT key;
562f19e
     DB_TXN *txn = NULL;
562f19e
-    static char* kwnames[] = {"key","txn", NULL};
562f19e
-
562f19e
-    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O:has_key", kwnames,
562f19e
-                &keyobj, &txnobj))
562f19e
-        return NULL;
562f19e
 
562f19e
     CHECK_DB_NOT_CLOSED(self);
562f19e
     if (!make_key_dbt(self, keyobj, &key, NULL))
562f19e
@@ -3118,28 +3251,77 @@ DB_has_key(DBObject* self, PyObject* arg
562f19e
         return NULL;
562f19e
     }
562f19e
 
562f19e
+#if (DBVER < 46)
562f19e
     /* This causes DB_BUFFER_SMALL to be returned when the db has the key because
562f19e
        it has a record but can't allocate a buffer for the data.  This saves
562f19e
        having to deal with data we won't be using.
562f19e
      */
562f19e
-    CLEAR_DBT(data);
562f19e
-    data.flags = DB_DBT_USERMEM;
562f19e
+    {
562f19e
+        DBT data ;
562f19e
+        CLEAR_DBT(data);
562f19e
+        data.flags = DB_DBT_USERMEM;
562f19e
 
562f19e
+        MYDB_BEGIN_ALLOW_THREADS;
562f19e
+        err = self->db->get(self->db, txn, &key, &data, 0);
562f19e
+        MYDB_END_ALLOW_THREADS;
562f19e
+    }
562f19e
+#else
562f19e
     MYDB_BEGIN_ALLOW_THREADS;
562f19e
-    err = self->db->get(self->db, txn, &key, &data, 0);
562f19e
+    err = self->db->exists(self->db, txn, &key, 0);
562f19e
     MYDB_END_ALLOW_THREADS;
562f19e
+#endif
562f19e
+
562f19e
     FREE_DBT(key);
562f19e
 
562f19e
+    /*
562f19e
+    ** DB_BUFFER_SMALL is only used if we use "get".
562f19e
+    ** We can drop it when we only use "exists",
562f19e
+    ** when we drop suport for Berkeley DB < 4.6.
562f19e
+    */
562f19e
     if (err == DB_BUFFER_SMALL || err == 0) {
562f19e
-        return NUMBER_FromLong(1);
562f19e
+        Py_INCREF(Py_True);
562f19e
+        return Py_True;
562f19e
     } else if (err == DB_NOTFOUND || err == DB_KEYEMPTY) {
562f19e
-        return NUMBER_FromLong(0);
562f19e
+        Py_INCREF(Py_False);
562f19e
+        return Py_False;
562f19e
     }
562f19e
 
562f19e
     makeDBError(err);
562f19e
     return NULL;
562f19e
 }
562f19e
 
562f19e
+static PyObject*
562f19e
+DB_has_key(DBObject* self, PyObject* args, PyObject* kwargs)
562f19e
+{
562f19e
+    PyObject* keyobj;
562f19e
+    PyObject* txnobj = NULL;
562f19e
+    static char* kwnames[] = {"key","txn", NULL};
562f19e
+
562f19e
+    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O:has_key", kwnames,
562f19e
+                &keyobj, &txnobj))
562f19e
+        return NULL;
562f19e
+
562f19e
+    return _DB_has_key(self, keyobj, txnobj);
562f19e
+}
562f19e
+
562f19e
+
562f19e
+static int DB_contains(DBObject* self, PyObject* keyobj)
562f19e
+{
562f19e
+    PyObject* result;
562f19e
+    int result2 = 0;
562f19e
+
562f19e
+    result = _DB_has_key(self, keyobj, NULL) ;
562f19e
+    if (result == NULL) {
562f19e
+        return -1; /* Propague exception */
562f19e
+    }
562f19e
+    if (result != Py_False) {
562f19e
+        result2 = 1;
562f19e
+    }
562f19e
+
562f19e
+    Py_DECREF(result);
562f19e
+    return result2;
562f19e
+}
562f19e
+
562f19e
 
562f19e
 #define _KEYS_LIST      1
562f19e
 #define _VALUES_LIST    2
562f19e
@@ -3970,6 +4152,13 @@ DBC_next_nodup(DBCursorObject* self, PyO
562f19e
     return _DBCursor_get(self,DB_NEXT_NODUP,args,kwargs,"|iii:next_nodup");
562f19e
 }
562f19e
 
562f19e
+#if (DBVER >= 46)
562f19e
+static PyObject*
562f19e
+DBC_prev_dup(DBCursorObject* self, PyObject* args, PyObject *kwargs)
562f19e
+{
562f19e
+    return _DBCursor_get(self,DB_PREV_DUP,args,kwargs,"|iii:prev_dup");
562f19e
+}
562f19e
+#endif
562f19e
 
562f19e
 static PyObject*
562f19e
 DBC_prev_nodup(DBCursorObject* self, PyObject* args, PyObject *kwargs)
562f19e
@@ -4012,6 +4201,44 @@ DBC_join_item(DBCursorObject* self, PyOb
562f19e
 }
562f19e
 
562f19e
 
562f19e
+#if (DBVER >= 46)
562f19e
+static PyObject*
562f19e
+DBC_set_priority(DBCursorObject* self, PyObject* args, PyObject* kwargs)
562f19e
+{
562f19e
+    int err, priority;
562f19e
+    static char* kwnames[] = { "priority", NULL };
562f19e
+
562f19e
+    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:set_priority", kwnames,
562f19e
+				     &priority))
562f19e
+        return NULL;
562f19e
+
562f19e
+    CHECK_CURSOR_NOT_CLOSED(self);
562f19e
+
562f19e
+    MYDB_BEGIN_ALLOW_THREADS;
562f19e
+    err = self->dbc->set_priority(self->dbc, priority);
562f19e
+    MYDB_END_ALLOW_THREADS;
562f19e
+    RETURN_IF_ERR();
562f19e
+    RETURN_NONE();
562f19e
+}
562f19e
+
562f19e
+
562f19e
+static PyObject*
562f19e
+DBC_get_priority(DBCursorObject* self)
562f19e
+{
562f19e
+    int err;
562f19e
+    DB_CACHE_PRIORITY priority;
562f19e
+
562f19e
+    CHECK_CURSOR_NOT_CLOSED(self);
562f19e
+
562f19e
+    MYDB_BEGIN_ALLOW_THREADS;
562f19e
+    err = self->dbc->get_priority(self->dbc, &priority);
562f19e
+    MYDB_END_ALLOW_THREADS;
562f19e
+    RETURN_IF_ERR();
562f19e
+    return NUMBER_FromLong(priority);
562f19e
+}
562f19e
+#endif
562f19e
+
562f19e
+
562f19e
 
562f19e
 /* --------------------------------------------------------------------- */
562f19e
 /* DBEnv methods */
562f19e
@@ -4095,7 +4322,6 @@ DBEnv_remove(DBEnvObject* self, PyObject
562f19e
     RETURN_NONE();
562f19e
 }
562f19e
 
562f19e
-#if (DBVER >= 41)
562f19e
 static PyObject*
562f19e
 DBEnv_dbremove(DBEnvObject* self, PyObject* args, PyObject* kwargs)
562f19e
 {
562f19e
@@ -4152,6 +4378,8 @@ DBEnv_dbrename(DBEnvObject* self, PyObje
562f19e
     RETURN_NONE();
562f19e
 }
562f19e
 
562f19e
+
562f19e
+
562f19e
 static PyObject*
562f19e
 DBEnv_set_encrypt(DBEnvObject* self, PyObject* args, PyObject* kwargs)
562f19e
 {
562f19e
@@ -4172,17 +4400,57 @@ DBEnv_set_encrypt(DBEnvObject* self, PyO
562f19e
     RETURN_IF_ERR();
562f19e
     RETURN_NONE();
562f19e
 }
562f19e
-#endif /* DBVER >= 41 */
562f19e
 
562f19e
+#if (DBVER >= 42)
562f19e
 static PyObject*
562f19e
-DBEnv_set_timeout(DBEnvObject* self, PyObject* args, PyObject* kwargs)
562f19e
+DBEnv_get_encrypt_flags(DBEnvObject* self)
562f19e
 {
562f19e
     int err;
562f19e
-    u_int32_t flags=0;
562f19e
-    u_int32_t timeout = 0;
562f19e
-    static char* kwnames[] = { "timeout", "flags", NULL };
562f19e
+    u_int32_t flags;
562f19e
 
562f19e
-    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii:set_timeout", kwnames,
562f19e
+    CHECK_ENV_NOT_CLOSED(self);
562f19e
+
562f19e
+    MYDB_BEGIN_ALLOW_THREADS;
562f19e
+    err = self->db_env->get_encrypt_flags(self->db_env, &flags);
562f19e
+    MYDB_END_ALLOW_THREADS;
562f19e
+
562f19e
+    RETURN_IF_ERR();
562f19e
+
562f19e
+    return NUMBER_FromLong(flags);
562f19e
+}
562f19e
+
562f19e
+static PyObject*
562f19e
+DBEnv_get_timeout(DBEnvObject* self, PyObject* args, PyObject* kwargs)
562f19e
+{
562f19e
+    int err;
562f19e
+    int flag;
562f19e
+    u_int32_t timeout;
562f19e
+    static char* kwnames[] = {"flag", NULL };
562f19e
+
562f19e
+    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:get_timeout", kwnames,
562f19e
+                &flag)) {
562f19e
+        return NULL;
562f19e
+    }
562f19e
+    CHECK_ENV_NOT_CLOSED(self);
562f19e
+
562f19e
+    MYDB_BEGIN_ALLOW_THREADS;
562f19e
+    err = self->db_env->get_timeout(self->db_env, &timeout, flag);
562f19e
+    MYDB_END_ALLOW_THREADS;
562f19e
+    RETURN_IF_ERR();
562f19e
+    return NUMBER_FromLong(timeout);
562f19e
+}
562f19e
+#endif
562f19e
+
562f19e
+
562f19e
+static PyObject*
562f19e
+DBEnv_set_timeout(DBEnvObject* self, PyObject* args, PyObject* kwargs)
562f19e
+{
562f19e
+    int err;
562f19e
+    u_int32_t flags=0;
562f19e
+    u_int32_t timeout = 0;
562f19e
+    static char* kwnames[] = { "timeout", "flags", NULL };
562f19e
+
562f19e
+    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii:set_timeout", kwnames,
562f19e
 		&timeout, &flags)) {
562f19e
 	return NULL;
562f19e
     }
562f19e
@@ -4210,6 +4478,25 @@ DBEnv_set_shm_key(DBEnvObject* self, PyO
562f19e
     RETURN_NONE();
562f19e
 }
562f19e
 
562f19e
+#if (DBVER >= 42)
562f19e
+static PyObject*
562f19e
+DBEnv_get_shm_key(DBEnvObject* self)
562f19e
+{
562f19e
+    int err;
562f19e
+    long shm_key;
562f19e
+
562f19e
+    CHECK_ENV_NOT_CLOSED(self);
562f19e
+
562f19e
+    MYDB_BEGIN_ALLOW_THREADS;
562f19e
+    err = self->db_env->get_shm_key(self->db_env, &shm_key);
562f19e
+    MYDB_END_ALLOW_THREADS;
562f19e
+
562f19e
+    RETURN_IF_ERR();
562f19e
+
562f19e
+    return NUMBER_FromLong(shm_key);
562f19e
+}
562f19e
+#endif
562f19e
+
562f19e
 static PyObject*
562f19e
 DBEnv_set_cachesize(DBEnvObject* self, PyObject* args)
562f19e
 {
562f19e
@@ -4227,6 +4514,26 @@ DBEnv_set_cachesize(DBEnvObject* self, P
562f19e
     RETURN_NONE();
562f19e
 }
562f19e
 
562f19e
+#if (DBVER >= 42)
562f19e
+static PyObject*
562f19e
+DBEnv_get_cachesize(DBEnvObject* self)
562f19e
+{
562f19e
+    int err;
562f19e
+    u_int32_t gbytes, bytes;
562f19e
+    int ncache;
562f19e
+
562f19e
+    CHECK_ENV_NOT_CLOSED(self);
562f19e
+
562f19e
+    MYDB_BEGIN_ALLOW_THREADS;
562f19e
+    err = self->db_env->get_cachesize(self->db_env, &gbytes, &bytes, &ncache);
562f19e
+    MYDB_END_ALLOW_THREADS;
562f19e
+
562f19e
+    RETURN_IF_ERR();
562f19e
+
562f19e
+    return Py_BuildValue("(iii)", gbytes, bytes, ncache);
562f19e
+}
562f19e
+#endif
562f19e
+
562f19e
 
562f19e
 static PyObject*
562f19e
 DBEnv_set_flags(DBEnvObject* self, PyObject* args)
562f19e
@@ -4265,6 +4572,151 @@ DBEnv_log_set_config(DBEnvObject* self, 
562f19e
 }
562f19e
 #endif /* DBVER >= 47 */
562f19e
 
562f19e
+#if (DBVER >= 44)
562f19e
+static PyObject*
562f19e
+DBEnv_mutex_set_max(DBEnvObject* self, PyObject* args)
562f19e
+{
562f19e
+    int err;
562f19e
+    int value;
562f19e
+
562f19e
+    if (!PyArg_ParseTuple(args, "i:mutex_set_max", &value))
562f19e
+        return NULL;
562f19e
+
562f19e
+    CHECK_ENV_NOT_CLOSED(self);
562f19e
+
562f19e
+    MYDB_BEGIN_ALLOW_THREADS;
562f19e
+    err = self->db_env->mutex_set_max(self->db_env, value);
562f19e
+    MYDB_END_ALLOW_THREADS;
562f19e
+
562f19e
+    RETURN_IF_ERR();
562f19e
+    RETURN_NONE();
562f19e
+}
562f19e
+
562f19e
+static PyObject*
562f19e
+DBEnv_mutex_get_max(DBEnvObject* self)
562f19e
+{
562f19e
+    int err;
562f19e
+    u_int32_t value;
562f19e
+
562f19e
+    CHECK_ENV_NOT_CLOSED(self);
562f19e
+
562f19e
+    MYDB_BEGIN_ALLOW_THREADS;
562f19e
+    err = self->db_env->mutex_get_max(self->db_env, &value);
562f19e
+    MYDB_END_ALLOW_THREADS;
562f19e
+
562f19e
+    RETURN_IF_ERR();
562f19e
+
562f19e
+    return NUMBER_FromLong(value);
562f19e
+}
562f19e
+
562f19e
+static PyObject*
562f19e
+DBEnv_mutex_set_align(DBEnvObject* self, PyObject* args)
562f19e
+{
562f19e
+    int err;
562f19e
+    int align;
562f19e
+
562f19e
+    if (!PyArg_ParseTuple(args, "i:mutex_set_align", &align))
562f19e
+        return NULL;
562f19e
+
562f19e
+    CHECK_ENV_NOT_CLOSED(self);
562f19e
+
562f19e
+    MYDB_BEGIN_ALLOW_THREADS;
562f19e
+    err = self->db_env->mutex_set_align(self->db_env, align);
562f19e
+    MYDB_END_ALLOW_THREADS;
562f19e
+
562f19e
+    RETURN_IF_ERR();
562f19e
+    RETURN_NONE();
562f19e
+}
562f19e
+
562f19e
+static PyObject*
562f19e
+DBEnv_mutex_get_align(DBEnvObject* self)
562f19e
+{
562f19e
+    int err;
562f19e
+    u_int32_t align;
562f19e
+
562f19e
+    CHECK_ENV_NOT_CLOSED(self);
562f19e
+
562f19e
+    MYDB_BEGIN_ALLOW_THREADS;
562f19e
+    err = self->db_env->mutex_get_align(self->db_env, &align);
562f19e
+    MYDB_END_ALLOW_THREADS;
562f19e
+
562f19e
+    RETURN_IF_ERR();
562f19e
+
562f19e
+    return NUMBER_FromLong(align);
562f19e
+}
562f19e
+
562f19e
+static PyObject*
562f19e
+DBEnv_mutex_set_increment(DBEnvObject* self, PyObject* args)
562f19e
+{
562f19e
+    int err;
562f19e
+    int increment;
562f19e
+
562f19e
+    if (!PyArg_ParseTuple(args, "i:mutex_set_increment", &increment))
562f19e
+        return NULL;
562f19e
+
562f19e
+    CHECK_ENV_NOT_CLOSED(self);
562f19e
+
562f19e
+    MYDB_BEGIN_ALLOW_THREADS;
562f19e
+    err = self->db_env->mutex_set_increment(self->db_env, increment);
562f19e
+    MYDB_END_ALLOW_THREADS;
562f19e
+
562f19e
+    RETURN_IF_ERR();
562f19e
+    RETURN_NONE();
562f19e
+}
562f19e
+
562f19e
+static PyObject*
562f19e
+DBEnv_mutex_get_increment(DBEnvObject* self)
562f19e
+{
562f19e
+    int err;
562f19e
+    u_int32_t increment;
562f19e
+
562f19e
+    CHECK_ENV_NOT_CLOSED(self);
562f19e
+
562f19e
+    MYDB_BEGIN_ALLOW_THREADS;
562f19e
+    err = self->db_env->mutex_get_increment(self->db_env, &increment);
562f19e
+    MYDB_END_ALLOW_THREADS;
562f19e
+
562f19e
+    RETURN_IF_ERR();
562f19e
+
562f19e
+    return NUMBER_FromLong(increment);
562f19e
+}
562f19e
+
562f19e
+static PyObject*
562f19e
+DBEnv_mutex_set_tas_spins(DBEnvObject* self, PyObject* args)
562f19e
+{
562f19e
+    int err;
562f19e
+    int tas_spins;
562f19e
+
562f19e
+    if (!PyArg_ParseTuple(args, "i:mutex_set_tas_spins", &tas_spins))
562f19e
+        return NULL;
562f19e
+
562f19e
+    CHECK_ENV_NOT_CLOSED(self);
562f19e
+
562f19e
+    MYDB_BEGIN_ALLOW_THREADS;
562f19e
+    err = self->db_env->mutex_set_tas_spins(self->db_env, tas_spins);
562f19e
+    MYDB_END_ALLOW_THREADS;
562f19e
+
562f19e
+    RETURN_IF_ERR();
562f19e
+    RETURN_NONE();
562f19e
+}
562f19e
+
562f19e
+static PyObject*
562f19e
+DBEnv_mutex_get_tas_spins(DBEnvObject* self)
562f19e
+{
562f19e
+    int err;
562f19e
+    u_int32_t tas_spins;
562f19e
+
562f19e
+    CHECK_ENV_NOT_CLOSED(self);
562f19e
+
562f19e
+    MYDB_BEGIN_ALLOW_THREADS;
562f19e
+    err = self->db_env->mutex_get_tas_spins(self->db_env, &tas_spins);
562f19e
+    MYDB_END_ALLOW_THREADS;
562f19e
+
562f19e
+    RETURN_IF_ERR();
562f19e
+
562f19e
+    return NUMBER_FromLong(tas_spins);
562f19e
+}
562f19e
+#endif
562f19e
 
562f19e
 static PyObject*
562f19e
 DBEnv_set_data_dir(DBEnvObject* self, PyObject* args)
562f19e
@@ -4283,6 +4735,47 @@ DBEnv_set_data_dir(DBEnvObject* self, Py
562f19e
     RETURN_NONE();
562f19e
 }
562f19e
 
562f19e
+#if (DBVER >= 42)
562f19e
+static PyObject*
562f19e
+DBEnv_get_data_dirs(DBEnvObject* self)
562f19e
+{
562f19e
+    int err;
562f19e
+    PyObject *tuple;
562f19e
+    PyObject *item;
562f19e
+    const char **dirpp;
562f19e
+    int size, i;
562f19e
+
562f19e
+    CHECK_ENV_NOT_CLOSED(self);
562f19e
+
562f19e
+    MYDB_BEGIN_ALLOW_THREADS;
562f19e
+    err = self->db_env->get_data_dirs(self->db_env, &dirpp);
562f19e
+    MYDB_END_ALLOW_THREADS;
562f19e
+
562f19e
+    RETURN_IF_ERR();
562f19e
+
562f19e
+    /*
562f19e
+    ** Calculate size. Python C API
562f19e
+    ** actually allows for tuple resizing,
562f19e
+    ** but this is simple enough.
562f19e
+    */
562f19e
+    for (size=0; *(dirpp+size) ; size++);
562f19e
+
562f19e
+    tuple = PyTuple_New(size);
562f19e
+    if (!tuple)
562f19e
+        return NULL;
562f19e
+
562f19e
+    for (i=0; i
562f19e
+        item = PyBytes_FromString (*(dirpp+i));
562f19e
+        if (item == NULL) {
562f19e
+            Py_DECREF(tuple);
562f19e
+            tuple = NULL;
562f19e
+            break;
562f19e
+        }
562f19e
+        PyTuple_SET_ITEM(tuple, i, item);
562f19e
+    }
562f19e
+    return tuple;
562f19e
+}
562f19e
+#endif
562f19e
 
562f19e
 static PyObject*
562f19e
 DBEnv_set_lg_bsize(DBEnvObject* self, PyObject* args)
562f19e
@@ -4501,7 +4994,11 @@ DBEnv_txn_recover(DBEnvObject* self)
562f19e
     DBTxnObject *txn;
562f19e
 #define PREPLIST_LEN 16
562f19e
     DB_PREPLIST preplist[PREPLIST_LEN];
562f19e
+#if (DBVER < 48)
562f19e
     long retp;
562f19e
+#else
562f19e
+    u_int32_t retp;
562f19e
+#endif
562f19e
 
562f19e
     CHECK_ENV_NOT_CLOSED(self);
562f19e
 
562f19e
@@ -4522,12 +5019,12 @@ DBEnv_txn_recover(DBEnvObject* self)
562f19e
         flags=DB_NEXT;  /* Prepare for next loop pass */
562f19e
         for (i=0; i
562f19e
             gid=PyBytes_FromStringAndSize((char *)(preplist[i].gid),
562f19e
-                                DB_XIDDATASIZE);
562f19e
+                                DB_GID_SIZE);
562f19e
             if (!gid) {
562f19e
                 Py_DECREF(list);
562f19e
                 return NULL;
562f19e
             }
562f19e
-            txn=newDBTxnObject(self, NULL, preplist[i].txn, flags);
562f19e
+            txn=newDBTxnObject(self, NULL, preplist[i].txn, 0);
562f19e
             if (!txn) {
562f19e
                 Py_DECREF(list);
562f19e
                 Py_DECREF(gid);
562f19e
@@ -4602,6 +5099,24 @@ DBEnv_txn_checkpoint(DBEnvObject* self, 
562f19e
 }
562f19e
 
562f19e
 
562f19e
+#if (DBVER >= 42)
562f19e
+static PyObject*
562f19e
+DBEnv_get_tx_max(DBEnvObject* self)
562f19e
+{
562f19e
+    int err;
562f19e
+    u_int32_t max;
562f19e
+
562f19e
+    CHECK_ENV_NOT_CLOSED(self);
562f19e
+
562f19e
+    MYDB_BEGIN_ALLOW_THREADS;
562f19e
+    err = self->db_env->get_tx_max(self->db_env, &max;;
562f19e
+    MYDB_END_ALLOW_THREADS;
562f19e
+    RETURN_IF_ERR();
562f19e
+    return PyLong_FromUnsignedLong(max);
562f19e
+}
562f19e
+#endif
562f19e
+
562f19e
+
562f19e
 static PyObject*
562f19e
 DBEnv_set_tx_max(DBEnvObject* self, PyObject* args)
562f19e
 {
562f19e
@@ -4611,12 +5126,31 @@ DBEnv_set_tx_max(DBEnvObject* self, PyOb
562f19e
         return NULL;
562f19e
     CHECK_ENV_NOT_CLOSED(self);
562f19e
 
562f19e
+    MYDB_BEGIN_ALLOW_THREADS;
562f19e
     err = self->db_env->set_tx_max(self->db_env, max);
562f19e
+    MYDB_END_ALLOW_THREADS;
562f19e
     RETURN_IF_ERR();
562f19e
     RETURN_NONE();
562f19e
 }
562f19e
 
562f19e
 
562f19e
+#if (DBVER >= 42)
562f19e
+static PyObject*
562f19e
+DBEnv_get_tx_timestamp(DBEnvObject* self)
562f19e
+{
562f19e
+    int err;
562f19e
+    time_t timestamp;
562f19e
+
562f19e
+    CHECK_ENV_NOT_CLOSED(self);
562f19e
+
562f19e
+    MYDB_BEGIN_ALLOW_THREADS;
562f19e
+    err = self->db_env->get_tx_timestamp(self->db_env, &timestamp);
562f19e
+    MYDB_END_ALLOW_THREADS;
562f19e
+    RETURN_IF_ERR();
562f19e
+    return NUMBER_FromLong(timestamp);
562f19e
+}
562f19e
+#endif
562f19e
+
562f19e
 static PyObject*
562f19e
 DBEnv_set_tx_timestamp(DBEnvObject* self, PyObject* args)
562f19e
 {
562f19e
@@ -4628,7 +5162,9 @@ DBEnv_set_tx_timestamp(DBEnvObject* self
562f19e
         return NULL;
562f19e
     CHECK_ENV_NOT_CLOSED(self);
562f19e
     timestamp = (time_t)stamp;
562f19e
+    MYDB_BEGIN_ALLOW_THREADS;
562f19e
     err = self->db_env->set_tx_timestamp(self->db_env, &timestamp);
562f19e
+    MYDB_END_ALLOW_THREADS;
562f19e
     RETURN_IF_ERR();
562f19e
     RETURN_NONE();
562f19e
 }
562f19e
@@ -4722,6 +5258,26 @@ DBEnv_lock_put(DBEnvObject* self, PyObje
562f19e
 
562f19e
 #if (DBVER >= 44)
562f19e
 static PyObject*
562f19e
+DBEnv_fileid_reset(DBEnvObject* self, PyObject* args, PyObject* kwargs)
562f19e
+{
562f19e
+    int err;
562f19e
+    char *file;
562f19e
+    u_int32_t flags = 0;
562f19e
+    static char* kwnames[] = { "file", "flags", NULL};
562f19e
+
562f19e
+    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "z|i:fileid_reset", kwnames,
562f19e
+                                     &file, &flags))
562f19e
+        return NULL;
562f19e
+    CHECK_ENV_NOT_CLOSED(self);
562f19e
+
562f19e
+    MYDB_BEGIN_ALLOW_THREADS;
562f19e
+    err = self->db_env->fileid_reset(self->db_env, file, flags);
562f19e
+    MYDB_END_ALLOW_THREADS;
562f19e
+    RETURN_IF_ERR();
562f19e
+    RETURN_NONE();
562f19e
+}
562f19e
+
562f19e
+static PyObject*
562f19e
 DBEnv_lsn_reset(DBEnvObject* self, PyObject* args, PyObject* kwargs)
562f19e
 {
562f19e
     int err;
562f19e
@@ -4777,9 +5333,6 @@ DBEnv_log_stat(DBEnvObject* self, PyObje
562f19e
     MAKE_ENTRY(lg_size);
562f19e
     MAKE_ENTRY(record);
562f19e
 #endif
562f19e
-#if (DBVER < 41)
562f19e
-    MAKE_ENTRY(lg_max);
562f19e
-#endif
562f19e
     MAKE_ENTRY(w_mbytes);
562f19e
     MAKE_ENTRY(w_bytes);
562f19e
     MAKE_ENTRY(wc_mbytes);
562f19e
@@ -4832,13 +5385,8 @@ DBEnv_lock_stat(DBEnvObject* self, PyObj
562f19e
 
562f19e
 #define MAKE_ENTRY(name)  _addIntToDict(d, #name, sp->st_##name)
562f19e
 
562f19e
-#if (DBVER < 41)
562f19e
-    MAKE_ENTRY(lastid);
562f19e
-#endif
562f19e
-#if (DBVER >=41)
562f19e
     MAKE_ENTRY(id);
562f19e
     MAKE_ENTRY(cur_maxid);
562f19e
-#endif
562f19e
     MAKE_ENTRY(nmodes);
562f19e
     MAKE_ENTRY(maxlocks);
562f19e
     MAKE_ENTRY(maxlockers);
562f19e
@@ -4863,10 +5411,8 @@ DBEnv_lock_stat(DBEnvObject* self, PyObj
562f19e
     MAKE_ENTRY(lock_wait);
562f19e
 #endif
562f19e
     MAKE_ENTRY(ndeadlocks);
562f19e
-#if (DBVER >= 41)
562f19e
     MAKE_ENTRY(locktimeout);
562f19e
     MAKE_ENTRY(txntimeout);
562f19e
-#endif
562f19e
     MAKE_ENTRY(nlocktimeouts);
562f19e
     MAKE_ENTRY(ntxntimeouts);
562f19e
 #if (DBVER >= 46)
562f19e
@@ -4955,6 +5501,31 @@ DBEnv_log_archive(DBEnvObject* self, PyO
562f19e
 }
562f19e
 
562f19e
 
562f19e
+#if (DBVER >= 43)
562f19e
+static PyObject*
562f19e
+DBEnv_txn_stat_print(DBEnvObject* self, PyObject* args, PyObject *kwargs)
562f19e
+{
562f19e
+    int err;
562f19e
+    int flags=0;
562f19e
+    static char* kwnames[] = { "flags", NULL };
562f19e
+
562f19e
+    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|i:stat_print",
562f19e
+                kwnames, &flags))
562f19e
+    {
562f19e
+        return NULL;
562f19e
+    }
562f19e
+
562f19e
+    CHECK_ENV_NOT_CLOSED(self);
562f19e
+
562f19e
+    MYDB_BEGIN_ALLOW_THREADS;
562f19e
+    err = self->db_env->txn_stat_print(self->db_env, flags);
562f19e
+    MYDB_END_ALLOW_THREADS;
562f19e
+    RETURN_IF_ERR();
562f19e
+    RETURN_NONE();
562f19e
+}
562f19e
+#endif
562f19e
+
562f19e
+
562f19e
 static PyObject*
562f19e
 DBEnv_txn_stat(DBEnvObject* self, PyObject* args)
562f19e
 {
562f19e
@@ -5047,6 +5618,7 @@ DBEnv_set_private(DBEnvObject* self, PyO
562f19e
 }
562f19e
 
562f19e
 
562f19e
+#if (DBVER < 48)
562f19e
 static PyObject*
562f19e
 DBEnv_set_rpc_server(DBEnvObject* self, PyObject* args, PyObject* kwargs)
562f19e
 {
562f19e
@@ -5068,6 +5640,7 @@ DBEnv_set_rpc_server(DBEnvObject* self, 
562f19e
     RETURN_IF_ERR();
562f19e
     RETURN_NONE();
562f19e
 }
562f19e
+#endif
562f19e
 
562f19e
 static PyObject*
562f19e
 DBEnv_set_verbose(DBEnvObject* self, PyObject* args)
562f19e
@@ -5551,79 +6124,248 @@ DBEnv_rep_get_nsites(DBEnvObject* self)
562f19e
     err = self->db_env->rep_get_nsites(self->db_env, &nsites);
562f19e
     MYDB_END_ALLOW_THREADS;
562f19e
     RETURN_IF_ERR();
562f19e
-    return NUMBER_FromLong(nsites);
562f19e
+    return NUMBER_FromLong(nsites);
562f19e
+}
562f19e
+
562f19e
+static PyObject*
562f19e
+DBEnv_rep_set_priority(DBEnvObject* self, PyObject* args)
562f19e
+{
562f19e
+    int err;
562f19e
+    int priority;
562f19e
+
562f19e
+    if (!PyArg_ParseTuple(args, "i:rep_set_priority", &priority)) {
562f19e
+        return NULL;
562f19e
+    }
562f19e
+    CHECK_ENV_NOT_CLOSED(self);
562f19e
+    MYDB_BEGIN_ALLOW_THREADS;
562f19e
+    err = self->db_env->rep_set_priority(self->db_env, priority);
562f19e
+    MYDB_END_ALLOW_THREADS;
562f19e
+    RETURN_IF_ERR();
562f19e
+    RETURN_NONE();
562f19e
+}
562f19e
+
562f19e
+static PyObject*
562f19e
+DBEnv_rep_get_priority(DBEnvObject* self)
562f19e
+{
562f19e
+    int err;
562f19e
+#if (DBVER >= 47)
562f19e
+    u_int32_t priority;
562f19e
+#else
562f19e
+    int priority;
562f19e
+#endif
562f19e
+
562f19e
+    CHECK_ENV_NOT_CLOSED(self);
562f19e
+    MYDB_BEGIN_ALLOW_THREADS;
562f19e
+    err = self->db_env->rep_get_priority(self->db_env, &priority);
562f19e
+    MYDB_END_ALLOW_THREADS;
562f19e
+    RETURN_IF_ERR();
562f19e
+    return NUMBER_FromLong(priority);
562f19e
+}
562f19e
+
562f19e
+static PyObject*
562f19e
+DBEnv_rep_set_timeout(DBEnvObject* self, PyObject* args)
562f19e
+{
562f19e
+    int err;
562f19e
+    int which, timeout;
562f19e
+
562f19e
+    if (!PyArg_ParseTuple(args, "ii:rep_set_timeout", &which, &timeout)) {
562f19e
+        return NULL;
562f19e
+    }
562f19e
+    CHECK_ENV_NOT_CLOSED(self);
562f19e
+    MYDB_BEGIN_ALLOW_THREADS;
562f19e
+    err = self->db_env->rep_set_timeout(self->db_env, which, timeout);
562f19e
+    MYDB_END_ALLOW_THREADS;
562f19e
+    RETURN_IF_ERR();
562f19e
+    RETURN_NONE();
562f19e
+}
562f19e
+
562f19e
+static PyObject*
562f19e
+DBEnv_rep_get_timeout(DBEnvObject* self, PyObject* args)
562f19e
+{
562f19e
+    int err;
562f19e
+    int which;
562f19e
+    u_int32_t timeout;
562f19e
+
562f19e
+    if (!PyArg_ParseTuple(args, "i:rep_get_timeout", &which)) {
562f19e
+        return NULL;
562f19e
+    }
562f19e
+    CHECK_ENV_NOT_CLOSED(self);
562f19e
+    MYDB_BEGIN_ALLOW_THREADS;
562f19e
+    err = self->db_env->rep_get_timeout(self->db_env, which, &timeout);
562f19e
+    MYDB_END_ALLOW_THREADS;
562f19e
+    RETURN_IF_ERR();
562f19e
+    return NUMBER_FromLong(timeout);
562f19e
 }
562f19e
+#endif
562f19e
+
562f19e
 
562f19e
+#if (DBVER >= 47)
562f19e
 static PyObject*
562f19e
-DBEnv_rep_set_priority(DBEnvObject* self, PyObject* args)
562f19e
+DBEnv_rep_set_clockskew(DBEnvObject* self, PyObject* args)
562f19e
 {
562f19e
     int err;
562f19e
-    int priority;
562f19e
+    unsigned int fast, slow;
562f19e
 
562f19e
-    if (!PyArg_ParseTuple(args, "i:rep_set_priority", &priority)) {
562f19e
+#if (PY_VERSION_HEX >= 0x02040000)
562f19e
+    if (!PyArg_ParseTuple(args,"II:rep_set_clockskew", &fast, &slow))
562f19e
         return NULL;
562f19e
-    }
562f19e
+#else
562f19e
+    if (!PyArg_ParseTuple(args,"ii:rep_set_clockskew", &fast, &slow))
562f19e
+        return NULL;
562f19e
+#endif
562f19e
+
562f19e
     CHECK_ENV_NOT_CLOSED(self);
562f19e
+
562f19e
     MYDB_BEGIN_ALLOW_THREADS;
562f19e
-    err = self->db_env->rep_set_priority(self->db_env, priority);
562f19e
+    err = self->db_env->rep_set_clockskew(self->db_env, fast, slow);
562f19e
     MYDB_END_ALLOW_THREADS;
562f19e
     RETURN_IF_ERR();
562f19e
     RETURN_NONE();
562f19e
 }
562f19e
 
562f19e
 static PyObject*
562f19e
-DBEnv_rep_get_priority(DBEnvObject* self)
562f19e
+DBEnv_rep_get_clockskew(DBEnvObject* self)
562f19e
 {
562f19e
     int err;
562f19e
-#if (DBVER >= 47)
562f19e
-    u_int32_t priority;
562f19e
-#else
562f19e
-    int priority;
562f19e
-#endif
562f19e
+    unsigned int fast, slow;
562f19e
 
562f19e
     CHECK_ENV_NOT_CLOSED(self);
562f19e
     MYDB_BEGIN_ALLOW_THREADS;
562f19e
-    err = self->db_env->rep_get_priority(self->db_env, &priority);
562f19e
+    err = self->db_env->rep_get_clockskew(self->db_env, &fast, &slow);
562f19e
     MYDB_END_ALLOW_THREADS;
562f19e
     RETURN_IF_ERR();
562f19e
-    return NUMBER_FromLong(priority);
562f19e
+#if (PY_VERSION_HEX >= 0x02040000)
562f19e
+    return Py_BuildValue("(II)", fast, slow);
562f19e
+#else
562f19e
+    return Py_BuildValue("(ii)", fast, slow);
562f19e
+#endif
562f19e
 }
562f19e
+#endif
562f19e
 
562f19e
+#if (DBVER >= 43)
562f19e
 static PyObject*
562f19e
-DBEnv_rep_set_timeout(DBEnvObject* self, PyObject* args)
562f19e
+DBEnv_rep_stat_print(DBEnvObject* self, PyObject* args, PyObject *kwargs)
562f19e
 {
562f19e
     int err;
562f19e
-    int which, timeout;
562f19e
+    int flags=0;
562f19e
+    static char* kwnames[] = { "flags", NULL };
562f19e
 
562f19e
-    if (!PyArg_ParseTuple(args, "ii:rep_set_timeout", &which, &timeout)) {
562f19e
+    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|i:rep_stat_print",
562f19e
+                kwnames, &flags))
562f19e
+    {
562f19e
         return NULL;
562f19e
     }
562f19e
     CHECK_ENV_NOT_CLOSED(self);
562f19e
     MYDB_BEGIN_ALLOW_THREADS;
562f19e
-    err = self->db_env->rep_set_timeout(self->db_env, which, timeout);
562f19e
+    err = self->db_env->rep_stat_print(self->db_env, flags);
562f19e
     MYDB_END_ALLOW_THREADS;
562f19e
     RETURN_IF_ERR();
562f19e
     RETURN_NONE();
562f19e
 }
562f19e
+#endif
562f19e
 
562f19e
 static PyObject*
562f19e
-DBEnv_rep_get_timeout(DBEnvObject* self, PyObject* args)
562f19e
+DBEnv_rep_stat(DBEnvObject* self, PyObject* args, PyObject *kwargs)
562f19e
 {
562f19e
     int err;
562f19e
-    int which;
562f19e
-    u_int32_t timeout;
562f19e
+    int flags=0;
562f19e
+    DB_REP_STAT *statp;
562f19e
+    PyObject *stats;
562f19e
+    static char* kwnames[] = { "flags", NULL };
562f19e
 
562f19e
-    if (!PyArg_ParseTuple(args, "i:rep_get_timeout", &which)) {
562f19e
+    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|i:rep_stat",
562f19e
+                kwnames, &flags))
562f19e
+    {
562f19e
         return NULL;
562f19e
     }
562f19e
     CHECK_ENV_NOT_CLOSED(self);
562f19e
     MYDB_BEGIN_ALLOW_THREADS;
562f19e
-    err = self->db_env->rep_get_timeout(self->db_env, which, &timeout);
562f19e
+    err = self->db_env->rep_stat(self->db_env, &statp, flags);
562f19e
     MYDB_END_ALLOW_THREADS;
562f19e
     RETURN_IF_ERR();
562f19e
-    return NUMBER_FromLong(timeout);
562f19e
-}
562f19e
+
562f19e
+    stats=PyDict_New();
562f19e
+    if (stats == NULL) {
562f19e
+        free(statp);
562f19e
+        return NULL;
562f19e
+    }
562f19e
+
562f19e
+#define MAKE_ENTRY(name)  _addIntToDict(stats, #name, statp->st_##name)
562f19e
+#define MAKE_DB_LSN_ENTRY(name) _addDB_lsnToDict(stats , #name, statp->st_##name)
562f19e
+
562f19e
+#if (DBVER >= 44)
562f19e
+    MAKE_ENTRY(bulk_fills);
562f19e
+    MAKE_ENTRY(bulk_overflows);
562f19e
+    MAKE_ENTRY(bulk_records);
562f19e
+    MAKE_ENTRY(bulk_transfers);
562f19e
+    MAKE_ENTRY(client_rerequests);
562f19e
+    MAKE_ENTRY(client_svc_miss);
562f19e
+    MAKE_ENTRY(client_svc_req);
562f19e
+#endif
562f19e
+    MAKE_ENTRY(dupmasters);
562f19e
+#if (DBVER >= 43)
562f19e
+    MAKE_ENTRY(egen);
562f19e
+    MAKE_ENTRY(election_nvotes);
562f19e
+    MAKE_ENTRY(startup_complete);
562f19e
+    MAKE_ENTRY(pg_duplicated);
562f19e
+    MAKE_ENTRY(pg_records);
562f19e
+    MAKE_ENTRY(pg_requested);
562f19e
+    MAKE_ENTRY(next_pg);
562f19e
+    MAKE_ENTRY(waiting_pg);
562f19e
+#endif
562f19e
+    MAKE_ENTRY(election_cur_winner);
562f19e
+    MAKE_ENTRY(election_gen);
562f19e
+    MAKE_DB_LSN_ENTRY(election_lsn);
562f19e
+    MAKE_ENTRY(election_nsites);
562f19e
+    MAKE_ENTRY(election_priority);
562f19e
+#if (DBVER >= 44)
562f19e
+    MAKE_ENTRY(election_sec);
562f19e
+    MAKE_ENTRY(election_usec);
562f19e
+#endif
562f19e
+    MAKE_ENTRY(election_status);
562f19e
+    MAKE_ENTRY(election_tiebreaker);
562f19e
+    MAKE_ENTRY(election_votes);
562f19e
+    MAKE_ENTRY(elections);
562f19e
+    MAKE_ENTRY(elections_won);
562f19e
+    MAKE_ENTRY(env_id);
562f19e
+    MAKE_ENTRY(env_priority);
562f19e
+    MAKE_ENTRY(gen);
562f19e
+    MAKE_ENTRY(log_duplicated);
562f19e
+    MAKE_ENTRY(log_queued);
562f19e
+    MAKE_ENTRY(log_queued_max);
562f19e
+    MAKE_ENTRY(log_queued_total);
562f19e
+    MAKE_ENTRY(log_records);
562f19e
+    MAKE_ENTRY(log_requested);
562f19e
+    MAKE_ENTRY(master);
562f19e
+    MAKE_ENTRY(master_changes);
562f19e
+#if (DBVER >= 47)
562f19e
+    MAKE_ENTRY(max_lease_sec);
562f19e
+    MAKE_ENTRY(max_lease_usec);
562f19e
+    MAKE_DB_LSN_ENTRY(max_perm_lsn);
562f19e
+#endif
562f19e
+    MAKE_ENTRY(msgs_badgen);
562f19e
+    MAKE_ENTRY(msgs_processed);
562f19e
+    MAKE_ENTRY(msgs_recover);
562f19e
+    MAKE_ENTRY(msgs_send_failures);
562f19e
+    MAKE_ENTRY(msgs_sent);
562f19e
+    MAKE_ENTRY(newsites);
562f19e
+    MAKE_DB_LSN_ENTRY(next_lsn);
562f19e
+    MAKE_ENTRY(nsites);
562f19e
+    MAKE_ENTRY(nthrottles);
562f19e
+    MAKE_ENTRY(outdated);
562f19e
+#if (DBVER >= 46)
562f19e
+    MAKE_ENTRY(startsync_delayed);
562f19e
 #endif
562f19e
+    MAKE_ENTRY(status);
562f19e
+    MAKE_ENTRY(txns_applied);
562f19e
+    MAKE_DB_LSN_ENTRY(waiting_lsn);
562f19e
+
562f19e
+#undef MAKE_DB_LSN_ENTRY
562f19e
+#undef MAKE_ENTRY
562f19e
+
562f19e
+    free(statp);
562f19e
+    return stats;
562f19e
+}
562f19e
 
562f19e
 /* --------------------------------------------------------------------- */
562f19e
 /* REPLICATION METHODS: Replication Manager */
562f19e
@@ -5947,9 +6689,9 @@ DBTxn_prepare(DBTxnObject* self, PyObjec
562f19e
     if (!PyArg_ParseTuple(args, "s#:prepare", &gid, &gid_size))
562f19e
         return NULL;
562f19e
 
562f19e
-    if (gid_size != DB_XIDDATASIZE) {
562f19e
+    if (gid_size != DB_GID_SIZE) {
562f19e
         PyErr_SetString(PyExc_TypeError,
562f19e
-                        "gid must be DB_XIDDATASIZE bytes long");
562f19e
+                        "gid must be DB_GID_SIZE bytes long");
562f19e
         return NULL;
562f19e
     }
562f19e
 
562f19e
@@ -6064,6 +6806,76 @@ DBTxn_id(DBTxnObject* self)
562f19e
     return NUMBER_FromLong(id);
562f19e
 }
562f19e
 
562f19e
+
562f19e
+static PyObject*
562f19e
+DBTxn_set_timeout(DBTxnObject* self, PyObject* args, PyObject* kwargs)
562f19e
+{
562f19e
+    int err;
562f19e
+    u_int32_t flags=0;
562f19e
+    u_int32_t timeout = 0;
562f19e
+    static char* kwnames[] = { "timeout", "flags", NULL };
562f19e
+
562f19e
+    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii:set_timeout", kwnames,
562f19e
+		&timeout, &flags)) {
562f19e
+	return NULL;
562f19e
+    }
562f19e
+
562f19e
+    MYDB_BEGIN_ALLOW_THREADS;
562f19e
+    err = self->txn->set_timeout(self->txn, (db_timeout_t)timeout, flags);
562f19e
+    MYDB_END_ALLOW_THREADS;
562f19e
+
562f19e
+    RETURN_IF_ERR();
562f19e
+    RETURN_NONE();
562f19e
+}
562f19e
+
562f19e
+
562f19e
+#if (DBVER >= 44)
562f19e
+static PyObject*
562f19e
+DBTxn_set_name(DBTxnObject* self, PyObject* args)
562f19e
+{
562f19e
+    int err;
562f19e
+    const char *name;
562f19e
+
562f19e
+    if (!PyArg_ParseTuple(args, "s:set_name", &name))
562f19e
+        return NULL;
562f19e
+
562f19e
+    MYDB_BEGIN_ALLOW_THREADS;
562f19e
+    err = self->txn->set_name(self->txn, name);
562f19e
+    MYDB_END_ALLOW_THREADS;
562f19e
+
562f19e
+    RETURN_IF_ERR();
562f19e
+    RETURN_NONE();
562f19e
+}
562f19e
+#endif
562f19e
+
562f19e
+
562f19e
+#if (DBVER >= 44)
562f19e
+static PyObject*
562f19e
+DBTxn_get_name(DBTxnObject* self)
562f19e
+{
562f19e
+    int err;
562f19e
+    const char *name;
562f19e
+
562f19e
+    MYDB_BEGIN_ALLOW_THREADS;
562f19e
+    err = self->txn->get_name(self->txn, &name);
562f19e
+    MYDB_END_ALLOW_THREADS;
562f19e
+
562f19e
+    RETURN_IF_ERR();
562f19e
+#if (PY_VERSION_HEX < 0x03000000)
562f19e
+    if (!name) {
562f19e
+        return PyString_FromString("");
562f19e
+    }
562f19e
+    return PyString_FromString(name);
562f19e
+#else
562f19e
+    if (!name) {
562f19e
+        return PyUnicode_FromString("");
562f19e
+    }
562f19e
+    return PyUnicode_FromString(name);
562f19e
+#endif
562f19e
+}
562f19e
+#endif
562f19e
+
562f19e
+
562f19e
 #if (DBVER >= 43)
562f19e
 /* --------------------------------------------------------------------- */
562f19e
 /* DBSequence methods */
562f19e
@@ -6167,12 +6979,12 @@ DBSequence_get_key(DBSequenceObject* sel
562f19e
 }
562f19e
 
562f19e
 static PyObject*
562f19e
-DBSequence_init_value(DBSequenceObject* self, PyObject* args)
562f19e
+DBSequence_initial_value(DBSequenceObject* self, PyObject* args)
562f19e
 {
562f19e
     int err;
562f19e
     PY_LONG_LONG value;
562f19e
     db_seq_t value2;
562f19e
-    if (!PyArg_ParseTuple(args,"L:init_value", &value))
562f19e
+    if (!PyArg_ParseTuple(args,"L:initial_value", &value))
562f19e
         return NULL;
562f19e
     CHECK_SEQUENCE_NOT_CLOSED(self)
562f19e
 
562f19e
@@ -6350,6 +7162,29 @@ DBSequence_get_range(DBSequenceObject* s
562f19e
     return Py_BuildValue("(LL)", min, max);
562f19e
 }
562f19e
 
562f19e
+
562f19e
+static PyObject*
562f19e
+DBSequence_stat_print(DBSequenceObject* self, PyObject* args, PyObject *kwargs)
562f19e
+{
562f19e
+    int err;
562f19e
+    int flags=0;
562f19e
+    static char* kwnames[] = { "flags", NULL };
562f19e
+
562f19e
+    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|i:stat_print",
562f19e
+                kwnames, &flags))
562f19e
+    {
562f19e
+        return NULL;
562f19e
+    }
562f19e
+
562f19e
+    CHECK_SEQUENCE_NOT_CLOSED(self);
562f19e
+
562f19e
+    MYDB_BEGIN_ALLOW_THREADS;
562f19e
+    err = self->sequence->stat_print(self->sequence, flags);
562f19e
+    MYDB_END_ALLOW_THREADS;
562f19e
+    RETURN_IF_ERR();
562f19e
+    RETURN_NONE();
562f19e
+}
562f19e
+
562f19e
 static PyObject*
562f19e
 DBSequence_stat(DBSequenceObject* self, PyObject* args, PyObject* kwargs)
562f19e
 {
562f19e
@@ -6401,11 +7236,18 @@ static PyMethodDef DB_methods[] = {
562f19e
     {"append",          (PyCFunction)DB_append,         METH_VARARGS|METH_KEYWORDS},
562f19e
     {"associate",       (PyCFunction)DB_associate,      METH_VARARGS|METH_KEYWORDS},
562f19e
     {"close",           (PyCFunction)DB_close,          METH_VARARGS},
562f19e
+#if (DBVER >= 47)
562f19e
+    {"compact",         (PyCFunction)DB_compact,        METH_VARARGS|METH_KEYWORDS},
562f19e
+#endif
562f19e
     {"consume",         (PyCFunction)DB_consume,        METH_VARARGS|METH_KEYWORDS},
562f19e
     {"consume_wait",    (PyCFunction)DB_consume_wait,   METH_VARARGS|METH_KEYWORDS},
562f19e
     {"cursor",          (PyCFunction)DB_cursor,         METH_VARARGS|METH_KEYWORDS},
562f19e
     {"delete",          (PyCFunction)DB_delete,         METH_VARARGS|METH_KEYWORDS},
562f19e
     {"fd",              (PyCFunction)DB_fd,             METH_NOARGS},
562f19e
+#if (DBVER >= 46)
562f19e
+    {"exists",          (PyCFunction)DB_exists,
562f19e
+        METH_VARARGS|METH_KEYWORDS},
562f19e
+#endif
562f19e
     {"get",             (PyCFunction)DB_get,            METH_VARARGS|METH_KEYWORDS},
562f19e
     {"pget",            (PyCFunction)DB_pget,           METH_VARARGS|METH_KEYWORDS},
562f19e
     {"get_both",        (PyCFunction)DB_get_both,       METH_VARARGS|METH_KEYWORDS},
562f19e
@@ -6424,9 +7266,14 @@ static PyMethodDef DB_methods[] = {
562f19e
     {"set_bt_minkey",   (PyCFunction)DB_set_bt_minkey,  METH_VARARGS},
562f19e
     {"set_bt_compare",  (PyCFunction)DB_set_bt_compare, METH_O},
562f19e
     {"set_cachesize",   (PyCFunction)DB_set_cachesize,  METH_VARARGS},
562f19e
-#if (DBVER >= 41)
562f19e
+#if (DBVER >= 42)
562f19e
+    {"get_cachesize",   (PyCFunction)DB_get_cachesize,  METH_NOARGS},
562f19e
+#endif
562f19e
     {"set_encrypt",     (PyCFunction)DB_set_encrypt,    METH_VARARGS|METH_KEYWORDS},
562f19e
+#if (DBVER >= 42)
562f19e
+    {"get_encrypt_flags", (PyCFunction)DB_get_encrypt_flags, METH_NOARGS},
562f19e
 #endif
562f19e
+
562f19e
     {"set_flags",       (PyCFunction)DB_set_flags,      METH_VARARGS},
562f19e
     {"set_h_ffactor",   (PyCFunction)DB_set_h_ffactor,  METH_VARARGS},
562f19e
     {"set_h_nelem",     (PyCFunction)DB_set_h_nelem,    METH_VARARGS},
562f19e
@@ -6451,6 +7298,20 @@ static PyMethodDef DB_methods[] = {
562f19e
 };
562f19e
 
562f19e
 
562f19e
+/* We need this to support __contains__() */
562f19e
+static PySequenceMethods DB_sequence = {
562f19e
+    0, /* sq_length, mapping wins here */
562f19e
+    0, /* sq_concat */
562f19e
+    0, /* sq_repeat */
562f19e
+    0, /* sq_item */
562f19e
+    0, /* sq_slice */
562f19e
+    0, /* sq_ass_item */
562f19e
+    0, /* sq_ass_slice */
562f19e
+    (objobjproc)DB_contains, /* sq_contains */
562f19e
+    0, /* sq_inplace_concat */
562f19e
+    0, /* sq_inplace_repeat */
562f19e
+};
562f19e
+
562f19e
 static PyMappingMethods DB_mapping = {
562f19e
         DB_length,                   /*mp_length*/
562f19e
         (binaryfunc)DB_subscript,    /*mp_subscript*/
562f19e
@@ -6481,8 +7342,17 @@ static PyMethodDef DBCursor_methods[] = 
562f19e
     {"consume",         (PyCFunction)DBC_consume,       METH_VARARGS|METH_KEYWORDS},
562f19e
     {"next_dup",        (PyCFunction)DBC_next_dup,      METH_VARARGS|METH_KEYWORDS},
562f19e
     {"next_nodup",      (PyCFunction)DBC_next_nodup,    METH_VARARGS|METH_KEYWORDS},
562f19e
+#if (DBVER >= 46)
562f19e
+    {"prev_dup",        (PyCFunction)DBC_prev_dup,
562f19e
+        METH_VARARGS|METH_KEYWORDS},
562f19e
+#endif
562f19e
     {"prev_nodup",      (PyCFunction)DBC_prev_nodup,    METH_VARARGS|METH_KEYWORDS},
562f19e
     {"join_item",       (PyCFunction)DBC_join_item,     METH_VARARGS},
562f19e
+#if (DBVER >= 46)
562f19e
+    {"set_priority",    (PyCFunction)DBC_set_priority,
562f19e
+        METH_VARARGS|METH_KEYWORDS},
562f19e
+    {"get_priority",    (PyCFunction)DBC_get_priority, METH_NOARGS},
562f19e
+#endif
562f19e
     {NULL,      NULL}       /* sentinel */
562f19e
 };
562f19e
 
562f19e
@@ -6491,57 +7361,94 @@ static PyMethodDef DBEnv_methods[] = {
562f19e
     {"close",           (PyCFunction)DBEnv_close,            METH_VARARGS},
562f19e
     {"open",            (PyCFunction)DBEnv_open,             METH_VARARGS},
562f19e
     {"remove",          (PyCFunction)DBEnv_remove,           METH_VARARGS},
562f19e
-#if (DBVER >= 41)
562f19e
     {"dbremove",        (PyCFunction)DBEnv_dbremove,         METH_VARARGS|METH_KEYWORDS},
562f19e
     {"dbrename",        (PyCFunction)DBEnv_dbrename,         METH_VARARGS|METH_KEYWORDS},
562f19e
     {"set_encrypt",     (PyCFunction)DBEnv_set_encrypt,      METH_VARARGS|METH_KEYWORDS},
562f19e
+#if (DBVER >= 42)
562f19e
+    {"get_encrypt_flags", (PyCFunction)DBEnv_get_encrypt_flags, METH_NOARGS},
562f19e
+    {"get_timeout",     (PyCFunction)DBEnv_get_timeout,
562f19e
+        METH_VARARGS|METH_KEYWORDS},
562f19e
+#endif
562f19e
+    {"set_timeout",     (PyCFunction)DBEnv_set_timeout,     METH_VARARGS|METH_KEYWORDS},
562f19e
+    {"set_shm_key",     (PyCFunction)DBEnv_set_shm_key,     METH_VARARGS},
562f19e
+#if (DBVER >= 42)
562f19e
+    {"get_shm_key",     (PyCFunction)DBEnv_get_shm_key,     METH_NOARGS},
562f19e
+#endif
562f19e
+    {"set_cachesize",   (PyCFunction)DBEnv_set_cachesize,   METH_VARARGS},
562f19e
+#if (DBVER >= 42)
562f19e
+    {"get_cachesize",   (PyCFunction)DBEnv_get_cachesize,   METH_NOARGS},
562f19e
+#endif
562f19e
+#if (DBVER >= 44)
562f19e
+    {"mutex_set_max",   (PyCFunction)DBEnv_mutex_set_max,   METH_VARARGS},
562f19e
+    {"mutex_get_max",   (PyCFunction)DBEnv_mutex_get_max,   METH_NOARGS},
562f19e
+    {"mutex_set_align", (PyCFunction)DBEnv_mutex_set_align, METH_VARARGS},
562f19e
+    {"mutex_get_align", (PyCFunction)DBEnv_mutex_get_align, METH_NOARGS},
562f19e
+    {"mutex_set_increment", (PyCFunction)DBEnv_mutex_set_increment,
562f19e
+        METH_VARARGS},
562f19e
+    {"mutex_get_increment", (PyCFunction)DBEnv_mutex_get_increment,
562f19e
+        METH_NOARGS},
562f19e
+    {"mutex_set_tas_spins", (PyCFunction)DBEnv_mutex_set_tas_spins,
562f19e
+        METH_VARARGS},
562f19e
+    {"mutex_get_tas_spins", (PyCFunction)DBEnv_mutex_get_tas_spins,
562f19e
+        METH_NOARGS},
562f19e
+#endif
562f19e
+    {"set_data_dir",    (PyCFunction)DBEnv_set_data_dir,    METH_VARARGS},
562f19e
+#if (DBVER >= 42)
562f19e
+    {"get_data_dirs",   (PyCFunction)DBEnv_get_data_dirs,   METH_NOARGS},
562f19e
 #endif
562f19e
-    {"set_timeout",     (PyCFunction)DBEnv_set_timeout,      METH_VARARGS|METH_KEYWORDS},
562f19e
-    {"set_shm_key",     (PyCFunction)DBEnv_set_shm_key,      METH_VARARGS},
562f19e
-    {"set_cachesize",   (PyCFunction)DBEnv_set_cachesize,    METH_VARARGS},
562f19e
-    {"set_data_dir",    (PyCFunction)DBEnv_set_data_dir,     METH_VARARGS},
562f19e
-    {"set_flags",       (PyCFunction)DBEnv_set_flags,        METH_VARARGS},
562f19e
+    {"set_flags",       (PyCFunction)DBEnv_set_flags,       METH_VARARGS},
562f19e
 #if (DBVER >= 47)
562f19e
-    {"log_set_config",  (PyCFunction)DBEnv_log_set_config,   METH_VARARGS},
562f19e
+    {"log_set_config",  (PyCFunction)DBEnv_log_set_config,  METH_VARARGS},
562f19e
 #endif
562f19e
-    {"set_lg_bsize",    (PyCFunction)DBEnv_set_lg_bsize,     METH_VARARGS},
562f19e
-    {"set_lg_dir",      (PyCFunction)DBEnv_set_lg_dir,       METH_VARARGS},
562f19e
-    {"set_lg_max",      (PyCFunction)DBEnv_set_lg_max,       METH_VARARGS},
562f19e
+    {"set_lg_bsize",    (PyCFunction)DBEnv_set_lg_bsize,    METH_VARARGS},
562f19e
+    {"set_lg_dir",      (PyCFunction)DBEnv_set_lg_dir,      METH_VARARGS},
562f19e
+    {"set_lg_max",      (PyCFunction)DBEnv_set_lg_max,      METH_VARARGS},
562f19e
 #if (DBVER >= 42)
562f19e
-    {"get_lg_max",      (PyCFunction)DBEnv_get_lg_max,       METH_NOARGS},
562f19e
+    {"get_lg_max",      (PyCFunction)DBEnv_get_lg_max,      METH_NOARGS},
562f19e
 #endif
562f19e
     {"set_lg_regionmax",(PyCFunction)DBEnv_set_lg_regionmax, METH_VARARGS},
562f19e
-    {"set_lk_detect",   (PyCFunction)DBEnv_set_lk_detect,    METH_VARARGS},
562f19e
+    {"set_lk_detect",   (PyCFunction)DBEnv_set_lk_detect,   METH_VARARGS},
562f19e
 #if (DBVER < 45)
562f19e
-    {"set_lk_max",      (PyCFunction)DBEnv_set_lk_max,       METH_VARARGS},
562f19e
+    {"set_lk_max",      (PyCFunction)DBEnv_set_lk_max,      METH_VARARGS},
562f19e
 #endif
562f19e
     {"set_lk_max_locks", (PyCFunction)DBEnv_set_lk_max_locks, METH_VARARGS},
562f19e
     {"set_lk_max_lockers", (PyCFunction)DBEnv_set_lk_max_lockers, METH_VARARGS},
562f19e
     {"set_lk_max_objects", (PyCFunction)DBEnv_set_lk_max_objects, METH_VARARGS},
562f19e
-    {"set_mp_mmapsize", (PyCFunction)DBEnv_set_mp_mmapsize,  METH_VARARGS},
562f19e
-    {"set_tmp_dir",     (PyCFunction)DBEnv_set_tmp_dir,      METH_VARARGS},
562f19e
-    {"txn_begin",       (PyCFunction)DBEnv_txn_begin,        METH_VARARGS|METH_KEYWORDS},
562f19e
-    {"txn_checkpoint",  (PyCFunction)DBEnv_txn_checkpoint,   METH_VARARGS},
562f19e
-    {"txn_stat",        (PyCFunction)DBEnv_txn_stat,         METH_VARARGS},
562f19e
-    {"set_tx_max",      (PyCFunction)DBEnv_set_tx_max,       METH_VARARGS},
562f19e
+    {"set_mp_mmapsize", (PyCFunction)DBEnv_set_mp_mmapsize, METH_VARARGS},
562f19e
+    {"set_tmp_dir",     (PyCFunction)DBEnv_set_tmp_dir,     METH_VARARGS},
562f19e
+    {"txn_begin",       (PyCFunction)DBEnv_txn_begin,       METH_VARARGS|METH_KEYWORDS},
562f19e
+    {"txn_checkpoint",  (PyCFunction)DBEnv_txn_checkpoint,  METH_VARARGS},
562f19e
+    {"txn_stat",        (PyCFunction)DBEnv_txn_stat,        METH_VARARGS},
562f19e
+#if (DBVER >= 43)
562f19e
+    {"txn_stat_print",  (PyCFunction)DBEnv_txn_stat_print,
562f19e
+        METH_VARARGS|METH_KEYWORDS},
562f19e
+#endif
562f19e
+#if (DBVER >= 42)
562f19e
+    {"get_tx_max",      (PyCFunction)DBEnv_get_tx_max,      METH_NOARGS},
562f19e
+    {"get_tx_timestamp", (PyCFunction)DBEnv_get_tx_timestamp, METH_NOARGS},
562f19e
+#endif
562f19e
+    {"set_tx_max",      (PyCFunction)DBEnv_set_tx_max,      METH_VARARGS},
562f19e
     {"set_tx_timestamp", (PyCFunction)DBEnv_set_tx_timestamp, METH_VARARGS},
562f19e
-    {"lock_detect",     (PyCFunction)DBEnv_lock_detect,      METH_VARARGS},
562f19e
-    {"lock_get",        (PyCFunction)DBEnv_lock_get,         METH_VARARGS},
562f19e
-    {"lock_id",         (PyCFunction)DBEnv_lock_id,          METH_NOARGS},
562f19e
-    {"lock_id_free",    (PyCFunction)DBEnv_lock_id_free,     METH_VARARGS},
562f19e
-    {"lock_put",        (PyCFunction)DBEnv_lock_put,         METH_VARARGS},
562f19e
-    {"lock_stat",       (PyCFunction)DBEnv_lock_stat,        METH_VARARGS},
562f19e
-    {"log_archive",     (PyCFunction)DBEnv_log_archive,      METH_VARARGS},
562f19e
-    {"log_flush",       (PyCFunction)DBEnv_log_flush,        METH_NOARGS},
562f19e
-    {"log_stat",        (PyCFunction)DBEnv_log_stat,         METH_VARARGS},
562f19e
+    {"lock_detect",     (PyCFunction)DBEnv_lock_detect,     METH_VARARGS},
562f19e
+    {"lock_get",        (PyCFunction)DBEnv_lock_get,        METH_VARARGS},
562f19e
+    {"lock_id",         (PyCFunction)DBEnv_lock_id,         METH_NOARGS},
562f19e
+    {"lock_id_free",    (PyCFunction)DBEnv_lock_id_free,    METH_VARARGS},
562f19e
+    {"lock_put",        (PyCFunction)DBEnv_lock_put,        METH_VARARGS},
562f19e
+    {"lock_stat",       (PyCFunction)DBEnv_lock_stat,       METH_VARARGS},
562f19e
+    {"log_archive",     (PyCFunction)DBEnv_log_archive,     METH_VARARGS},
562f19e
+    {"log_flush",       (PyCFunction)DBEnv_log_flush,       METH_NOARGS},
562f19e
+    {"log_stat",        (PyCFunction)DBEnv_log_stat,        METH_VARARGS},
562f19e
 #if (DBVER >= 44)
562f19e
-    {"lsn_reset",       (PyCFunction)DBEnv_lsn_reset,        METH_VARARGS|METH_KEYWORDS},
562f19e
+    {"fileid_reset",    (PyCFunction)DBEnv_fileid_reset,    METH_VARARGS|METH_KEYWORDS},
562f19e
+    {"lsn_reset",       (PyCFunction)DBEnv_lsn_reset,       METH_VARARGS|METH_KEYWORDS},
562f19e
 #endif
562f19e
     {"set_get_returns_none",(PyCFunction)DBEnv_set_get_returns_none, METH_VARARGS},
562f19e
-    {"txn_recover",     (PyCFunction)DBEnv_txn_recover,       METH_NOARGS},
562f19e
+    {"txn_recover",     (PyCFunction)DBEnv_txn_recover,     METH_NOARGS},
562f19e
+#if (DBVER < 48)
562f19e
     {"set_rpc_server",  (PyCFunction)DBEnv_set_rpc_server,
562f19e
         METH_VARARGS||METH_KEYWORDS},
562f19e
-    {"set_verbose",     (PyCFunction)DBEnv_set_verbose,       METH_VARARGS},
562f19e
+#endif
562f19e
+    {"set_verbose",     (PyCFunction)DBEnv_set_verbose,     METH_VARARGS},
562f19e
 #if (DBVER >= 42)
562f19e
     {"get_verbose",     (PyCFunction)DBEnv_get_verbose,       METH_VARARGS},
562f19e
 #endif
562f19e
@@ -6579,6 +7486,17 @@ static PyMethodDef DBEnv_methods[] = {
562f19e
     {"rep_set_timeout", (PyCFunction)DBEnv_rep_set_timeout, METH_VARARGS},
562f19e
     {"rep_get_timeout", (PyCFunction)DBEnv_rep_get_timeout, METH_VARARGS},
562f19e
 #endif
562f19e
+#if (DBVER >= 47)
562f19e
+    {"rep_set_clockskew", (PyCFunction)DBEnv_rep_set_clockskew, METH_VARARGS},
562f19e
+    {"rep_get_clockskew", (PyCFunction)DBEnv_rep_get_clockskew, METH_VARARGS},
562f19e
+#endif
562f19e
+    {"rep_stat", (PyCFunction)DBEnv_rep_stat,
562f19e
+        METH_VARARGS|METH_KEYWORDS},
562f19e
+#if (DBVER >= 43)
562f19e
+    {"rep_stat_print", (PyCFunction)DBEnv_rep_stat_print,
562f19e
+        METH_VARARGS|METH_KEYWORDS},
562f19e
+#endif
562f19e
+
562f19e
 #if (DBVER >= 45)
562f19e
     {"repmgr_start", (PyCFunction)DBEnv_repmgr_start,
562f19e
         METH_VARARGS|METH_KEYWORDS},
562f19e
@@ -6609,6 +7527,12 @@ static PyMethodDef DBTxn_methods[] = {
562f19e
     {"discard",         (PyCFunction)DBTxn_discard,     METH_NOARGS},
562f19e
     {"abort",           (PyCFunction)DBTxn_abort,       METH_NOARGS},
562f19e
     {"id",              (PyCFunction)DBTxn_id,          METH_NOARGS},
562f19e
+    {"set_timeout",     (PyCFunction)DBTxn_set_timeout,
562f19e
+        METH_VARARGS|METH_KEYWORDS},
562f19e
+#if (DBVER >= 44)
562f19e
+    {"set_name",        (PyCFunction)DBTxn_set_name, METH_VARARGS},
562f19e
+    {"get_name",        (PyCFunction)DBTxn_get_name, METH_NOARGS},
562f19e
+#endif
562f19e
     {NULL,      NULL}       /* sentinel */
562f19e
 };
562f19e
 
562f19e
@@ -6619,7 +7543,7 @@ static PyMethodDef DBSequence_methods[] 
562f19e
     {"get",             (PyCFunction)DBSequence_get,            METH_VARARGS|METH_KEYWORDS},
562f19e
     {"get_dbp",         (PyCFunction)DBSequence_get_dbp,        METH_NOARGS},
562f19e
     {"get_key",         (PyCFunction)DBSequence_get_key,        METH_NOARGS},
562f19e
-    {"init_value",      (PyCFunction)DBSequence_init_value,     METH_VARARGS},
562f19e
+    {"initial_value",   (PyCFunction)DBSequence_initial_value,  METH_VARARGS},
562f19e
     {"open",            (PyCFunction)DBSequence_open,           METH_VARARGS|METH_KEYWORDS},
562f19e
     {"remove",          (PyCFunction)DBSequence_remove,         METH_VARARGS|METH_KEYWORDS},
562f19e
     {"set_cachesize",   (PyCFunction)DBSequence_set_cachesize,  METH_VARARGS},
562f19e
@@ -6629,6 +7553,8 @@ static PyMethodDef DBSequence_methods[] 
562f19e
     {"set_range",       (PyCFunction)DBSequence_set_range,      METH_VARARGS},
562f19e
     {"get_range",       (PyCFunction)DBSequence_get_range,      METH_NOARGS},
562f19e
     {"stat",            (PyCFunction)DBSequence_stat,           METH_VARARGS|METH_KEYWORDS},
562f19e
+    {"stat_print",      (PyCFunction)DBSequence_stat_print,
562f19e
+        METH_VARARGS|METH_KEYWORDS},
562f19e
     {NULL,      NULL}       /* sentinel */
562f19e
 };
562f19e
 #endif
562f19e
@@ -6677,7 +7603,7 @@ statichere PyTypeObject DB_Type = {
562f19e
     0,          /*tp_compare*/
562f19e
     0,          /*tp_repr*/
562f19e
     0,          /*tp_as_number*/
562f19e
-    0,          /*tp_as_sequence*/
562f19e
+    &DB_sequence,/*tp_as_sequence*/
562f19e
     &DB_mapping,/*tp_as_mapping*/
562f19e
     0,          /*tp_hash*/
562f19e
     0,			/* tp_call */
562f19e
@@ -7029,10 +7955,21 @@ PyMODINIT_FUNC  PyInit__bsddb(void)    /
562f19e
 {
562f19e
     PyObject* m;
562f19e
     PyObject* d;
562f19e
-    PyObject* pybsddb_version_s = PyBytes_FromString( PY_BSDDB_VERSION );
562f19e
-    PyObject* db_version_s = PyBytes_FromString( DB_VERSION_STRING );
562f19e
-    PyObject* cvsid_s = PyBytes_FromString( rcs_id );
562f19e
     PyObject* py_api;
562f19e
+    PyObject* pybsddb_version_s;
562f19e
+    PyObject* db_version_s;
562f19e
+    PyObject* cvsid_s;
562f19e
+
562f19e
+#if (PY_VERSION_HEX < 0x03000000)
562f19e
+    pybsddb_version_s = PyString_FromString(PY_BSDDB_VERSION);
562f19e
+    db_version_s = PyString_FromString(DB_VERSION_STRING);
562f19e
+    cvsid_s = PyString_FromString(rcs_id);
562f19e
+#else
562f19e
+    /* This data should be ascii, so UTF-8 conversion is fine */
562f19e
+    pybsddb_version_s = PyUnicode_FromString(PY_BSDDB_VERSION);
562f19e
+    db_version_s = PyUnicode_FromString(DB_VERSION_STRING);
562f19e
+    cvsid_s = PyUnicode_FromString(rcs_id);
562f19e
+#endif
562f19e
 
562f19e
     /* Initialize object types */
562f19e
     if ((PyType_Ready(&DB_Type) < 0)
562f19e
@@ -7089,6 +8026,7 @@ PyMODINIT_FUNC  PyInit__bsddb(void)    /
562f19e
     ADD_INT(d, DB_MAX_PAGES);
562f19e
     ADD_INT(d, DB_MAX_RECORDS);
562f19e
 
562f19e
+#if (DBVER < 48)
562f19e
 #if (DBVER >= 42)
562f19e
     ADD_INT(d, DB_RPCCLIENT);
562f19e
 #else
562f19e
@@ -7096,7 +8034,11 @@ PyMODINIT_FUNC  PyInit__bsddb(void)    /
562f19e
     /* allow apps to be written using DB_RPCCLIENT on older Berkeley DB */
562f19e
     _addIntToDict(d, "DB_RPCCLIENT", DB_CLIENT);
562f19e
 #endif
562f19e
+#endif
562f19e
+
562f19e
+#if (DBVER < 48)
562f19e
     ADD_INT(d, DB_XA_CREATE);
562f19e
+#endif
562f19e
 
562f19e
     ADD_INT(d, DB_CREATE);
562f19e
     ADD_INT(d, DB_NOMMAP);
562f19e
@@ -7113,7 +8055,13 @@ PyMODINIT_FUNC  PyInit__bsddb(void)    /
562f19e
     ADD_INT(d, DB_INIT_TXN);
562f19e
     ADD_INT(d, DB_JOINENV);
562f19e
 
562f19e
+#if (DBVER >= 48)
562f19e
+    ADD_INT(d, DB_GID_SIZE);
562f19e
+#else
562f19e
     ADD_INT(d, DB_XIDDATASIZE);
562f19e
+    /* Allow new code to work in old BDB releases */
562f19e
+    _addIntToDict(d, "DB_GID_SIZE", DB_XIDDATASIZE);
562f19e
+#endif
562f19e
 
562f19e
     ADD_INT(d, DB_RECOVER);
562f19e
     ADD_INT(d, DB_RECOVER_FATAL);
562f19e
@@ -7128,6 +8076,10 @@ PyMODINIT_FUNC  PyInit__bsddb(void)    /
562f19e
     ADD_INT(d, DB_TXN_SYNC);
562f19e
     ADD_INT(d, DB_TXN_NOWAIT);
562f19e
 
562f19e
+#if (DBVER >= 46)
562f19e
+    ADD_INT(d, DB_TXN_WAIT);
562f19e
+#endif
562f19e
+
562f19e
     ADD_INT(d, DB_EXCL);
562f19e
     ADD_INT(d, DB_FCNTL_LOCKING);
562f19e
     ADD_INT(d, DB_ODDFILESIZE);
562f19e
@@ -7233,12 +8185,6 @@ PyMODINIT_FUNC  PyInit__bsddb(void)    /
562f19e
     ADD_INT(d, DB_CACHED_COUNTS);
562f19e
 #endif
562f19e
 
562f19e
-#if (DBVER >= 41)
562f19e
-    _addIntToDict(d, "DB_CHECKPOINT", 0);
562f19e
-#else
562f19e
-    ADD_INT(d, DB_CHECKPOINT);
562f19e
-    ADD_INT(d, DB_CURLSN);
562f19e
-#endif
562f19e
 #if (DBVER <= 41)
562f19e
     ADD_INT(d, DB_COMMIT);
562f19e
 #endif
562f19e
@@ -7249,6 +8195,7 @@ PyMODINIT_FUNC  PyInit__bsddb(void)    /
562f19e
     ADD_INT(d, DB_FIRST);
562f19e
     ADD_INT(d, DB_FLUSH);
562f19e
     ADD_INT(d, DB_GET_BOTH);
562f19e
+    ADD_INT(d, DB_GET_BOTH_RANGE);
562f19e
     ADD_INT(d, DB_GET_RECNO);
562f19e
     ADD_INT(d, DB_JOIN_ITEM);
562f19e
     ADD_INT(d, DB_KEYFIRST);
562f19e
@@ -7263,6 +8210,9 @@ PyMODINIT_FUNC  PyInit__bsddb(void)    /
562f19e
     ADD_INT(d, DB_POSITION);
562f19e
     ADD_INT(d, DB_PREV);
562f19e
     ADD_INT(d, DB_PREV_NODUP);
562f19e
+#if (DBVER >= 46)
562f19e
+    ADD_INT(d, DB_PREV_DUP);
562f19e
+#endif
562f19e
 #if (DBVER < 45)
562f19e
     ADD_INT(d, DB_RECORDCOUNT);
562f19e
 #endif
562f19e
@@ -7278,17 +8228,18 @@ PyMODINIT_FUNC  PyInit__bsddb(void)    /
562f19e
     ADD_INT(d, DB_MULTIPLE_KEY);
562f19e
 
562f19e
 #if (DBVER >= 44)
562f19e
+    ADD_INT(d, DB_IMMUTABLE_KEY);
562f19e
     ADD_INT(d, DB_READ_UNCOMMITTED);    /* replaces DB_DIRTY_READ in 4.4 */
562f19e
     ADD_INT(d, DB_READ_COMMITTED);
562f19e
 #endif
562f19e
 
562f19e
+#if (DBVER >= 44)
562f19e
+    ADD_INT(d, DB_FREELIST_ONLY);
562f19e
+    ADD_INT(d, DB_FREE_SPACE);
562f19e
+#endif
562f19e
+
562f19e
     ADD_INT(d, DB_DONOTINDEX);
562f19e
 
562f19e
-#if (DBVER >= 41)
562f19e
-    _addIntToDict(d, "DB_INCOMPLETE", 0);
562f19e
-#else
562f19e
-    ADD_INT(d, DB_INCOMPLETE);
562f19e
-#endif
562f19e
     ADD_INT(d, DB_KEYEMPTY);
562f19e
     ADD_INT(d, DB_KEYEXIST);
562f19e
     ADD_INT(d, DB_LOCK_DEADLOCK);
562f19e
@@ -7309,14 +8260,15 @@ PyMODINIT_FUNC  PyInit__bsddb(void)    /
562f19e
     ADD_INT(d, DB_PANIC_ENVIRONMENT);
562f19e
     ADD_INT(d, DB_NOPANIC);
562f19e
 
562f19e
-#if (DBVER >= 41)
562f19e
     ADD_INT(d, DB_OVERWRITE);
562f19e
-#endif
562f19e
 
562f19e
-#ifdef DB_REGISTER
562f19e
+#if (DBVER >= 44)
562f19e
     ADD_INT(d, DB_REGISTER);
562f19e
 #endif
562f19e
 
562f19e
+    ADD_INT(d, DB_EID_INVALID);
562f19e
+    ADD_INT(d, DB_EID_BROADCAST);
562f19e
+
562f19e
 #if (DBVER >= 42)
562f19e
     ADD_INT(d, DB_TIME_NOTGRANTED);
562f19e
     ADD_INT(d, DB_TXN_NOT_DURABLE);
562f19e
@@ -7389,6 +8341,32 @@ PyMODINIT_FUNC  PyInit__bsddb(void)    /
562f19e
 
562f19e
     ADD_INT(d, DB_REP_MASTER);
562f19e
     ADD_INT(d, DB_REP_CLIENT);
562f19e
+
562f19e
+    ADD_INT(d, DB_REP_PERMANENT);
562f19e
+
562f19e
+#if (DBVER >= 44)
562f19e
+    ADD_INT(d, DB_REP_CONF_NOAUTOINIT);
562f19e
+    ADD_INT(d, DB_REP_CONF_DELAYCLIENT);
562f19e
+    ADD_INT(d, DB_REP_CONF_BULK);
562f19e
+    ADD_INT(d, DB_REP_CONF_NOWAIT);
562f19e
+    ADD_INT(d, DB_REP_ANYWHERE);
562f19e
+    ADD_INT(d, DB_REP_REREQUEST);
562f19e
+#endif
562f19e
+
562f19e
+#if (DBVER >= 42)
562f19e
+    ADD_INT(d, DB_REP_NOBUFFER);
562f19e
+#endif
562f19e
+
562f19e
+#if (DBVER >= 46)
562f19e
+    ADD_INT(d, DB_REP_LEASE_EXPIRED);
562f19e
+    ADD_INT(d, DB_IGNORE_LEASE);
562f19e
+#endif
562f19e
+
562f19e
+#if (DBVER >= 47)
562f19e
+    ADD_INT(d, DB_REP_CONF_LEASE);
562f19e
+    ADD_INT(d, DB_REPMGR_CONF_2SITE_STRICT);
562f19e
+#endif
562f19e
+
562f19e
 #if (DBVER >= 45)
562f19e
     ADD_INT(d, DB_REP_ELECTION);
562f19e
 
562f19e
@@ -7400,6 +8378,11 @@ PyMODINIT_FUNC  PyInit__bsddb(void)    /
562f19e
 #if (DBVER >= 46)
562f19e
     ADD_INT(d, DB_REP_CHECKPOINT_DELAY);
562f19e
     ADD_INT(d, DB_REP_FULL_ELECTION_TIMEOUT);
562f19e
+    ADD_INT(d, DB_REP_LEASE_TIMEOUT);
562f19e
+#endif
562f19e
+#if (DBVER >= 47)
562f19e
+    ADD_INT(d, DB_REP_HEARTBEAT_MONITOR);
562f19e
+    ADD_INT(d, DB_REP_HEARTBEAT_SEND);
562f19e
 #endif
562f19e
 
562f19e
 #if (DBVER >= 45)
562f19e
@@ -7412,7 +8395,6 @@ PyMODINIT_FUNC  PyInit__bsddb(void)    /
562f19e
     ADD_INT(d, DB_REPMGR_ACKS_QUORUM);
562f19e
     ADD_INT(d, DB_REPMGR_CONNECTED);
562f19e
     ADD_INT(d, DB_REPMGR_DISCONNECTED);
562f19e
-    ADD_INT(d, DB_STAT_CLEAR);
562f19e
     ADD_INT(d, DB_STAT_ALL);
562f19e
 #endif
562f19e
 
562f19e
@@ -7428,12 +8410,16 @@ PyMODINIT_FUNC  PyInit__bsddb(void)    /
562f19e
     ADD_INT(d, DB_DSYNC_LOG);
562f19e
 #endif
562f19e
 
562f19e
-#if (DBVER >= 41)
562f19e
     ADD_INT(d, DB_ENCRYPT_AES);
562f19e
     ADD_INT(d, DB_AUTO_COMMIT);
562f19e
-#else
562f19e
-    /* allow Berkeley DB 4.1 aware apps to run on older versions */
562f19e
-    _addIntToDict(d, "DB_AUTO_COMMIT", 0);
562f19e
+    ADD_INT(d, DB_PRIORITY_VERY_LOW);
562f19e
+    ADD_INT(d, DB_PRIORITY_LOW);
562f19e
+    ADD_INT(d, DB_PRIORITY_DEFAULT);
562f19e
+    ADD_INT(d, DB_PRIORITY_HIGH);
562f19e
+    ADD_INT(d, DB_PRIORITY_VERY_HIGH);
562f19e
+
562f19e
+#if (DBVER >= 46)
562f19e
+    ADD_INT(d, DB_PRIORITY_UNCHANGED);
562f19e
 #endif
562f19e
 
562f19e
     ADD_INT(d, EINVAL);
562f19e
@@ -7497,10 +8483,6 @@ PyMODINIT_FUNC  PyInit__bsddb(void)    /
562f19e
     }
562f19e
 #endif
562f19e
 
562f19e
-
562f19e
-#if !INCOMPLETE_IS_WARNING
562f19e
-    MAKE_EX(DBIncompleteError);
562f19e
-#endif
562f19e
     MAKE_EX(DBCursorClosedError);
562f19e
     MAKE_EX(DBKeyEmptyError);
562f19e
     MAKE_EX(DBKeyExistError);
562f19e
@@ -7528,9 +8510,16 @@ PyMODINIT_FUNC  PyInit__bsddb(void)    /
562f19e
 #if (DBVER >= 42)
562f19e
     MAKE_EX(DBRepHandleDeadError);
562f19e
 #endif
562f19e
+#if (DBVER >= 44)
562f19e
+    MAKE_EX(DBRepLockoutError);
562f19e
+#endif
562f19e
 
562f19e
     MAKE_EX(DBRepUnavailError);
562f19e
 
562f19e
+#if (DBVER >= 46)
562f19e
+    MAKE_EX(DBRepLeaseExpiredError);
562f19e
+#endif
562f19e
+
562f19e
 #undef MAKE_EX
562f19e
 
562f19e
     /* Initiliase the C API structure and add it to the module */
562f19e
@@ -7544,7 +8533,24 @@ PyMODINIT_FUNC  PyInit__bsddb(void)    /
562f19e
 #endif
562f19e
     bsddb_api.makeDBError     = makeDBError;
562f19e
 
562f19e
+    /*
562f19e
+    ** Capsules exist from Python 3.1, but I
562f19e
+    ** don't want to break the API compatibility
562f19e
+    ** for already published Python versions.
562f19e
+    */
562f19e
+#if (PY_VERSION_HEX < 0x03020000)
562f19e
     py_api = PyCObject_FromVoidPtr((void*)&bsddb_api, NULL);
562f19e
+#else
562f19e
+    {
562f19e
+        char py_api_name[250];
562f19e
+
562f19e
+        strcpy(py_api_name, _bsddbModuleName);
562f19e
+        strcat(py_api_name, ".api");
562f19e
+
562f19e
+        py_api = PyCapsule_New((void*)&bsddb_api, py_api_name, NULL);
562f19e
+    }
562f19e
+#endif
562f19e
+
562f19e
     PyDict_SetItemString(d, "api", py_api);
562f19e
     Py_DECREF(py_api);
562f19e
 
562f19e
diff -Nupr Python-2.6.4.orig/Modules/bsddb.h Python-2.6.4/Modules/bsddb.h
562f19e
--- Python-2.6.4.orig/Modules/bsddb.h	2008-09-28 19:24:19.000000000 -0400
562f19e
+++ Python-2.6.4/Modules/bsddb.h	2009-12-04 07:34:56.000000000 -0500
562f19e
@@ -105,7 +105,7 @@
562f19e
 #error "eek! DBVER can't handle minor versions > 9"
562f19e
 #endif
562f19e
 
562f19e
-#define PY_BSDDB_VERSION "4.7.3"
562f19e
+#define PY_BSDDB_VERSION "4.8.1"
562f19e
 
562f19e
 /* Python object definitions */
562f19e
 
562f19e
@@ -220,6 +220,7 @@ typedef struct DBSequenceObject {
562f19e
 /* To access the structure from an external module, use code like the
562f19e
    following (error checking missed out for clarity):
562f19e
 
562f19e
+     // If you are using Python 3.2:
562f19e
      BSDDB_api* bsddb_api;
562f19e
      PyObject*  mod;
562f19e
      PyObject*  cobj;
562f19e
@@ -231,6 +232,15 @@ typedef struct DBSequenceObject {
562f19e
      Py_DECREF(cobj);
562f19e
      Py_DECREF(mod);
562f19e
 
562f19e
+
562f19e
+     // If you are using Python 3.2 or up:
562f19e
+     BSDDB_api* bsddb_api;
562f19e
+
562f19e
+     // Use "bsddb3._pybsddb.api" if you're using
562f19e
+     // the standalone pybsddb add-on.
562f19e
+     bsddb_api = (void **)PyCapsule_Import("bsddb._bsddb.api", 1);
562f19e
+
562f19e
+
562f19e
    The structure's members must not be changed.
562f19e
 */
562f19e
 
562f19e
@@ -247,7 +257,6 @@ typedef struct {
562f19e
 
562f19e
     /* Functions */
562f19e
     int (*makeDBError)(int err);
562f19e
-
562f19e
 } BSDDB_api;
562f19e
 
562f19e