Merge branch 'master' of git://github.com/kpy3/bdberl into merge-changes-from-kpy3

Conflicts:
	Makefile
	c_src/buildlib.sh
	include/bdberl.hrl
	int_test/DB_CONFIG
	rebar
	rebar.config
	test/bdberl_SUITE.erl
This commit is contained in:
Gregory Burd 2011-11-28 12:37:59 -05:00
commit db1eb122c6
17 changed files with 283 additions and 165 deletions

2
.gitignore vendored
View file

@ -4,6 +4,7 @@
*.o
*.so
*.beam
*.orig
logs
doc
test/test.cover
@ -14,3 +15,4 @@ priv/mibs
c_src/system
c_src/db-*
c_src/db-*.tar.gz
.eunit

View file

@ -1,13 +1,25 @@
all: compile
compile:
@ $(REBAR) compile
ERL ?=erl
ERL_FLAGS ?=+A10
REBAR_FLAGS :=
all: $(BDB_LOCAL_LIB)
ERL_FLAGS=$(ERL_FLAGS) $(REBAR) $(REBAR_FLAGS) compile
test: tests
tests:
@ $(REBAR) ct
@ $(REBAR) $(REBAR_FLAGS) eunit ct
clean:
@ $(REBAR) clean
@ rm -rf ./logs
$(REBAR) $(REBAR_FLAGS) clean
-rm test/*.beam
distclean: clean
-rm -rf $(BDB_LOCAL_DIST)
-rm -rf c_src/sources
-rm -rf priv
-rm -rf logs
include rebar.mk
include rebar.mk

1
README
View file

@ -4,3 +4,4 @@ Authors:
Dave "dizzyd" Smith <dizzyd@dizzyd.com>
Phil Toland <phil.toland@gmail.com>
Jon Meredith <jon@jonmeredith.com>
Sergey Yelin <elinsn@gmail.com>

View file

@ -1,9 +1,13 @@
# This Makefile builds the dependency (libdb) needed by bdberl_drv.so
ERL ?=erl
ERL_FLAGS ?=+A10
TAR ?= tar
GUNZIP ?= gunzip
BDB_VER := 5.2.28
BDB_VER := 5.2.36
BDB_DIR := $(CURDIR)/db-$(BDB_VER)
BDB_DIST := db-$(BDB_VER).tar.gz
BDB_DIST_URL := http://download.oracle.com/berkeley-db/$(BDB_DIST)
SYSTEM_DIR := $(CURDIR)/system
LIB_DIR := $(SYSTEM_DIR)/lib
@ -12,7 +16,7 @@ INC_DIR := $(SYSTEM_DIR)/include
db: $(LIB_DIR)/libdb.a
$(LIB_DIR)/libdb.a:
$(LIB_DIR)/libdb.a: $(BDB_DIST)
$(GUNZIP) -c db-$(BDB_VER).tar.gz | $(TAR) xf -
@for I in patches/*.patch; do \
(patch -p0 < $${I} || echo "Skipping patch"); \
@ -21,6 +25,9 @@ $(LIB_DIR)/libdb.a:
@$(MAKE) -C $(BDB_DIR)/build_unix install
clean:
@rm -rf $(SYSTEM_DIR) $(BDB_DIR)
@rm -rf ./*.o $(SYSTEM_DIR) $(BDB_DIR)
$(BDB_DIST):
$(REBAR_FETCH) $(BDB_DIST_URL)
.EXPORT_ALL_VARIABLES:

View file

@ -88,6 +88,8 @@
*/
#define DB_TYPE_BTREE DB_BTREE /* 1 */
#define DB_TYPE_HASH DB_HASH /* 2 */
#define DB_TYPE_RECNO DB_RECNO /* 3 */
#define DB_TYPE_QUEUE DB_QUEUE /* 4 */
/**
* Error codes -- chosen so that we do not conflict with other packages, particularly

30
c_src/buildlib.sh Executable file
View file

@ -0,0 +1,30 @@
#!/bin/bash
if [ `basename $PWD` != "c_src" ]; then
pushd c_src
fi
BASEDIR="$PWD"
WORKDIR=$BASEDIR/system
TARGETDIR=$BASEDIR/../priv
## Check for necessary tarball
if [ ! -f "db-${BDB_VERSION}.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-${BDB_VERSION}
## Untar and build everything
tar -xzf db-${BDB_VERSION}.tar.gz && \
##(cd db-${BDB_VERSION} && patch -p0 < ../bdb-align.patch ) && \
(cd db-${BDB_VERSION}/build_unix && \
../dist/configure --prefix=$WORKDIR --disable-shared && make && ranlib libdb-*.a && make install) && \
rm -rf db-${BDB_VERSION}

Binary file not shown.

View file

@ -1,6 +1,24 @@
--- 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 @@
--- db-5.2.36/dist/Makefile.in 2011-09-14 10:30:11.000000000 -0400
+++ db-5.2.36/dist/Makefile.in.patched 2011-11-28 12:15:04.000000000 -0500
@@ -239,7 +239,7 @@
LOG_VRFY_OBJS=\
log_verify@o@ log_verify_util@o@ log_verify_int@o@ \
- log_verify_auto@o@
+ log_verify_auto@o@
MUTEX_OBJS=\
mut_alloc@o@ mut_failchk@o@ mut_method@o@ mut_region@o@ mut_stat@o@
@@ -762,7 +762,7 @@
$(JAVA_EXDIR)/persist/gettingStarted/SimpleStorePut.java \
$(JAVA_EXDIR)/persist/txn/PayloadDataEntity.java \
$(JAVA_EXDIR)/persist/txn/StoreWriter.java \
- $(JAVA_EXDIR)/persist/txn/TxnGuideDPL.java
+ $(JAVA_EXDIR)/persist/txn/TxnGuideDPL.java
SQL_OBJS=\
sqlite3@o@ $(C_OBJS)
@@ -1067,9 +1067,9 @@
# Library and standard utilities install.
##################################################
library_install: install_setup
@ -12,7 +30,7 @@
install_setup:
@test -d $(DESTDIR)$(prefix) || \
@@ -1144,22 +1144,6 @@
@@ -1145,22 +1145,6 @@
$(RM) $$i; \
done)
@ -35,3 +53,21 @@
##################################################
# Remaining standard Makefile targets.
@@ -1335,7 +1319,7 @@
db_repsite: $(DBREPSITE_OBJS) $(DEF_LIB_CXX)
$(CXXLINK) -o $@ \
$(LDFLAGS) $(DBREPSITE_OBJS) $(DEF_LIB_CXX) $(TEST_LIBS) $(LIBS)
- $(POSTLINK) $@
+ $(POSTLINK) $@
db_reptest@o@: $(testdir)/repmgr/db_reptest.c
$(CC) $(CFLAGS) $?
@@ -1349,7 +1333,7 @@
$(CC) $(CFLAGS) $?
DBREPTEST_OBJS=\
db_reptest@o@ reptest_am@o@ reptest_handles@o@ \
- reptest_spawn@o@ reptest_util@o@
+ reptest_spawn@o@ reptest_util@o@
db_reptest: $(DBREPTEST_OBJS) $(DEF_LIB)
$(CCLINK) -o $@ \

View file

@ -31,14 +31,14 @@
%%
%% -------------------------------------------------------------------
-define(CMD_NONE, 0).
-define(CMD_OPEN_DB, 1).
-define(CMD_CLOSE_DB, 2).
-define(CMD_TXN_BEGIN, 3).
-define(CMD_TXN_COMMIT, 4).
-define(CMD_TXN_ABORT, 5).
-define(CMD_GET, 6).
-define(CMD_PUT, 7).
-define(CMD_NONE, 0).
-define(CMD_OPEN_DB, 1).
-define(CMD_CLOSE_DB, 2).
-define(CMD_TXN_BEGIN, 3).
-define(CMD_TXN_COMMIT, 4).
-define(CMD_TXN_ABORT, 5).
-define(CMD_GET, 6).
-define(CMD_PUT, 7).
-define(CMD_DEL, 8).
-define(CMD_GETINFO, 9).
-define(CMD_CURSOR_OPEN, 10).
@ -70,9 +70,11 @@
-define(CMD_LOG_DIR_INFO, 33).
-define(CMD_DRIVER_INFO, 34).
-define(DB_TYPE_BTREE, 1).
-define(DB_TYPE_HASH, 2).
-define(DB_TYPE_UNKNOWN, 6).
-define(DB_TYPE_BTREE, 1).
-define(DB_TYPE_HASH, 2).
-define(DB_TYPE_RECNO, 3).
-define(DB_TYPE_QUEUE, 4).
-define(DB_TYPE_UNKNOWN, 5).
-define(SYSP_CACHESIZE_GET, 1).
-define(SYSP_TXN_TIMEOUT_GET, 2).
@ -82,17 +84,18 @@
-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
-define(ERROR_INVALID_VALUE, -29010). % Invalid CRC-32 on value
%% DB (public, user visible) error return codes.
-define(DB_BUFFER_SMALL, -30999). % User memory too small for return.
@ -128,47 +131,47 @@
-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_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_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_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_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_FAST_STAT, 16#00000001).
-define(DB_FCNTL_LOCKING, 16#00000800).
-define(DB_FLUSH, 16#00000001).
-define(DB_FORCE, 16#00000001).
-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_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_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).
@ -178,7 +181,7 @@
-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_JOIN_NOSORT, 16#00000001).
-define(DB_LEGACY, 16#00000004).
-define(DB_LOCAL_SITE, 16#00000008).
-define(DB_LOCKDOWN, 16#00004000).
@ -189,13 +192,13 @@
-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_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_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).
@ -205,61 +208,61 @@
-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_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_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_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_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_ORDERCHKONLY, 16#00000004).
-define(DB_OVERWRITE, 16#00008000).
-define(DB_PANIC_ENVIRONMENT, 16#00010000).
-define(DB_PRINTABLE, 16#00000008).
-define(DB_PRINTABLE, 16#00000008).
-define(DB_PRIVATE, 16#00010000).
-define(DB_PR_PAGE, 16#00000010).
-define(DB_PR_RECOVERYTEST, 16#00000020).
-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_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_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_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).
@ -267,21 +270,21 @@
-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_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_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_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).
@ -290,7 +293,7 @@
-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_CLEAR, 16#00000001).
-define(DB_STAT_LOCK_CONF, 16#00000010).
-define(DB_STAT_LOCK_LOCKERS, 16#00000020).
-define(DB_STAT_LOCK_OBJECTS, 16#00000040).
@ -313,34 +316,34 @@
-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_NOSYNC, 16#00000001).
-define(DB_TXN_NOT_DURABLE, 16#00000002).
-define(DB_TXN_NOWAIT, 16#00000002).
-define(DB_TXN_NOWAIT, 16#00000002).
-define(DB_TXN_SNAPSHOT, 16#00000010).
-define(DB_TXN_SYNC, 16#00000004).
-define(DB_TXN_SYNC, 16#00000004).
-define(DB_TXN_WAIT, 16#00000080).
-define(DB_TXN_WRITE_NOSYNC, 16#00000020).
-define(DB_TXN_WRITE_NOSYNC, 16#00000020).
-define(DB_UNREF, 16#00020000).
-define(DB_UPGRADE, 16#00000001).
-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_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, 16#00000002).
-define(DB_VERIFY_PARTITION, 16#00040000).
-define(DB_WRITECURSOR, 16#00000008).
-define(DB_WRITELOCK, 16#00000020).
@ -350,34 +353,34 @@
%% DB access method and cursor operation values. Each value is an operation
%% code to which additional bit flags are added.
-define(DB_AFTER, 1).
-define(DB_APPEND, 2).
-define(DB_BEFORE, 3).
-define(DB_CONSUME, 4).
-define(DB_CONSUME_WAIT, 5).
-define(DB_CURRENT, 6).
-define(DB_FIRST, 7).
-define(DB_GET_BOTH, 8).
-define(DB_GET_BOTHC, 9).
-define(DB_GET_BOTH_RANGE, 10).
-define(DB_GET_RECNO, 11).
-define(DB_JOIN_ITEM, 12).
-define(DB_KEYFIRST, 13).
-define(DB_KEYLAST, 14).
-define(DB_LAST, 15).
-define(DB_NEXT, 16).
-define(DB_NEXT_DUP, 17).
-define(DB_NEXT_NODUP, 18).
-define(DB_NODUPDATA, 19).
-define(DB_NOOVERWRITE, 20).
-define(DB_AFTER, 1).
-define(DB_APPEND, 2).
-define(DB_BEFORE, 3).
-define(DB_CONSUME, 4).
-define(DB_CONSUME_WAIT, 5).
-define(DB_CURRENT, 6).
-define(DB_FIRST, 7).
-define(DB_GET_BOTH, 8).
-define(DB_GET_BOTHC, 9).
-define(DB_GET_BOTH_RANGE, 10).
-define(DB_GET_RECNO, 11).
-define(DB_JOIN_ITEM, 12).
-define(DB_KEYFIRST, 13).
-define(DB_KEYLAST, 14).
-define(DB_LAST, 15).
-define(DB_NEXT, 16).
-define(DB_NEXT_DUP, 17).
-define(DB_NEXT_NODUP, 18).
-define(DB_NODUPDATA, 19).
-define(DB_NOOVERWRITE, 20).
-define(DB_OVERWRITE_DUP, 21).
-define(DB_POSITION, 22).
-define(DB_PREV, 23).
-define(DB_PREV_DUP, 24).
-define(DB_PREV_NODUP, 25).
-define(DB_SET, 26).
-define(DB_SET_RANGE, 27).
-define(DB_SET_RECNO, 28).
-define(DB_UPDATE_SECONDARY, 29).
-define(DB_POSITION, 22).
-define(DB_PREV, 23).
-define(DB_PREV_DUP, 24).
-define(DB_PREV_NODUP, 25).
-define(DB_SET, 26).
-define(DB_SET_RANGE, 27).
-define(DB_SET_RECNO, 28).
-define(DB_UPDATE_SECONDARY, 29).
-define(DB_SET_LTE, 30).
-define(DB_GET_BOTH_LTE, 31).

View file

@ -3,3 +3,4 @@ set_cachesize 0 536870912 1
set_lg_max 104857600
set_lg_bsize 536870912
log_set_config DB_LOG_IN_MEMORY
set_flags DB_LOG_AUTOREMOVE

View file

@ -24,7 +24,7 @@
%% -------------------------------------------------------------------
-module(stress_SUITE).
-compile(export_all).
-include_lib("ct.hrl").
-include_lib("common_test/include/ct.hrl").
%% NOTE: all of the tests are set for a low number of iterations to guarantee
%% that they all pass and run in a reasonable amount of time. That kinda defeats
@ -36,11 +36,21 @@ all() ->
write_array_test,
write_bytes_test].
dbconfig(Config) ->
Cfg = [
{set_data_dir, ?config(priv_dir, Config)},
{set_flags, 'DB_TXN_WRITE_NOSYNC'},
{set_cachesize, '0 536870912 1'},
{set_lg_max, '1048576000'},
{set_lg_bsize, '5368709120'},
{set_log_config, 'DB_LOG_IN_MEMORY'}
],
list_to_binary(lists:flatten([io_lib:format("~s ~s\n", [K,V]) || {K, V} <- Cfg])).
init_per_suite(Config) ->
{ok, Cwd} = file:get_cwd(),
{ok, _} = file:copy(lists:append([Cwd, "/../../int_test/DB_CONFIG"]),
lists:append([Cwd, "/DB_CONFIG"])),
crypto:start(),
DbHome = ?config(priv_dir, Config),
os:putenv("DB_HOME", DbHome),
ok = file:write_file(DbHome ++ "DB_CONFIG", dbconfig(Config)),
Config.
end_per_suite(_Config) ->

BIN
rebar vendored

Binary file not shown.

View file

@ -38,3 +38,7 @@
{pre_hooks, [{compile, "make -C c_src"}]}.
{post_hooks, [{clean, "make -C c_src clean"}]}.
{cover_enabled, true}.
{ct_extra_params, "-boot start_sasl -s snmp"}.

View file

@ -188,6 +188,8 @@ open(Name, Type, Opts) ->
case Type of
btree -> TypeCode = ?DB_TYPE_BTREE;
hash -> TypeCode = ?DB_TYPE_HASH;
recno -> TypeCode = ?DB_TYPE_RECNO;
queue -> TypeCode = ?DB_TYPE_QUEUE;
unknown -> TypeCode = ?DB_TYPE_UNKNOWN %% BDB automatically determines if file exists
end,
Flags = process_flags(lists:umerge(Opts, [auto_commit, threaded])),
@ -2276,7 +2278,7 @@ stop() ->
%% ====================================================================
init() ->
case erl_ddll:load_driver(code:priv_dir(bdberl), bdberl_drv) of
case erl_ddll:load_driver(priv_dir(), bdberl_drv) of
ok -> ok;
{error, permanent} -> ok % Means that the driver is already active
end,
@ -2295,6 +2297,15 @@ init() ->
erlang:put(bdb_port, Port),
Port.
priv_dir() ->
case code:priv_dir(?MODULE) of
Name when is_list(Name) ->
Name;
{error, bad_name} ->
{ok, Cwd} = file:get_cwd(),
filename:absname(filename:join(Cwd, "../priv"))
end.
get_port() ->
case erlang:get(bdb_port) of
undefined -> init();

View file

@ -75,9 +75,11 @@ all() ->
dbconfig(Config) ->
Cfg = [{set_data_dir, ?config(priv_dir, Config)},
Cfg = [
{set_data_dir, ?config(priv_dir, Config)},
{set_flags, 'DB_TXN_NOSYNC'},
{log_set_config, 'DB_LOG_IN_MEMORY'}],
{log_set_config, 'DB_LOG_IN_MEMORY'}
],
list_to_binary(lists:flatten([io_lib:format("~s ~s\n", [K,V]) || {K, V} <- Cfg])).
@ -342,7 +344,7 @@ hash_stat_should_report_on_success(_Config) ->
1 = proplists:get_value(nkeys, Stat1),
1 = proplists:get_value(ndata, Stat1),
done.
stat_should_fail_on_bad_dbref(_Config) ->
{error, invalid_db} = bdberl:stat(10000000, []),
done.
@ -382,7 +384,7 @@ data_dirs_info_should_report_on_success(_Config) ->
lg_dir_info_should_report_on_success(_Config) ->
{ok, _LgDir, _Fsid, _MBytesAvail} = bdberl:get_lg_dir_info().
%% Check the bdberl_logger gets reinstalled after stopping
start_after_stop_should_be_safe(_Config) ->
@ -411,5 +413,5 @@ start_after_stop_should_be_safe(_Config) ->
end,
true = lists:keymember(bdberl_logger, 1, supervisor:which_children(kernel_safe_sup)),
ok.

View file

@ -1,3 +0,0 @@
{export, ["test/test.cover"]}.
{level, details}.
{incl_dirs_r, ["ebin"]}.