Updated to Oracle Berkeley DB version 5.2.28

This commit is contained in:
Gregory Burd 2011-08-09 11:01:44 -04:00
parent 2983416786
commit 7b1350f899
18 changed files with 476 additions and 399 deletions

7
.gitignore vendored
View file

@ -1,11 +1,16 @@
*~
\#*#
.\#*
*.o
*.so
*.beam
c_src/system
logs
doc
test/test.cover
int_test/test.cover
.eunit
bdberl-*
priv/mibs
c_src/system
c_src/db-*
c_src/db-*.tar.gz

26
c_src/Makefile Normal file
View file

@ -0,0 +1,26 @@
# This Makefile builds the dependency (libdb) needed by bdberl_drv.so
TAR ?= tar
GUNZIP ?= gunzip
BDB_VER := 5.2.28
BDB_DIR := $(CURDIR)/db-$(BDB_VER)
SYSTEM_DIR := $(CURDIR)/system
LIB_DIR := $(SYSTEM_DIR)/lib
INC_DIR := $(SYSTEM_DIR)/include
db: $(LIB_DIR)/libdb.a
$(LIB_DIR)/libdb.a:
$(GUNZIP) -c db-$(BDB_VER).tar.gz | $(TAR) xf -
@for I in patches/*.patch; do \
(patch -p0 < $${I} || echo "Skipping patch"); \
done
@./configure_bdb.sh $(BDB_DIR) $(SYSTEM_DIR)
@$(MAKE) -C $(BDB_DIR)/build_unix install
clean:
@rm -rf $(SYSTEM_DIR) $(BDB_DIR)
.EXPORT_ALL_VARIABLES:

View file

@ -1,133 +0,0 @@
--- dbinc/mp.h.orig 2006-09-07 14:31:58.000000000 -0700
+++ dbinc/mp.h 2007-01-06 19:14:56.000000000 -0800
@@ -378,6 +378,23 @@
#define BH_FREE_REUSE 0x02
#define BH_FREE_UNLOCKED 0x04
+#ifdef DIAG_MVCC
+#define BH_ALIGNED
+#define VM_PAGESIZE 4096
+#endif
+
+/* Linux O_DIRECT needs aligned buffers. 2.6 kernel allows 512 byte
+ * alignment, otherwise need page sized (4096).
+ */
+#if defined(linux) && !defined(BH_ALIGNED)
+#define BH_ALIGNED
+#ifdef LINUX_NEEDS_PAGE_ALIGNMENT
+#define VM_PAGESIZE 4096
+#else /* Linux 2.6+ */
+#define VM_PAGESIZE 512
+#endif
+#endif
+
/*
* BH --
* Buffer header.
@@ -404,7 +421,7 @@
roff_t td_off; /* MVCC: creating TXN_DETAIL offset. */
SH_CHAIN_ENTRY vc; /* MVCC: version chain. */
-#ifdef DIAG_MVCC
+#ifdef BH_ALIGNED
u_int16_t align_off; /* Alignment offset for diagnostics.*/
#endif
@@ -465,15 +482,14 @@
(dbc->txn != NULL && F_ISSET(dbc->txn, TXN_SNAPSHOT) && \
dbc->txn->td != NULL && __memp_skip_curadj(dbc, pgno))
-#if defined(DIAG_MVCC) && defined(HAVE_MPROTECT)
-#define VM_PAGESIZE 4096
-#define MVCC_BHSIZE(mfp, sz) do { \
+#ifdef BH_ALIGNED
+#define BHSIZE(mfp, sz) do { \
sz += VM_PAGESIZE + sizeof(BH); \
if (mfp->stat.st_pagesize < VM_PAGESIZE) \
sz += VM_PAGESIZE - mfp->stat.st_pagesize; \
} while (0)
-#define MVCC_BHALIGN(mfp, p) do { \
+#define BHALIGN(mfp, p) do { \
if (mfp != NULL) { \
BH *__bhp; \
void *__orig = (p); \
@@ -493,13 +509,19 @@
} \
} while (0)
-#define MVCC_BHUNALIGN(mfp, p) do { \
+#define BHUNALIGN(mfp, p) do { \
if ((mfp) != NULL) { \
BH *bhp = (BH *)(p); \
(p) = ((u_int8_t *)bhp - bhp->align_off); \
} \
} while (0)
+#else
+#define BHSIZE(mfp, sz) do {} while (0)
+#define BHALIGN(mfp, p) do {} while (0)
+#define BHUNALIGN(mfp, p) do {} while (0)
+#endif
+#if defined(DIAG_MVCC) && defined(HAVE_MPROTECT)
#ifdef linux
#define MVCC_MPROTECT(buf, sz, mode) do { \
int __ret = mprotect((buf), (sz), (mode)); \
@@ -513,11 +535,7 @@
} \
} while (0)
#endif /* linux */
-
-#else /* defined(DIAG_MVCC) && defined(HAVE_MPROTECT) */
-#define MVCC_BHSIZE(mfp, sz) do {} while (0)
-#define MVCC_BHALIGN(mfp, p) do {} while (0)
-#define MVCC_BHUNALIGN(mfp, p) do {} while (0)
+#else
#define MVCC_MPROTECT(buf, size, mode) do {} while (0)
#endif
--- mp/mp_alloc.c.orig 2006-09-07 14:32:03.000000000 -0700
+++ mp/mp_alloc.c 2007-01-06 19:14:56.000000000 -0800
@@ -66,7 +66,7 @@
if (mfp != NULL) {
len = SSZA(BH, buf) + mfp->stat.st_pagesize;
/* Add space for alignment padding for MVCC diagnostics. */
- MVCC_BHSIZE(mfp, len);
+ BHSIZE(mfp, len);
}
MPOOL_REGION_LOCK(dbenv, infop);
@@ -91,10 +91,10 @@
c_mp->stat.st_pages++;
MPOOL_REGION_UNLOCK(dbenv, infop);
/*
- * For MVCC diagnostics, align the pointer so that the buffer
+ * If necessary, align the pointer so that the buffer
* starts on a page boundary.
*/
- MVCC_BHALIGN(mfp, p);
+ BHALIGN(mfp, p);
found: if (offsetp != NULL)
*offsetp = R_OFFSET(infop, p);
@@ -447,7 +447,7 @@
MPOOLFILE *mfp;
void *buf;
{
- MVCC_BHUNALIGN(mfp, buf);
+ BHUNALIGN(mfp, buf);
COMPQUIET(mfp, NULL);
__db_shalloc_free(infop, buf);
}
--- mp/mp_fget.c.orig 2006-09-13 09:22:42.000000000 -0700
+++ mp/mp_fget.c 2007-01-06 19:14:56.000000000 -0800
@@ -708,7 +708,7 @@
* the hash bucket's priority.
*/
/*lint --e{668} (flexelint: bhp cannot be NULL). */
-#ifdef DIAG_MVCC
+#ifdef BH_ALIGNED
memset(bhp, 0, SSZ(BH, align_off));
#else
memset(bhp, 0, sizeof(BH));

