BerkeleyDB 0.7 → 0.7.1
raw patch · 4 files changed
+29/−11 lines, 4 filesdep ~basePVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: base
API changes (from Hackage documentation)
- Database.Berkeley.Db: dbEnv_txn_checkpoint :: [DbFlag] -> DbEnv -> CUInt -> CUInt -> IO ()
+ Database.Berkeley.Db: dbEnv_txn_checkpoint :: [DbFlag] -> DbEnv -> Word -> Word -> IO ()
Files
- BerkeleyDB.cabal +2/−2
- Database/Berkeley/Db.hs +6/−5
- Database/Berkeley/db_helper.cpp +20/−3
- examples/tests.hs +1/−1
BerkeleyDB.cabal view
@@ -1,5 +1,5 @@ name: BerkeleyDB-version: 0.7+version: 0.7.1 license: BSD3 license-file: LICENSE cabal-version: >= 1.4@@ -50,7 +50,7 @@ Library exposed-modules: Database.Berkeley.Db - build-depends: base, extensible-exceptions, bytestring >= 0.9+ build-depends: base >= 3 && < 5, extensible-exceptions, bytestring >= 0.9 include-dirs: Database/Berkeley/ if flag(CXX) extra-libraries: db db_cxx
Database/Berkeley/Db.hs view
@@ -47,12 +47,12 @@ dbTxn_id, -- * Db Db,- db_close, db_create, db_del, db_get, DbType(..), db_open,+ db_close, db_put, db_set_pagesize, -- * DbCursor@@ -740,12 +740,12 @@ -- | Checkpoint the transaction subsystem. dbEnv_txn_checkpoint :: [DbFlag] -> DbEnv- -> CUInt -- ^ kbyte- -> CUInt -- ^ min+ -> Word -- ^ kbyte+ -> Word -- ^ minutes -> IO () dbEnv_txn_checkpoint flags dbenv kbyte min = withForeignPtr dbenv $ \c_dbenv -> do- ret <- _dbenv_txn_checkpoint c_dbenv kbyte min (dbOrFlags flags)+ ret <- _dbenv_txn_checkpoint c_dbenv (fromIntegral kbyte) (fromIntegral min) (dbOrFlags flags) if ret /= 0 then throwDB "dbEnv_txn_checkpoint" ret else return ()@@ -1036,7 +1036,7 @@ then throwDB "dbCursor_del" ret else return () --- | An exception-safe helper that duplcates a cursor using dbCursor_dup,+-- | An exception-safe helper that duplicates a cursor using 'dbCursor_dup', -- passes it to an action, and cleans up afterwards. dbCursor_withCursor :: [DbFlag] -- ^ 'db_cursor' flags -> DbCursor -- ^ The source cursor@@ -1051,6 +1051,7 @@ foreign import ccall "db_helper.h _dbCursor_dup" _dbCursor_dup :: Ptr DbCursor_struct -> Ptr (Ptr DbCursor_struct) -> CUInt -> IO CInt +-- | Create a duplicate of the specified cursor. dbCursor_dup :: [DbFlag] -> DbCursor -> IO DbCursor dbCursor_dup flags dbc = withForeignPtr dbc $ \c_dbc ->
Database/Berkeley/db_helper.cpp view
@@ -206,20 +206,33 @@ parent = *parentp; if (parent == NULL) return -20883; /* Haskell binding-specific error code */ }- *txnpp = (MY_DBTXN**)malloc(sizeof(MY_DBTXN*)); #if defined(USE_DB_CXX) try {- return dbenvp->txn_begin(parent, *txnpp, flags);+ *txnpp = (MY_DBTXN**)malloc(sizeof(MY_DBTXN*)*2);+ int ret = dbenvp->txn_begin(parent, *txnpp, flags);+ // We store two copies of the pointer. The second one becomes NULL if+ // the transaction gets adopted by BerkeleyDBXML. If it's adopted, we+ // don't force an abort in our finalizer.+ (*txnpp)[1] = (*txnpp)[0];+ return ret; } catch (DbException& exc) { free(*txnpp); return exc.get_errno(); } #else+ *txnpp = (MY_DBTXN**)malloc(sizeof(MY_DBTXN*)); return dbenv->txn_begin(dbenv, parent, *txnpp, flags); #endif } +void detach_DbTxn(MY_DBTXN** dbtxnp)+{+ dbtxnp[1] = NULL; // Nullify the second slot to mark it as adopted, so+ // as to prevent BerkeleyDB from aborting the transaction+ // in its finalizer.+}+ int _dbenv_txn_checkpoint(MY_DBENV* dbenvp, u_int32_t kbyte, u_int32_t min, u_int32_t flags) { UNWRAP_DBENV();@@ -242,10 +255,14 @@ void _dbtxn_delete(MY_DBTXN** dbtxnp) {- if (*dbtxnp != NULL) #if defined(USE_DB_CXX)+ // If either slot has been nulled, don't abort it in the finalizer.+ // Slot 0 nulled = explicitly commited or aborted by dbTxn_abort or dbTxn_commit.+ // Slot 1 nulled = adopted by BerkeleyDBXML.+ if (*dbtxnp != NULL && dbtxnp[1] != NULL) (*dbtxnp)->abort(); #else+ if (*dbtxnp != NULL) (*dbtxnp)->abort(*dbtxnp); #endif free(dbtxnp);
examples/tests.hs view
@@ -1,7 +1,7 @@ import System.Directory import Database.Berkeley.Db import Test.HUnit-import Control.Exception+import Control.Exception.Extensible import Control.Monad import qualified Data.ByteString as B import Data.Char