packages feed

BerkeleyDB 0.8.1 → 0.8.2

raw patch · 4 files changed

+147/−54 lines, 4 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

+ Database.Berkeley.Db: DB_DUP :: DbFlag
+ Database.Berkeley.Db: DB_DUPSORT :: DbFlag
+ Database.Berkeley.Db: DB_LOG_AUTO_REMOVE :: DbLogFlag
+ Database.Berkeley.Db: DB_LOG_DIRECT :: DbLogFlag
+ Database.Berkeley.Db: DB_LOG_DSYNC :: DbLogFlag
+ Database.Berkeley.Db: DB_LOG_IN_MEMORY :: DbLogFlag
+ Database.Berkeley.Db: DB_LOG_ZERO :: DbLogFlag
+ Database.Berkeley.Db: data DbLogFlag
+ Database.Berkeley.Db: dbEnv_log_set_config :: DbEnv -> [DbLogFlag] -> Bool -> IO ()
+ Database.Berkeley.Db: dbEnv_set_flags :: DbEnv -> [DbFlag] -> Bool -> IO ()
+ Database.Berkeley.Db: db_set_flags :: [DbFlag] -> Db -> IO ()
- Database.Berkeley.Db: dbToNum :: DbFlag -> CUInt
+ Database.Berkeley.Db: dbToNum :: DbFlag -> Word32

Files