View file

@ -1,11 +1,15 @@
/* -------------------------------------------------------------------
*
* bdberl: Berkeley DB Driver for Erlang
*
* Copyright (c) 2008-9 The Hive http://www.thehive.com/
* Authors: Dave "dizzyd" Smith <dizzyd@dizzyd.com>
* Phil Toland <phil.toland@gmail.com>
* Jon Meredith <jon@jonmeredith.com>
*
* Copyright (c) 2011 Basho Technologies http://www.basho.com/
* Authors: Greg Burd <greg@basho.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights

View file

@ -29,7 +29,7 @@
#define _BDBERL_DRV
#include "erl_driver.h"
#include "db.h"
#include <db.h>
#include "bdberl_tpool.h"
#include "bdberl_crc32.h"
#include "bin_helper.h"

View file

@ -1,11 +1,15 @@
/* -------------------------------------------------------------------
*
* bdberl: Berkeley DB Driver for Erlang - Stats
*
* Copyright (c) 2008-9 The Hive http://www.thehive.com/
* Authors: Dave "dizzyd" Smith <dizzyd@dizzyd.com>
* Phil Toland <phil.toland@gmail.com>
* Jon Meredith <jon@jonmeredith.com>
*
* Copyright (c) 2011 Basho Technologies http://www.basho.com/
* Authors: Greg Burd <greg@basho.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights

11
c_src/build_driver_deps.sh Executable file
View file

@ -0,0 +1,11 @@
#!/bin/sh
set -e
if [ `basename $PWD` != "src" ]; then
cd c_src
fi
unset CFLAGS LDFLAGS
make $1

View file

@ -1,29 +0,0 @@
#!/bin/sh
WORKDIR=`pwd`/system
TARGETDIR=`(cd .. && pwd)`/priv
DB_VER="4.7.25"
## Check for necessary tarball
if [ ! -f "db-${DB_VER}.tar.gz" ]; then
echo "Could not find db tarball. Aborting..."
exit 1
fi
## Make sure target directory exists
mkdir -p $TARGETDIR
## Remove existing directories
rm -rf system db-${DB_VER}
## Untar and build everything
tar -xzf db-${DB_VER}.tar.gz && \
##(cd db-${DB_VER} && patch -p0 < ../bdb-align.patch ) && \
(cd db-${DB_VER}/build_unix && \
../dist/configure --prefix=$WORKDIR --enable-diagnostic --enable-debug --disable-replication --disable-shared --with-pic && make && ranlib libdb-*.a && make install) && \
rm -rf db-${DB_VER}

8
c_src/configure_bdb.sh Executable file
View file

@ -0,0 +1,8 @@
#!/bin/sh -
cd $1/build_unix && \
../dist/configure --disable-shared --enable-static --with-pic \
--disable-hash --disable-heap --disable-queue \
--disable-partition --disable-replication \
--enable-o_direct \
--prefix=$2

BIN
c_src/db-5.2.28.tar.gz Normal file

Binary file not shown.

View file

@ -0,0 +1,37 @@
--- db-5.2.28/dist/Makefile.in.orig 2011-08-08 11:12:17.000000000 -0400
+++ db-5.2.28/dist/Makefile.in 2011-08-08 11:13:04.000000000 -0400
@@ -1066,9 +1066,9 @@
# Library and standard utilities install.
##################################################
library_install: install_setup
-library_install: install_include install_lib install_utilities install_docs
+library_install: install_include install_lib install_utilities
-uninstall: uninstall_include uninstall_lib uninstall_utilities uninstall_docs
+uninstall: uninstall_include uninstall_lib uninstall_utilities
install_setup:
@test -d $(DESTDIR)$(prefix) || \
@@ -1144,22 +1144,6 @@
$(RM) $$i; \
done)
-# We install csharp docs even on UNIX so we don't have a
-# broken link on the landing page.
-DOCLIST=api_reference articles bdb-sql collections csharp \
- gsg gsg_db_rep gsg_txn index.html installation java \
- license porting programmer_reference upgrading
-
-install_docs:
- @echo "Installing documentation: $(DESTDIR)$(docdir) ..."
- @test -d $(DESTDIR)$(docdir) || \
- ($(MKDIR) -p $(DESTDIR)$(docdir) && \
- $(CHMOD) $(dmode) $(DESTDIR)$(docdir))
- @cd $(DESTDIR)$(docdir) && $(RM) -r $(DOCLIST)
- @cd $(topdir)/docs && $(CP) -pr $(DOCLIST) $(DESTDIR)$(docdir)/
-
-uninstall_docs:
- @cd $(DESTDIR)$(docdir) && $(RM) -r $(DOCLIST)
##################################################
# Remaining standard Makefile targets.

View file

@ -1,9 +1,7 @@
{application, bdberl,
[{description, "Berkeley DB Erlang Driver"},
{vsn, "12"},
{modules, [ bdberl, bdberl_logger ]},
{registered, []},
{applications, [kernel,
stdlib]},
{env, []}
]}.
{application,bdberl,
[{description,"This is an Erlang port driver that allows Erlang programs to store data in BerkleyDB."},
{vsn,"5.1.28"},
{registered,[]},
{applications,[kernel,stdlib]},
{env,[]},
{modules,[bdberl,bdberl_logger]}]}.

View file

@ -7,6 +7,9 @@
%% @author Phil Toland <phil.toland@gmail.com>
%% @author Jon Meredith <jon@jonmeredith.com>
%% @end
%% @copyright 2011 Basho Technologies http://www.basho.com/
%% @author Greg Burd <greg@basho.com>
%% @end
%%
%% Permission is hereby granted, free of charge, to any person obtaining a copy
%% of this software and associated documentation files (the "Software"), to deal
@ -65,7 +68,10 @@
-define(DB_TYPE_BTREE, 1).
-define(DB_TYPE_HASH, 2).
-define(DB_TYPE_UNKNOWN, 5).
%%-define(DB_TYPE_QUEUE, 3).
%%-define(DB_TYPE_RECNO, 4).
%%-define(DB_TYPE_HEAP, 5).
-define(DB_TYPE_UNKNOWN, 6).
-define(SYSP_CACHESIZE_GET, 1).
-define(SYSP_TXN_TIMEOUT_GET, 2).
@ -75,225 +81,271 @@
-define(STATUS_OK, 0).
-define(STATUS_ERROR, 1).
-define(ERROR_NONE, 0).
-define(ERROR_MAX_DBS, -29000). % System can not open any more databases
-define(ERROR_ASYNC_PENDING, -29001). % Async operation already pending on this port
-define(ERROR_INVALID_DBREF, -29002). % DbRef not currently opened by this port
-define(ERROR_TXN_OPEN, -29003). % Transaction already active on this port
-define(ERROR_NO_TXN, -29004). % No transaction open on this port
-define(ERROR_CURSOR_OPEN, -29005). % Cursor already active on this port
-define(ERROR_NO_CURSOR, -29006). % No cursor open on this port
-define(ERROR_DB_ACTIVE, -29007). % Database is currently active; operation requires otherwise
-define(ERROR_INVALID_CMD, -29008). % Invalid command
-define(ERROR_INVALID_DB_TYPE,-29009). % Invalid database type
-define(ERROR_NONE, 0).
-define(ERROR_MAX_DBS, -29000). % System can not open any more databases
-define(ERROR_ASYNC_PENDING, -29001). % Async operation already pending on this port
-define(ERROR_INVALID_DBREF, -29002). % DbRef not currently opened by this port
-define(ERROR_TXN_OPEN, -29003). % Transaction already active on this port
-define(ERROR_NO_TXN, -29004). % No transaction open on this port
-define(ERROR_CURSOR_OPEN, -29005). % Cursor already active on this port
-define(ERROR_NO_CURSOR, -29006). % No cursor open on this port
-define(ERROR_DB_ACTIVE, -29007). % Database is currently active; operation requires otherwise
-define(ERROR_INVALID_CMD, -29008). % Invalid command
-define(ERROR_INVALID_DB_TYPE,-29009). % Invalid database type
%% DB (user visible) error return codes.
-define(DB_BUFFER_SMALL, -30999). % User memory too small for return
-define(DB_DONOTINDEX, -30998). % "Null" return from 2ndary callbk
-define(DB_FOREIGN_CONFLICT, -30997). % A foreign db constraint triggered
-define(DB_KEYEMPTY, -30996). % Key/data deleted or never created
-define(DB_KEYEXIST, -30995). % The key/data pair already exists
-define(DB_LOCK_DEADLOCK, -30994). % Deadlock occurred
-define(DB_LOCK_NOTGRANTED, -30993). % Lock unavailable
-define(DB_LOG_BUFFER_FULL, -30992). % In-memory log buffer full
-define(DB_NOSERVER, -30991). % Server panic return
-define(DB_NOSERVER_HOME, -30990). % Bad home sent to server
-define(DB_NOSERVER_ID, -30989). % Bad ID sent to server
-define(DB_NOTFOUND, -30988). % Key/data pair not found (EOF)
-define(DB_OLD_VERSION, -30987). % Out-of-date version
-define(DB_PAGE_NOTFOUND, -30986). % Requested page not found
-define(DB_REP_DUPMASTER, -30985). % There are two masters
-define(DB_REP_HANDLE_DEAD, -30984). % Rolled back a commit
-define(DB_REP_HOLDELECTION, -30983). % Time to hold an election
-define(DB_REP_IGNORE, -30982). % This msg should be ignored
-define(DB_REP_ISPERM, -30981). % Cached not written perm written
-define(DB_REP_JOIN_FAILURE, -30980). % Unable to join replication group
-define(DB_REP_LEASE_EXPIRED, -30979). % Master lease has expired
-define(DB_REP_LOCKOUT, -30978). % API/Replication lockout now
-define(DB_REP_NEWSITE, -30977). % New site entered system
-define(DB_REP_NOTPERM, -30976). % Permanent log record not written
-define(DB_REP_UNAVAIL, -30975). % Site cannot currently be reached
-define(DB_RUNRECOVERY, -30974). % Panic return
-define(DB_SECONDARY_BAD, -30973). % Secondary index corrupt
-define(DB_VERIFY_BAD, -30972). % Verify failed; bad format
-define(DB_VERSION_MISMATCH, -30971). % Environment version mismatch
%% DB (public, user visible) error return codes.
-define(DB_BUFFER_SMALL, -30999). % User memory too small for return.
-define(DB_DONOTINDEX, -30998). % "Null" return from 2ndary callbk.
-define(DB_FOREIGN_CONFLICT, -30997). % A foreign db constraint triggered.
-define(DB_HEAP_FULL, -30996). % No free space in a heap file.
-define(DB_KEYEMPTY, -30995). % Key/data deleted or never created.
-define(DB_KEYEXIST, -30994). % The key/data pair already exists.
-define(DB_LOCK_DEADLOCK, -30993). % Deadlock.
-define(DB_LOCK_NOTGRANTED, -30992). % Lock unavailable.
-define(DB_LOG_BUFFER_FULL, -30991). % In-memory log buffer full.
-define(DB_LOG_VERIFY_BAD, -30990). % Log verification failed.
-define(DB_NOSERVER, -30989). % Server panic return.
-define(DB_NOTFOUND, -30988). % Key/data pair not found (EOF).
-define(DB_OLD_VERSION, -30987). % Out-of-date version.
-define(DB_PAGE_NOTFOUND, -30986). % Requested page not found.
-define(DB_REP_DUPMASTER, -30985). % There are two masters.
-define(DB_REP_HANDLE_DEAD, -30984). % Rolled back a commit.
-define(DB_REP_HOLDELECTION, -30983). % Time to hold an election.
-define(DB_REP_IGNORE, -30982). % This msg should be ignored
-define(DB_REP_ISPERM, -30981). % Cached not written perm written
-define(DB_REP_JOIN_FAILURE, -30980). % Unable to join replication group.
-define(DB_REP_LEASE_EXPIRED, -30979). % Master lease has expired.
-define(DB_REP_LOCKOUT, -30978). % API/Replication lockout now.
-define(DB_REP_NEWSITE, -30977). % New site entered system.
-define(DB_REP_NOTPERM, -30976). % Permanent log record not written.
-define(DB_REP_UNAVAIL, -30975). % Site cannot currently be reached.
-define(DB_REP_WOULDROLLBACK, -30974). % UNDOC: rollback inhibited by app.
-define(DB_RUNRECOVERY, -30973). % Panic return.
-define(DB_SECONDARY_BAD, -30972). % Secondary index corrupt.
-define(DB_TIMEOUT, -30971). % Timed out on read consistency.
-define(DB_VERIFY_BAD, -30970). % Verify failed; bad format.
-define(DB_VERSION_MISMATCH, -30969). % Environment version mismatch.
%% DB API flags
-define(DB_AGGRESSIVE, 16#00000001).
-define(DB_ARCH_ABS, 16#00000001).
-define(DB_ARCH_DATA, 16#00000002).
-define(DB_ARCH_LOG, 16#00000004).
-define(DB_ARCH_REMOVE, 16#00000008).
-define(DB_AUTO_COMMIT, 16#00000100).
-define(DB_CDB_ALLDB, 16#00000004).
-define(DB_CHKSUM, 16#00000004).
-define(DB_CKP_INTERNAL, 16#00000002).
-define(DB_CREATE, 16#00000001).
-define(DB_CXX_NO_EXCEPTIONS, 16#00000002).
-define(DB_DIRECT, 16#00000002).
-define(DB_DIRECT_DB, 16#00000040).
-define(DB_DSYNC_DB, 16#00000080).
-define(DB_DUP, 16#00000008).
-define(DB_DUPSORT, 16#00000002).
-define(DB_DURABLE_UNKNOWN, 16#00000020).
-define(DB_ENCRYPT, 16#00000001).
-define(DB_ENCRYPT_AES, 16#00000001).
-define(DB_EXCL, 16#00000400).
-define(DB_EXTENT, 16#00000004).
-define(DB_FAST_STAT, 16#00000001).
-define(DB_FCNTL_LOCKING, 16#00001000).
-define(DB_FLUSH, 16#00000001).
-define(DB_FORCE, 16#00000001).
-define(DB_FOREIGN_ABORT, 16#00000001).
-define(DB_FOREIGN_CASCADE, 16#00000002).
-define(DB_FOREIGN_NULLIFY, 16#00000004).
-define(DB_FREELIST_ONLY, 16#00000001).
-define(DB_FREE_SPACE, 16#00000002).
-define(DB_IGNORE_LEASE, 16#00001000).
-define(DB_IMMUTABLE_KEY, 16#00000002).
-define(DB_INIT_CDB, 16#00000020).
-define(DB_INIT_LOCK, 16#00000040).
-define(DB_INIT_LOG, 16#00000080).
-define(DB_INIT_MPOOL, 16#00000100).
-define(DB_INIT_REP, 16#00000200).
-define(DB_INIT_TXN, 16#00000400).
-define(DB_INORDER, 16#00000010).
-define(DB_JOIN_NOSORT, 16#00000001).
-define(DB_LOCKDOWN, 16#00000800).
-define(DB_LOCK_NOWAIT, 16#00000001).
-define(DB_LOCK_RECORD, 16#00000002).
-define(DB_LOCK_SET_TIMEOUT, 16#00000004).
-define(DB_LOCK_SWITCH, 16#00000008).
-define(DB_LOCK_UPGRADE, 16#00000010).
-define(DB_LOG_AUTO_REMOVE, 16#00000004).
-define(DB_LOG_CHKPNT, 16#00000002).
-define(DB_LOG_COMMIT, 16#00000004).
-define(DB_LOG_DIRECT, 16#00000001).
-define(DB_LOG_DSYNC, 16#00000002).
-define(DB_LOG_IN_MEMORY, 16#00000008).
-define(DB_LOG_NOCOPY, 16#00000008).
-define(DB_LOG_NOT_DURABLE, 16#00000010).
-define(DB_LOG_WRNOSYNC, 16#00000020).
-define(DB_LOG_ZERO, 16#00000010).
-define(DB_MPOOL_CREATE, 16#00000001).
-define(DB_MPOOL_DIRTY, 16#00000002).
-define(DB_MPOOL_DISCARD, 16#00000001).
-define(DB_MPOOL_EDIT, 16#00000004).
-define(DB_MPOOL_FREE, 16#00000008).
-define(DB_MPOOL_LAST, 16#00000010).
-define(DB_MPOOL_NEW, 16#00000020).
-define(DB_MPOOL_NOFILE, 16#00000001).
-define(DB_MPOOL_NOLOCK, 16#00000002).
-define(DB_MPOOL_UNLINK, 16#00000002).
-define(DB_MULTIPLE, 16#00002000).
-define(DB_MULTIPLE_KEY, 16#00000100).
-define(DB_MULTIVERSION, 16#00000008).
-define(DB_MUTEX_ALLOCATED, 16#00000001).
-define(DB_MUTEX_LOCKED, 16#00000002).
-define(DB_MUTEX_LOGICAL_LOCK, 16#00000004).
-define(DB_MUTEX_PROCESS_ONLY, 16#00000008).
-define(DB_MUTEX_SELF_BLOCK, 16#00000010).
-define(DB_NOLOCKING, 16#00000200).
-define(DB_NOMMAP, 16#00000010).
-define(DB_NOORDERCHK, 16#00000002).
-define(DB_NOPANIC, 16#00000400).
-define(DB_NO_AUTO_COMMIT, 16#00002000).
-define(DB_ODDFILESIZE, 16#00000040).
-define(DB_ORDERCHKONLY, 16#00000004).
-define(DB_OVERWRITE, 16#00001000).
-define(DB_PANIC_ENVIRONMENT, 16#00002000).
-define(DB_PRINTABLE, 16#00000008).
-define(DB_PRIVATE, 16#00001000).
-define(DB_PR_PAGE, 16#00000010).
-define(DB_PR_RECOVERYTEST, 16#00000020).
-define(DB_RDONLY, 16#00000080).
-define(DB_RDWRMASTER, 16#00004000).
-define(DB_READ_COMMITTED, 16#00000400).
-define(DB_READ_UNCOMMITTED, 16#00000200).
-define(DB_RECNUM, 16#00000020).
-define(DB_RECOVER, 16#00000010).
-define(DB_RECOVER_FATAL, 16#00002000).
-define(DB_REGION_INIT, 16#00004000).
-define(DB_REGISTER, 16#00004000).
-define(DB_RENUMBER, 16#00000040).
-define(DB_REPMGR_CONF_2SITE_STRICT, 16#00000001).
-define(DB_REPMGR_PEER, 16#00000001).
-define(DB_REP_ANYWHERE, 16#00000001).
-define(DB_REP_CLIENT, 16#00000001).
-define(DB_REP_CONF_BULK, 16#00000002).
-define(DB_REP_CONF_DELAYCLIENT, 16#00000004).
-define(DB_REP_CONF_LEASE, 16#00000008).
-define(DB_REP_CONF_NOAUTOINIT, 16#00000010).
-define(DB_REP_CONF_NOWAIT, 16#00000020).
-define(DB_REP_ELECTION, 16#00000004).
-define(DB_REP_MASTER, 16#00000002).
-define(DB_REP_NOBUFFER, 16#00000002).
-define(DB_REP_PERMANENT, 16#00000004).
-define(DB_REP_REREQUEST, 16#00000008).
-define(DB_REVSPLITOFF, 16#00000080).
-define(DB_RMW, 16#00000800).
-define(DB_RPCCLIENT, 16#00000001).
-define(DB_SALVAGE, 16#00000040).
-define(DB_SA_SKIPFIRSTKEY, 16#00010000).
-define(DB_SEQ_DEC, 16#00000001).
-define(DB_SEQ_INC, 16#00000002).
-define(DB_SEQ_RANGE_SET, 16#00000004).
-define(DB_SEQ_WRAP, 16#00000008).
-define(DB_SEQ_WRAPPED, 16#00000010).
-define(DB_SET_LOCK_TIMEOUT, 16#00000002).
-define(DB_SET_TXN_NOW, 16#00000004).
-define(DB_SET_TXN_TIMEOUT, 16#00000001).
-define(DB_SNAPSHOT, 16#00000100).
-define(DB_STAT_ALL, 16#00000002).
-define(DB_STAT_CLEAR, 16#00000001).
-define(DB_STAT_LOCK_CONF, 16#00000004).
-define(DB_STAT_LOCK_LOCKERS, 16#00000008).
-define(DB_STAT_LOCK_OBJECTS, 16#00000010).
-define(DB_STAT_LOCK_PARAMS, 16#00000020).
-define(DB_STAT_MEMP_HASH, 16#00000004).
-define(DB_STAT_MEMP_NOERROR, 16#00000008).
-define(DB_STAT_SUBSYSTEM, 16#00000004).
-define(DB_ST_DUPOK, 16#00000100).
-define(DB_ST_DUPSET, 16#00000200).
-define(DB_ST_DUPSORT, 16#00000400).
-define(DB_ST_IS_RECNO, 16#00000800).
-define(DB_ST_OVFL_LEAF, 16#00001000).
-define(DB_ST_RECNUM, 16#00002000).
-define(DB_ST_RELEN, 16#00004000).
-define(DB_ST_TOPLEVEL, 16#00008000).
-define(DB_SYSTEM_MEM, 16#00008000).
-define(DB_THREAD, 16#00000004).
-define(DB_TIME_NOTGRANTED, 16#00008000).
-define(DB_TRUNCATE, 16#00008000).
-define(DB_TXN_NOSYNC, 16#00000001).
-define(DB_TXN_NOT_DURABLE, 16#00000200).
-define(DB_TXN_NOWAIT, 16#00000002).
-define(DB_TXN_SNAPSHOT, 16#00000800).
-define(DB_TXN_SYNC, 16#00000004).
-define(DB_TXN_WAIT, 16#00000008).
-define(DB_TXN_WRITE_NOSYNC, 16#00000020).
-define(DB_UNREF, 16#00000080).
-define(DB_UPGRADE, 16#00000001).
-define(DB_USE_ENVIRON, 16#00000002).
-define(DB_USE_ENVIRON_ROOT, 16#00000008).
-define(DB_VERB_DEADLOCK, 16#00000001).
-define(DB_VERB_FILEOPS, 16#00000002).
-define(DB_VERB_FILEOPS_ALL, 16#00000004).
-define(DB_VERB_RECOVERY, 16#00000008).
-define(DB_VERB_REGISTER, 16#00000010).
-define(DB_VERB_REPLICATION, 16#00000020).
-define(DB_VERB_REPMGR_CONNFAIL, 16#00000040).
-define(DB_VERB_REPMGR_MISC, 16#00000080).
-define(DB_VERB_REP_ELECT, 16#00000100).
-define(DB_VERB_REP_LEASE, 16#00000200).
-define(DB_VERB_REP_MISC, 16#00000400).
-define(DB_VERB_REP_MSGS, 16#00000800).
-define(DB_VERB_REP_SYNC, 16#00001000).
-define(DB_VERB_WAITSFOR, 16#00002000).
-define(DB_VERIFY, 16#00000002).
-define(DB_WRITEOPEN, 16#00010000).
-define(DB_XA_CREATE, 16#00000800).
-define(DB_YIELDCPU, 16#00010000).
-define(DB_AGGRESSIVE, 16#00000001).
-define(DB_ARCH_ABS, 16#00000001).
-define(DB_ARCH_DATA, 16#00000002).
-define(DB_ARCH_LOG, 16#00000004).
-define(DB_ARCH_REMOVE, 16#00000008).
-define(DB_AUTO_COMMIT, 16#00000100).
-define(DB_BOOTSTRAP_HELPER, 16#00000001).
-define(DB_CDB_ALLDB, 16#00000040).
-define(DB_CHKSUM, 16#00000008).
-define(DB_CKP_INTERNAL, 16#00000002).
-define(DB_CREATE, 16#00000001).
-define(DB_CURSOR_BULK, 16#00000001).
-define(DB_CURSOR_TRANSIENT, 16#00000004).
-define(DB_CXX_NO_EXCEPTIONS, 16#00000002).
-define(DB_DATABASE_LOCKING, 16#00000080).
-define(DB_DIRECT, 16#00000010).
-define(DB_DIRECT_DB, 16#00000200).
-define(DB_DSYNC_DB, 16#00000400).
-define(DB_DUP, 16#00000010).
-define(DB_DUPSORT, 16#00000004).
-define(DB_DURABLE_UNKNOWN, 16#00000020).
-define(DB_ENCRYPT, 16#00000001).
-define(DB_ENCRYPT_AES, 16#00000001).
-define(DB_EXCL, 16#00000040).
-define(DB_EXTENT, 16#00000040).
-define(DB_FAILCHK, 16#00000020).
-define(DB_FAILCHK_ISALIVE, 16#00000040).
-define(DB_FAST_STAT, 16#00000001).
-define(DB_FCNTL_LOCKING, 16#00000800).
-define(DB_FLUSH, 16#00000001).
-define(DB_FORCE, 16#00000001).
-define(DB_FORCESYNC, 16#00000001).
-define(DB_FOREIGN_ABORT, 16#00000001).
-define(DB_FOREIGN_CASCADE, 16#00000002).
-define(DB_FOREIGN_NULLIFY, 16#00000004).
-define(DB_FREELIST_ONLY, 16#00000001).
-define(DB_FREE_SPACE, 16#00000002).
-define(DB_GROUP_CREATOR, 16#00000002).
-define(DB_HOTBACKUP_IN_PROGRESS, 16#00000800).
-define(DB_IGNORE_LEASE, 16#00001000).
-define(DB_IMMUTABLE_KEY, 16#00000002).
-define(DB_INIT_CDB, 16#00000080).
-define(DB_INIT_LOCK, 16#00000100).
-define(DB_INIT_LOG, 16#00000200).
-define(DB_INIT_MPOOL, 16#00000400).
-define(DB_INIT_MUTEX, 16#00000800).
-define(DB_INIT_REP, 16#00001000).
-define(DB_INIT_TXN, 16#00002000).
-define(DB_INORDER, 16#00000020).
-define(DB_INTERNAL_DB, 16#00001000).
-define(DB_JOIN_NOSORT, 16#00000001).
-define(DB_LEGACY, 16#00000004).
-define(DB_LOCAL_SITE, 16#00000008).
-define(DB_LOCKDOWN, 16#00004000).
-define(DB_LOCK_CHECK, 16#00000001).
-define(DB_LOCK_NOWAIT, 16#00000002).
-define(DB_LOCK_RECORD, 16#00000004).
-define(DB_LOCK_SET_TIMEOUT, 16#00000008).
-define(DB_LOCK_SWITCH, 16#00000010).
-define(DB_LOCK_UPGRADE, 16#00000020).
-define(DB_LOG_AUTO_REMOVE, 16#00000001).
-define(DB_LOG_CHKPNT, 16#00000002).
-define(DB_LOG_COMMIT, 16#00000004).
-define(DB_LOG_DIRECT, 16#00000002).
-define(DB_LOG_DSYNC, 16#00000004).
-define(DB_LOG_IN_MEMORY, 16#00000008).
-define(DB_LOG_NOCOPY, 16#00000008).
-define(DB_LOG_NOT_DURABLE, 16#00000010).
-define(DB_LOG_NO_DATA, 16#00000004).
-define(DB_LOG_VERIFY_CAF, 16#00000001).
-define(DB_LOG_VERIFY_DBFILE, 16#00000002).
-define(DB_LOG_VERIFY_ERR, 16#00000004).
-define(DB_LOG_VERIFY_FORWARD, 16#00000008).
-define(DB_LOG_VERIFY_INTERR, 16#00000010).
-define(DB_LOG_VERIFY_PARTIAL, 16#00000020).
-define(DB_LOG_VERIFY_VERBOSE, 16#00000040).
-define(DB_LOG_VERIFY_WARNING, 16#00000080).
-define(DB_LOG_WRNOSYNC, 16#00000020).
-define(DB_LOG_ZERO, 16#00000010).
-define(DB_MPOOL_CREATE, 16#00000001).
-define(DB_MPOOL_DIRTY, 16#00000002).
-define(DB_MPOOL_DISCARD, 16#00000001).
-define(DB_MPOOL_EDIT, 16#00000004).
-define(DB_MPOOL_FREE, 16#00000008).
-define(DB_MPOOL_LAST, 16#00000010).
-define(DB_MPOOL_NEW, 16#00000020).
-define(DB_MPOOL_NOFILE, 16#00000001).
-define(DB_MPOOL_NOLOCK, 16#00000002).
-define(DB_MPOOL_TRY, 16#00000040).
-define(DB_MPOOL_UNLINK, 16#00000002).
-define(DB_MULTIPLE, 16#00000800).
-define(DB_MULTIPLE_KEY, 16#00004000).
-define(DB_MULTIVERSION, 16#00000004).
-define(DB_MUTEX_ALLOCATED, 16#00000001).
-define(DB_MUTEX_LOCKED, 16#00000002).
-define(DB_MUTEX_LOGICAL_LOCK, 16#00000004).
-define(DB_MUTEX_PROCESS_ONLY, 16#00000008).
-define(DB_MUTEX_SELF_BLOCK, 16#00000010).
-define(DB_MUTEX_SHARED, 16#00000020).
-define(DB_NOERROR, 16#00002000).
-define(DB_NOFLUSH, 16#00001000).
-define(DB_NOLOCKING, 16#00002000).
-define(DB_NOMMAP, 16#00000008).
-define(DB_NOORDERCHK, 16#00000002).
-define(DB_NOPANIC, 16#00004000).
-define(DB_NOSYNC, 16#00000001).
-define(DB_NO_AUTO_COMMIT, 16#00004000).
-define(DB_NO_CHECKPOINT, 16#00008000).
-define(DB_ODDFILESIZE, 16#00000080).
-define(DB_ORDERCHKONLY, 16#00000004).
-define(DB_OVERWRITE, 16#00008000).
-define(DB_PANIC_ENVIRONMENT, 16#00010000).
-define(DB_PRINTABLE, 16#00000008).
-define(DB_PRIVATE, 16#00010000).
-define(DB_PR_PAGE, 16#00000010).
-define(DB_PR_RECOVERYTEST, 16#00000020).
-define(DB_RDONLY, 16#00000400).
-define(DB_RDWRMASTER, 16#00008000).
-define(DB_READ_COMMITTED, 16#00000400).
-define(DB_READ_UNCOMMITTED, 16#00000200).
-define(DB_RECNUM, 16#00000040).
-define(DB_RECOVER, 16#00000002).
-define(DB_RECOVER_FATAL, 16#00020000).
-define(DB_REGION_INIT, 16#00020000).
-define(DB_REGISTER, 16#00040000).
-define(DB_RENUMBER, 16#00000080).
-define(DB_REPMGR_CONF_2SITE_STRICT, 16#00000001).
-define(DB_REPMGR_CONF_ELECTIONS, 16#00000002).
-define(DB_REPMGR_NEED_RESPONSE, 16#00000001).
-define(DB_REPMGR_PEER, 16#00000010).
-define(DB_REP_ANYWHERE, 16#00000001).
-define(DB_REP_CLIENT, 16#00000001).
-define(DB_REP_CONF_AUTOINIT, 16#00000004).
-define(DB_REP_CONF_AUTOROLLBACK, 16#00000008).
-define(DB_REP_CONF_BULK, 16#00000010).
-define(DB_REP_CONF_DELAYCLIENT, 16#00000020).
-define(DB_REP_CONF_INMEM, 16#00000040).
-define(DB_REP_CONF_LEASE, 16#00000080).
-define(DB_REP_CONF_NOWAIT, 16#00000100).
-define(DB_REP_ELECTION, 16#00000004).
-define(DB_REP_MASTER, 16#00000002).
-define(DB_REP_NOBUFFER, 16#00000002).
-define(DB_REP_PERMANENT, 16#00000004).
-define(DB_REP_REREQUEST, 16#00000008).
-define(DB_REVSPLITOFF, 16#00000100).
-define(DB_RMW, 16#00002000).
-define(DB_SALVAGE, 16#00000040).
-define(DB_SA_SKIPFIRSTKEY, 16#00000080).
-define(DB_SA_UNKNOWNKEY, 16#00000100).
-define(DB_SEQ_DEC, 16#00000001).
-define(DB_SEQ_INC, 16#00000002).
-define(DB_SEQ_RANGE_SET, 16#00000004).
-define(DB_SEQ_WRAP, 16#00000008).
-define(DB_SEQ_WRAPPED, 16#00000010).
-define(DB_SET_LOCK_TIMEOUT, 16#00000001).
-define(DB_SET_REG_TIMEOUT, 16#00000004).
-define(DB_SET_TXN_NOW, 16#00000008).
-define(DB_SET_TXN_TIMEOUT, 16#00000002).
-define(DB_SHALLOW_DUP, 16#00000100).
-define(DB_SNAPSHOT, 16#00000200).
-define(DB_STAT_ALL, 16#00000004).
-define(DB_STAT_ALLOC, 16#00000008).
-define(DB_STAT_CLEAR, 16#00000001).
-define(DB_STAT_LOCK_CONF, 16#00000010).
-define(DB_STAT_LOCK_LOCKERS, 16#00000020).
-define(DB_STAT_LOCK_OBJECTS, 16#00000040).
-define(DB_STAT_LOCK_PARAMS, 16#00000080).
-define(DB_STAT_MEMP_HASH, 16#00000010).
-define(DB_STAT_MEMP_NOERROR, 16#00000020).
-define(DB_STAT_SUBSYSTEM, 16#00000002).
-define(DB_STAT_SUMMARY, 16#00000010).
-define(DB_ST_DUPOK, 16#00000200).
-define(DB_ST_DUPSET, 16#00000400).
-define(DB_ST_DUPSORT, 16#00000800).
-define(DB_ST_IS_RECNO, 16#00001000).
-define(DB_ST_OVFL_LEAF, 16#00002000).
-define(DB_ST_RECNUM, 16#00004000).
-define(DB_ST_RELEN, 16#00008000).
-define(DB_ST_TOPLEVEL, 16#00010000).
-define(DB_SYSTEM_MEM, 16#00080000).
-define(DB_THREAD, 16#00000010).
-define(DB_TIME_NOTGRANTED, 16#00040000).
-define(DB_TRUNCATE, 16#00010000).
-define(DB_TXN_BULK, 16#00000008).
-define(DB_TXN_FAMILY, 16#00000040).
-define(DB_TXN_NOSYNC, 16#00000001).
-define(DB_TXN_NOT_DURABLE, 16#00000002).
-define(DB_TXN_NOWAIT, 16#00000002).
-define(DB_TXN_SNAPSHOT, 16#00000010).
-define(DB_TXN_SYNC, 16#00000004).
-define(DB_TXN_WAIT, 16#00000080).
-define(DB_TXN_WRITE_NOSYNC, 16#00000020).
-define(DB_UNREF, 16#00020000).
-define(DB_UPGRADE, 16#00000001).
-define(DB_USE_ENVIRON, 16#00000004).
-define(DB_USE_ENVIRON_ROOT, 16#00000008).
-define(DB_VERB_DEADLOCK, 16#00000001).
-define(DB_VERB_FILEOPS, 16#00000002).
-define(DB_VERB_FILEOPS_ALL, 16#00000004).
-define(DB_VERB_RECOVERY, 16#00000008).
-define(DB_VERB_REGISTER, 16#00000010).
-define(DB_VERB_REPLICATION, 16#00000020).
-define(DB_VERB_REPMGR_CONNFAIL, 16#00000040).
-define(DB_VERB_REPMGR_MISC, 16#00000080).
-define(DB_VERB_REP_ELECT, 16#00000100).
-define(DB_VERB_REP_LEASE, 16#00000200).
-define(DB_VERB_REP_MISC, 16#00000400).
-define(DB_VERB_REP_MSGS, 16#00000800).
-define(DB_VERB_REP_SYNC, 16#00001000).
-define(DB_VERB_REP_SYSTEM, 16#00002000).
-define(DB_VERB_REP_TEST, 16#00004000).
-define(DB_VERB_WAITSFOR, 16#00008000).
-define(DB_VERIFY, 16#00000002).
-define(DB_VERIFY_PARTITION, 16#00040000).
-define(DB_WRITECURSOR, 16#00000008).
-define(DB_WRITELOCK, 16#00000020).
-define(DB_WRITEOPEN, 16#00020000).
-define(DB_XA_CREATE, 16#00000001).
-define(DB_YIELDCPU, 16#00080000).
%% DB access method and cursor operation values. Each value is an operation
%% code to which additional bit flags are added.
@ -317,7 +369,7 @@
-define(DB_NEXT_NODUP, 18).
-define(DB_NODUPDATA, 19).
-define(DB_NOOVERWRITE, 20).
-define(DB_NOSYNC, 21).
-define(DB_OVERWRITE_DUP, 21).
-define(DB_POSITION, 22).
-define(DB_PREV, 23).
-define(DB_PREV_DUP, 24).
@ -326,5 +378,5 @@
-define(DB_SET_RANGE, 27).
-define(DB_SET_RECNO, 28).
-define(DB_UPDATE_SECONDARY, 29).
-define(DB_WRITECURSOR, 30).
-define(DB_WRITELOCK, 31).
-define(DB_SET_LTE, 30).
-define(DB_GET_BOTH_LTE, 31).

40
rebar.config Normal file
View file

@ -0,0 +1,40 @@
%% Linked-in driver config
%%
%% -*- tab-width: 4;erlang-indent-level: 4;indent-tabs-mode: nil -*-
%% ex: ft=erlang ts=4 sw=4 et
%%
{cover_enabled, true}.
{erl_opts, [warnings_as_errors]}.
{port_envs, [
{"DRV_CFLAGS", "$DRV_CFLAGS -Werror -I c_src/system/include"},
{"DRV_LDFLAGS", "$DRV_LDFLAGS c_src/system/lib/libdb.a"},
%% Solaris specific flags
{"solaris.*-64$", "CFLAGS", "-D_REENTRANT -m64"},
{"solaris.*-64$", "LDFLAGS", "-m64"},
%% OS X Leopard flags for 64-bit
{"darwin9.*-64$", "CFLAGS", "-m64"},
{"darwin9.*-64$", "LDFLAGS", "-arch x86_64"},
%% OS X Snow Leopard flags for 32-bit
{"darwin10.*-32$", "CFLAGS", "-m32"},
{"darwin10.*-32$", "LDFLAGS", "-arch i386"},
%% OS X Snow Leopard flags for 64-bit
{"darwin10.*-64$", "CFLAGS", "-m64"},
{"darwin10.*-64$", "LDFLAGS", "-arch x86_64"},
%% OS X Lion flags for 32-bit
{"darwin11.*-32$", "CFLAGS", "-m32"},
{"darwin11.*-32$", "LDFLAGS", "-arch i386"},
%% OS X Lion flags for 64-bit
{"darwin11.*-64$", "CFLAGS", "-m64"},
{"darwin11.*-64$", "LDFLAGS", "-arch x86_64"}
]}.
{pre_hooks, [{compile, "make -C c_src"}]}.
{post_hooks, [{clean, "make -C c_src clean"}]}.

38
rebar.mk Normal file
View file

@ -0,0 +1,38 @@
REBAR_URL ?= http://github.com/downloads/basho/rebar/rebar
REBAR_GLOBAL ?= $(shell which rebar)
REBAR_LOCAL ?= $(shell which ./rebar)
REBAR_TARGET ?= $(dir $(shell which escript))
ifneq ($(strip $(REBAR_LOCAL)), )
REBAR ?= $(REBAR_LOCAL)
else ifneq ($(strip $(REBAR_GLOBAL)), )
REBAR ?= $(REBAR_GLOBAL)
else
REBAR ?= rebar
$(warning Rebar not installed or available. Try 'make rebar-info')
endif
ifneq ($(strip $(shell which wget)), )
REBAR_FETCH ?= wget --no-check-certificate -q -O - $(REBAR_URL)
else
REBAR_FETCH ?= curl -s -f $(REBAR_URL)
endif
rebar-info:
@echo "Rebar needs to be either on your path or present in the current" \
"working directory:\n" \
"* 'make rebar-install' will download and install it into your Erlang path (RECOMMENDED)\n" \
"* 'make rebar-get' will download it to your current working directory\n" \
rebar-install:
$(REBAR_FETCH) > $(REBAR_TARGET)/rebar
chmod a+x $(REBAR_TARGET)/rebar
rebar-get:
$(REBAR_FETCH) > ./rebar
chmod u+x ./rebar

View file

@ -2,6 +2,10 @@
[
{description, "This is an Erlang port driver that allows Erlang programs to store data in BerkleyDB."},
{vsn, "5.1.28"},
{applications, [kernel, stdlib]}
]
}.
{registered, []},
{applications, [
kernel,
stdlib
]},
{env, []}
]}.

View file

@ -8,6 +8,10 @@
%% @author Jon Meredith <jon@jonmeredith.com>
%% @end
%%
%% @copyright 2011 Basho Technologies http://www.basho.com/
%% @author Greg Burd <greg@basho.com>
%% @end
%%
%% Permission is hereby granted, free of charge, to any person obtaining a copy
%% of this software and associated documentation files (the "Software"), to deal
%% in the Software without restriction, including without limitation the rights
@ -2189,7 +2193,6 @@ flag_value(Flag) ->
no_duplicate -> ?DB_NODUPDATA;
no_mmap -> ?DB_NOMMAP;
no_overwrite -> ?DB_NOOVERWRITE;
no_sync -> ?DB_NOSYNC;
read_committed -> ?DB_READ_COMMITTED;
read_uncommitted -> ?DB_READ_UNCOMMITTED;
readonly -> ?DB_RDONLY;

View file

@ -1,7 +1,16 @@
%% -------------------------------------------------------------------
%%
%% bdberl: DB API Tests
%% Copyright (c) 2008 The Hive. All rights reserved.
%%
%% @copyright 2008-9 The Hive http://www.thehive.com/
%% @author Dave "dizzyd" Smith <dizzyd@dizzyd.com>
%% @author Phil Toland <phil.toland@gmail.com>
%% @author Jon Meredith <jon@jonmeredith.com>
%% @end
%%
%% @copyright 2011 Basho Technologies http://www.basho.com/
%% @author Greg Burd <greg@basho.com>
%% @end
%%
%% Permission is hereby granted, free of charge, to any person obtaining a copy
%% of this software and associated documentation files (the "Software"), to deal
@ -26,7 +35,7 @@
-compile(export_all).
-include_lib("ct.hrl").
-include_lib("common_test/include/ct.hrl").
all() ->
[open_should_create_database_if_none_exists,