BerkeleyDB.cabal view
@@ -1,5 +1,5 @@ name: BerkeleyDB-version: 0.8.1+version: 0.8.2 license: BSD3 license-file: LICENSE cabal-version: >= 1.4
Database/Berkeley/Db.hsc view
@@ -19,7 +19,6 @@         DbEnvCreateFlag,         dbEnv_create,         dbEnv_get_cache_size,-        dbEnv_get_lg_regionmax,         dbEnv_get_lk_max_lockers,         dbEnv_get_lk_max_locks,         dbEnv_get_lk_max_objects,@@ -32,7 +31,6 @@         dbEnv_withLock,         dbEnv_open,         dbEnv_set_cache_size,-        dbEnv_set_lg_regionmax,         DbLockFlag(..),         dbEnv_set_lk_detect,         dbEnv_set_lk_max_lockers,@@ -40,6 +38,7 @@         dbEnv_set_lk_max_objects,         dbEnv_set_tx_max,         dbEnv_txn_checkpoint,+        dbEnv_set_flags,         -- * DbTxn         dbEnv_withTxn,         dbEnv_txn_begin,@@ -55,6 +54,7 @@         DbType(..),         db_open,         db_close,+        db_set_flags,         db_put,         db_set_pagesize,         -- * DbCursor@@ -69,6 +69,13 @@         dbCursor_get,         dbCursor_set,         dbCursor_put,+        -- * Logging subsystem+#if (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 7) || DB_VERSION_MAJOR > 4+        DbLogFlag(..),+        dbEnv_log_set_config,+#endif+        dbEnv_get_lg_regionmax,+        dbEnv_set_lg_regionmax,         -- * Private         dbToNum,       -- | Needed for BerkeleyDBXML: Binary representation of a DbFlag         dbErrFromNum,  -- | Needed for BerkeleyDBXML: Convert an error code to a DbError@@ -346,36 +353,6 @@             else return ()  -foreign import ccall safe "db_helper.h _dbenv_get_lg_regionmax" _dbenv_get_lg_regionmax-    :: Ptr DbEnv_struct -> Ptr CUInt -> IO CInt--dbEnv_get_lg_regionmax :: DbEnv -> IO Int-dbEnv_get_lg_regionmax dbenv =-    withForeignPtr dbenv $ \c_dbenv ->-    alloca $ \ptr -> do-        ret <- _dbenv_get_lg_regionmax c_dbenv ptr-        if ret /= 0-            then throwDB "dbEnv_get_lg_regionmax" ret-            else do-                ci <- peek ptr-                return $ fromIntegral ci---foreign import ccall safe "db_helper.h _dbenv_set_lg_regionmax" _dbenv_set_lg_regionmax-    :: Ptr DbEnv_struct -> CUInt -> IO CInt--dbEnv_set_lg_regionmax :: DbEnv -> Int -> IO ()-dbEnv_set_lg_regionmax dbenv max =-    withForeignPtr dbenv $ \c_dbenv -> do-        ret <- _dbenv_set_lg_regionmax c_dbenv (fromIntegral max)-        if ret /= 0-            then throwDB "dbEnv_set_lg_regionmax" ret-            else return ()---foreign import ccall safe "db_helper.h _dbenv_open" _dbenv_open-    :: Ptr DbEnv_struct -> CString -> CUInt -> CInt -> IO CInt- data DbFlag =     DB_CREATE |     DB_DURABLE_UNKNOWN |@@ -452,10 +429,12 @@     DB_SET_RECNO |     DB_UPDATE_SECONDARY |     DB_WRITECURSOR |-    DB_WRITELOCK+    DB_WRITELOCK |+    DB_DUP |+    DB_DUPSORT  -dbToNum :: DbFlag -> CUInt+dbToNum :: DbFlag -> Word32 dbToNum DB_CREATE = #const DB_CREATE dbToNum	DB_DURABLE_UNKNOWN = #const DB_DURABLE_UNKNOWN dbToNum	DB_FORCE = #const DB_FORCE@@ -533,9 +512,13 @@ dbToNum DB_WRITECURSOR = (#const DB_WRITECURSOR)       -- Db.cursor dbToNum DB_WRITELOCK = (#const DB_WRITELOCK)           -- Db.cursor (internal) -+dbOrFlags :: [DbFlag] -> Word32 dbOrFlags flags = foldr (.|.) 0 $ map dbToNum flags ++foreign import ccall safe "db_helper.h _dbenv_open" _dbenv_open+    :: Ptr DbEnv_struct -> CString -> Word32 -> CInt -> IO CInt+ -- | Open the Berkeley DB environment, which must be done before 'db_open'. dbEnv_open :: [DbFlag]            -> Int        -- ^ UNIX file creation mode, or 0, meaning \"readable and writable by both owner and group\"@@ -551,7 +534,7 @@             else return ()  foreign import ccall "db_helper.h _dbenv_close" _dbenv_close-    :: Ptr DbEnv_struct -> CUInt -> IO CInt+    :: Ptr DbEnv_struct -> Word32 -> IO CInt  -- | Close the Berkeley DB environment. dbEnv_close :: [DbFlag] -> DbEnv -> IO ()@@ -598,7 +581,81 @@             then throwDB "dbEnv_set_lk_detect" ret             else return () +foreign import ccall "db_helper.h _dbenv_set_flags" _dbenv_set_flags+    :: Ptr DbEnv_struct -> Word32 -> CInt -> IO CInt +dbEnv_set_flags :: DbEnv+                -> [DbFlag]   -- ^ environment flags+                -> Bool       -- ^ onoff: False to clear the specified flags, True to set them+                -> IO ()+dbEnv_set_flags dbenv flags onoff =+    withForeignPtr dbenv $ \c_dbenv -> do+        ret <- _dbenv_set_flags c_dbenv (dbOrFlags flags) (if onoff then 1 else 0)+        if ret /= 0+            then throwDB "dbEnv_set_flags" ret+            else return ()+++------ Logging subsystem -------------------------------------------------------++#if (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 7) || DB_VERSION_MAJOR > 4+data DbLogFlag+    = DB_LOG_DIRECT+    | DB_LOG_DSYNC+    | DB_LOG_AUTO_REMOVE+    | DB_LOG_IN_MEMORY+    | DB_LOG_ZERO+dbLogToNum :: DbLogFlag -> Word32+dbLogToNum DB_LOG_DIRECT = (#const DB_LOG_DIRECT)+dbLogToNum DB_LOG_DSYNC = (#const DB_LOG_DSYNC)+dbLogToNum DB_LOG_AUTO_REMOVE = (#const DB_LOG_AUTO_REMOVE)+dbLogToNum DB_LOG_IN_MEMORY = (#const DB_LOG_IN_MEMORY)+dbLogToNum DB_LOG_ZERO = (#const DB_LOG_ZERO)++dbLogOrFlags :: [DbLogFlag] -> Word32+dbLogOrFlags flags = foldr (.|.) 0 $ map dbLogToNum flags++foreign import ccall "db_helper.h _dbenv_log_set_config" _dbenv_log_set_config+    :: Ptr DbEnv_struct -> Word32 -> CInt -> IO CInt++dbEnv_log_set_config :: DbEnv+                     -> [DbLogFlag]+                     -> Bool       -- ^ onoff: False to clear the specified flags, True to set them+                     -> IO ()+dbEnv_log_set_config dbenv flags onoff =+    withForeignPtr dbenv $ \c_dbenv -> do+        ret <- _dbenv_log_set_config c_dbenv (dbLogOrFlags flags) (if onoff then 1 else 0)+        if ret /= 0+            then throwDB "dbEnv_log_set_config" ret+            else return ()+#endif++foreign import ccall safe "db_helper.h _dbenv_get_lg_regionmax" _dbenv_get_lg_regionmax+    :: Ptr DbEnv_struct -> Ptr CUInt -> IO CInt++dbEnv_get_lg_regionmax :: DbEnv -> IO Int+dbEnv_get_lg_regionmax dbenv =+    withForeignPtr dbenv $ \c_dbenv ->+    alloca $ \ptr -> do+        ret <- _dbenv_get_lg_regionmax c_dbenv ptr+        if ret /= 0+            then throwDB "dbEnv_get_lg_regionmax" ret+            else do+                ci <- peek ptr+                return $ fromIntegral ci++foreign import ccall safe "db_helper.h _dbenv_set_lg_regionmax" _dbenv_set_lg_regionmax+    :: Ptr DbEnv_struct -> CUInt -> IO CInt++dbEnv_set_lg_regionmax :: DbEnv -> Int -> IO ()+dbEnv_set_lg_regionmax dbenv max =+    withForeignPtr dbenv $ \c_dbenv -> do+        ret <- _dbenv_set_lg_regionmax c_dbenv (fromIntegral max)+        if ret /= 0+            then throwDB "dbEnv_set_lg_regionmax" ret+            else return ()++ ------ Db ----------------------------------------------------------------------  data Db_struct@@ -608,7 +665,7 @@   foreign import ccall safe "db_helper.h _db_create" _db_create-    ::  Ptr (Ptr Db_struct) -> Ptr DbEnv_struct -> CUInt -> IO CInt+    ::  Ptr (Ptr Db_struct) -> Ptr DbEnv_struct -> Word32 -> IO CInt  -- | Create a database handle. db_create :: [DbFlag] -> DbEnv -> IO Db@@ -649,7 +706,7 @@   foreign import ccall "db_helper.h _db_open" _db_open-    :: Ptr Db_struct -> Ptr DbTxn_struct -> CString -> CString -> CInt -> CUInt -> CInt -> IO CInt+    :: Ptr Db_struct -> Ptr DbTxn_struct -> CString -> CString -> CInt -> Word32 -> CInt -> IO CInt  -- | Open a database. db_open :: [DbFlag]@@ -689,7 +746,7 @@   foreign import ccall "db_helper.h _dbenv_txn_begin" _dbenv_txn_begin-    :: Ptr DbEnv_struct -> Ptr DbTxn_struct -> Ptr (Ptr DbTxn_struct) -> CUInt -> IO CInt+    :: Ptr DbEnv_struct -> Ptr DbTxn_struct -> Ptr (Ptr DbTxn_struct) -> Word32 -> IO CInt  -- | Create a new transaction. You are recommended to use 'dbEnv_withTxn' -- instead of this function.@@ -730,7 +787,7 @@             return retValue  foreign import ccall "db_helper.h _dbenv_txn_checkpoint" _dbenv_txn_checkpoint-    :: Ptr DbEnv_struct -> CUInt -> CUInt -> CUInt -> IO CInt+    :: Ptr DbEnv_struct -> CUInt -> CUInt -> Word32 -> IO CInt  -- | Checkpoint the transaction subsystem. dbEnv_txn_checkpoint :: [DbFlag]@@ -761,7 +818,7 @@   foreign import ccall "db_helper.h _dbtxn_commit" _dbtxn_commit-    :: Ptr DbTxn_struct -> CUInt -> IO CInt+    :: Ptr DbTxn_struct -> Word32 -> IO CInt  -- | Commit a transaction. You are recommended to use 'dbEnv_withTxn' -- instead of this function.@@ -804,7 +861,7 @@   foreign import ccall "db_helper.h _dbenv_lock_get" _dbenv_lock_get-    :: Ptr DbEnv_struct -> CUInt -> CUInt -> Ptr Word8 -> CUInt -> CUInt -> Ptr (Ptr DbLock_struct) -> IO CInt+    :: Ptr DbEnv_struct -> CUInt -> Word32 -> Ptr Word8 -> CUInt -> Word32 -> Ptr (Ptr DbLock_struct) -> IO CInt  -- | Acquire a DbLock. 'dbTxn_id' converts a DbTxn to a DbLocker. dbEnv_lock_get :: [DbFlag]@@ -862,7 +919,7 @@     :: FunPtr (Ptr Word8 -> IO ())  foreign import ccall "db_helper.h _db_get" _db_get-    :: Ptr Db_struct -> Ptr DbTxn_struct -> Ptr Word8 -> CUInt -> Ptr (Ptr Word8) -> Ptr CUInt -> CUInt -> IO CInt+    :: Ptr Db_struct -> Ptr DbTxn_struct -> Ptr Word8 -> CUInt -> Ptr (Ptr Word8) -> Ptr CUInt -> Word32 -> IO CInt  -- | Look the key up in the database, and return Just the stored value, or Nothing -- if it was not found.@@ -895,7 +952,7 @@   foreign import ccall "db_helper.h _db_put" _db_put-    :: Ptr Db_struct -> Ptr DbTxn_struct -> Ptr Word8 -> CUInt -> Ptr Word8 -> CUInt -> CUInt -> IO CInt+    :: Ptr Db_struct -> Ptr DbTxn_struct -> Ptr Word8 -> CUInt -> Ptr Word8 -> CUInt -> Word32 -> IO CInt  -- | Store the specified value into the database under the specified key. db_put :: [DbFlag]@@ -928,7 +985,7 @@   foreign import ccall "db_helper.h _db_del" _db_del-    :: Ptr Db_struct -> Ptr DbTxn_struct -> Ptr Word8 -> CUInt -> CUInt -> IO CInt+    :: Ptr Db_struct -> Ptr DbTxn_struct -> Ptr Word8 -> CUInt -> Word32 -> IO CInt  db_del :: [DbFlag] -> Db -> Maybe DbTxn -> ByteString -> IO () db_del flags db mTxn key =@@ -946,7 +1003,7 @@   foreign import ccall "db_helper.h _db_close" _db_close-    :: Ptr Db_struct -> CUInt -> IO CInt+    :: Ptr Db_struct -> Word32 -> IO CInt  db_close :: [DbFlag] -> Db -> IO () db_close flags db =@@ -956,7 +1013,18 @@             then throwDB "db_close" ret             else return () +foreign import ccall "db_helper.h _db_set_flags" _db_set_flags+    :: Ptr Db_struct -> Word32 -> IO CInt +db_set_flags :: [DbFlag] -> Db -> IO ()+db_set_flags flags db =+    withForeignPtr db $ \c_db -> do+        ret <- _db_set_flags c_db (dbOrFlags flags)+        if ret /= 0+            then throwDB "db_set_flags" ret+            else return ()++ ------ DbCursor ----------------------------------------------------------------  data DbCursor_struct@@ -978,7 +1046,7 @@         action  foreign import ccall "db_helper.h _db_cursor" _db_cursor-    :: Ptr Db_struct -> Ptr DbTxn_struct -> Ptr (Ptr DbCursor_struct) -> CUInt -> IO CInt+    :: Ptr Db_struct -> Ptr DbTxn_struct -> Ptr (Ptr DbCursor_struct) -> Word32 -> IO CInt  -- | Open a DbCursor.  You are recommended to use 'db_withCursor' instead of this -- function.@@ -1010,7 +1078,7 @@             else return ()  foreign import ccall "db_helper.h _dbCursor_count" _dbCursor_count-    :: Ptr DbCursor_struct -> Ptr CUInt -> CUInt -> IO CInt+    :: Ptr DbCursor_struct -> Ptr CUInt -> Word32 -> IO CInt  -- | Count the number of duplicates at the cursor position. dbCursor_count :: [DbFlag] -> DbCursor -> IO Int@@ -1023,7 +1091,7 @@             else fromIntegral <$> peek p_count  foreign import ccall "db_helper.h _dbCursor_del" _dbCursor_del-    :: Ptr DbCursor_struct -> CUInt -> IO CInt+    :: Ptr DbCursor_struct -> Word32 -> IO CInt  -- | Delete the record at the cursor position. dbCursor_del :: [DbFlag] -> DbCursor -> IO ()@@ -1047,7 +1115,7 @@         action  foreign import ccall "db_helper.h _dbCursor_dup" _dbCursor_dup-    :: Ptr DbCursor_struct -> Ptr (Ptr DbCursor_struct) -> CUInt -> IO CInt+    :: Ptr DbCursor_struct -> Ptr (Ptr DbCursor_struct) -> Word32 -> IO CInt  -- | Create a duplicate of the specified cursor. dbCursor_dup :: [DbFlag] -> DbCursor -> IO DbCursor@@ -1060,7 +1128,7 @@             else newForeignPtr _dbcursor_delete =<< peek pc_cursor  foreign import ccall "db_helper.h _dbCursor_get" _dbCursor_get-    :: Ptr DbCursor_struct -> Ptr (Ptr Word8) -> Ptr CUInt -> Ptr (Ptr Word8) -> Ptr CUInt -> CUInt -> IO CInt+    :: Ptr DbCursor_struct -> Ptr (Ptr Word8) -> Ptr CUInt -> Ptr (Ptr Word8) -> Ptr CUInt -> Word32 -> IO CInt  -- | Fetch the record pointed at by the cursor (modified by the flags - see the -- Berkeley DB documentation), and return Just the (key, value) pair at the cursor@@ -1090,7 +1158,7 @@                      BSI.fromForeignPtr value 0 (fromIntegral value_len))  foreign import ccall "db_helper.h _dbCursor_set" _dbCursor_set-    :: Ptr DbCursor_struct -> Ptr Word8 -> CUInt -> Ptr (Ptr Word8) -> Ptr CUInt -> CUInt -> IO CInt+    :: Ptr DbCursor_struct -> Ptr Word8 -> CUInt -> Ptr (Ptr Word8) -> Ptr CUInt -> Word32 -> IO CInt  -- | Move the cursor to the specified key/data pair of the database, and return -- the datum associated with the given key, or Nothing if it wasn't matched.@@ -1114,7 +1182,7 @@                 return $ Just $ BSI.fromForeignPtr str 0 (fromIntegral value_len)  foreign import ccall "db_helper.h _dbCursor_put" _dbCursor_put-    :: Ptr DbCursor_struct -> Ptr Word8 -> CUInt -> Ptr Word8 -> CUInt -> CUInt -> IO CInt+    :: Ptr DbCursor_struct -> Ptr Word8 -> CUInt -> Ptr Word8 -> CUInt -> Word32 -> IO CInt  -- | stores key/data pairs into the database in the context of the cursor. dbCursor_put :: [DbFlag] -> DbCursor -> ByteString -> ByteString -> IO ()
Database/Berkeley/db_helper.c view
@@ -117,6 +117,20 @@     return dbenv->set_lk_detect(dbenv, flag); } +int _dbenv_set_flags(MY_DBENV* dbenvp, u_int32_t flags, int onoff)+{+    UNWRAP_DBENV();+    return dbenv->set_flags(dbenv, flags, onoff);+}++#if (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 7) || DB_VERSION_MAJOR > 4+int _dbenv_log_set_config(MY_DBENV* dbenvp, u_int32_t flags, int onoff)+{+    UNWRAP_DBENV();+    return dbenv->log_set_config(dbenv, flags, onoff);+}+#endif+ int _dbenv_open(MY_DBENV* dbenvp, char *db_home, u_int32_t flags, int mode) {     UNWRAP_DBENV();     return dbenv->open(dbenv, db_home, flags, mode);@@ -328,6 +342,12 @@     UNWRAP_DB();     *dbp = NULL;     return db->close(db, flags);+}++int _db_set_flags(DB** dbp, u_int32_t flags)+{+    UNWRAP_DB();+    return db->set_flags(db, flags); }  int _db_cursor(DB** dbp, DB_TXN** dbtxnp, DBC*** dbcursorpp, u_int32_t flags)
Database/Berkeley/db_helper.h view
@@ -24,6 +24,10 @@ int _dbenv_get_lg_regionmax(MY_DBENV* dbenvp, u_int32_t *lk_maxp); int _dbenv_set_lg_regionmax(MY_DBENV* dbenvp, u_int32_t max); int _dbenv_set_lk_detect(MY_DBENV* dbEnv, u_int32_t flag);+int _dbenv_set_flags(MY_DBENV* dbEnv, u_int32_t flags, int onoff);+#if (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 7) || DB_VERSION_MAJOR > 4+int _dbenv_log_set_config(MY_DBENV* dbEnv, u_int32_t flags, int onoff);+#endif int _dbenv_open(MY_DBENV* dbenvp, char *db_home, u_int32_t flags, int mode); int _dbenv_close(MY_DBENV* dbEnv, u_int32_t flags); int _db_create(DB*** dbpp, MY_DBENV* dbenvp, u_int32_t flags);@@ -47,6 +51,7 @@ int _db_put(DB** dbp, DB_TXN** dbtxnp, const char* key, u_int32_t key_len, const char* value, u_int32_t value_len, u_int32_t flags); int _db_del(DB** dbp, DB_TXN** dbtxnp, const char* key, u_int32_t key_len, u_int32_t flags); int _db_close(DB** dbp, u_int32_t flags);+int _db_set_flags(DB** dbp, u_int32_t flags); int _db_cursor(DB** dbp, DB_TXN** dbtxnp, DBC*** dbcursorpp, u_int32_t flags); void _dbcursor_delete(DBC** dbc); int _dbCursor_close(DBC** dbc);