This commit is contained in:
Sergey Yelin 2011-07-17 23:55:48 +04:00
parent 7ab049b119
commit a765b45841
7 changed files with 283 additions and 431 deletions

1
.gitignore vendored
View file

@ -9,3 +9,4 @@ int_test/test.cover
bdberl-*
priv/mibs
c_src/db-*.tar.gz
.eunit

View file

@ -1,9 +1,15 @@
#!/bin/sh
WORKDIR=`pwd`/system
TARGETDIR=`(cd .. && pwd)`/priv
if [ `basename $PWD` != "c_src" ]; then
pushd c_src
fi
DB_VER="4.7.25"
BASEDIR="$PWD"
WORKDIR=$BASEDIR/system
TARGETDIR=$BASEDIR/../priv
DB_VER="5.1.25"
## Check for necessary tarball
if [ ! -f "db-${DB_VER}.tar.gz" ]; then

View file

@ -65,6 +65,8 @@
-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).
@ -88,243 +90,277 @@
-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
-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.
-define(DB_LOCK_NOTGRANTED, -30993). % Lock unavailable.
-define(DB_LOG_BUFFER_FULL, -30992). % In-memory log buffer full.
-define(DB_LOG_VERIFY_BAD, -30991). % Log verification failed.
-define(DB_NOSERVER, -30990). % Server panic return.
-define(DB_NOSERVER_HOME, -30989). % Bad home sent to server.
-define(DB_NOSERVER_ID, -30988). % Bad ID sent to server.
-define(DB_NOTFOUND, -30987). % Key/data pair not found (EOF).
-define(DB_OLD_VERSION, -30986). % Out-of-date version.
-define(DB_PAGE_NOTFOUND, -30985). % Requested page not found.
-define(DB_REP_DUPMASTER, -30984). % There are two masters.
-define(DB_REP_HANDLE_DEAD, -30983). % Rolled back a commit.
-define(DB_REP_HOLDELECTION, -30982). % Time to hold an election.
-define(DB_REP_IGNORE, -30981). % This msg should be ignored.
-define(DB_REP_ISPERM, -30980). % Cached not written perm written.
-define(DB_REP_JOIN_FAILURE, -30979). % Unable to join replication group.
-define(DB_REP_LEASE_EXPIRED, -30978). % Master lease has expired.
-define(DB_REP_LOCKOUT, -30977). % API/Replication lockout now.
-define(DB_REP_NEWSITE, -30976). % New site entered system.
-define(DB_REP_NOTPERM, -30975). % Permanent log record not written.
-define(DB_REP_UNAVAIL, -30974). % Site cannot currently be reached.
-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_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_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_HOTBACKUP_IN_PROGRESS, 16#00000800).
-define(DB_IGNORE_LEASE, 16#00001000).
-define(DB_IMMUTABLE_KEY, 16#00000002).
-define(DB_INIT_CDB, 16#00000040).
-define(DB_INIT_LOCK, 16#00000080).
-define(DB_INIT_LOG, 16#00000100).
-define(DB_INIT_MPOOL, 16#00000200).
-define(DB_INIT_REP, 16#00000400).
-define(DB_INIT_TXN, 16#00000800).
-define(DB_INORDER, 16#00000020).
-define(DB_JOIN_NOSORT, 16#00000001).
-define(DB_LOCKDOWN, 16#00001000).
-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#00001000).
-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#00002000).
-define(DB_NO_CHECKPOINT, 16#00002000).
-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#00004000).
-define(DB_PR_PAGE, 16#00000010).
-define(DB_PR_RECOVERYTEST, 16#00000020).
-define(DB_RDONLY, 16#00000400).
-define(DB_RDWRMASTER, 16#00004000).
-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#00008000).
-define(DB_REGION_INIT, 16#00020000).
-define(DB_REGISTER, 16#00010000).
-define(DB_RENUMBER, 16#00000080).
-define(DB_REPMGR_CONF_2SITE_STRICT, 16#00000001).
-define(DB_REPMGR_CONF_ELECTIONS, 16#00000002).
-define(DB_REPMGR_PEER, 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_BULK, 16#00000008).
-define(DB_REP_CONF_DELAYCLIENT, 16#00000010).
-define(DB_REP_CONF_INMEM, 16#00000020).
-define(DB_REP_CONF_LEASE, 16#00000040).
-define(DB_REP_CONF_NOWAIT, 16#00000080).
-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_CLEAR, 16#00000001).
-define(DB_STAT_LOCK_CONF, 16#00000008).
-define(DB_STAT_LOCK_LOCKERS, 16#00000010).
-define(DB_STAT_LOCK_OBJECTS, 16#00000020).
-define(DB_STAT_LOCK_PARAMS, 16#00000040).
-define(DB_STAT_MEMP_HASH, 16#00000008).
-define(DB_STAT_MEMP_NOERROR, 16#00000010).
-define(DB_STAT_SUBSYSTEM, 16#00000002).
-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#00020000).
-define(DB_THREAD, 16#00000010).
-define(DB_TIME_NOTGRANTED, 16#00040000).
-define(DB_TRUNCATE, 16#00008000).
-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#00010000).
-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.
-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_NOSYNC, 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_WRITECURSOR, 30).
-define(DB_WRITELOCK, 31).
-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_SET_LTE, 30).
-define(DB_GET_BOTH_LTE, 31).

View file

@ -1,110 +0,0 @@
%% -------------------------------------------------------------------
%%
%% bdberl: Port Driver Stress tests
%% Copyright (c) 2008 The Hive. All rights reserved.
%%
%% 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
%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
%% copies of the Software, and to permit persons to whom the Software is
%% furnished to do so, subject to the following conditions:
%%
%% The above copyright notice and this permission notice shall be included in
%% all copies or substantial portions of the Software.
%%
%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
%% THE SOFTWARE.
%%
%% -------------------------------------------------------------------
-module(stress_SUITE).
-compile(export_all).
-include_lib("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
%% the purpose of the test, tho. Work is ongoing to make this a useful test suite.
all() ->
[rewrite_array_test,
rewrite_bytes_test,
write_array_test,
write_bytes_test].
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(),
Config.
end_per_suite(_Config) ->
ok.
init_per_testcase(TestCase, Config) ->
Size = 1024 * 1024,
Chunk = crypto:rand_bytes(Size),
Name = io_lib:format("~p.db", [TestCase]),
{ok, Db} = bdberl:open(Name, hash),
[{size, Size}, {chunk, Chunk}, {db, Db}|Config].
end_per_testcase(_TestCase, Config) ->
bdberl:close(?config(db, Config)),
ok.
%%---------------------------------------------------------------------------
rewrite_array_test(Config) ->
%% If you try to run this one for more than 2K iterations than the Erlang
%% VM will die with a memory allocation error when creating the binary.
ct:print("Running rewrite_array test for 2000 iterations..."),
Chunk = ?config(chunk, Config),
rewrite_array(?config(db, Config), Chunk, [Chunk], 20).
rewrite_array(_Db, _Block, _Bytes, 0) ->
ok;
rewrite_array(Db, Block, Bytes, Iter) ->
bdberl:put(Db, 1, Bytes),
rewrite_array(Db, Block, [Block|Bytes], Iter - 1).
%%---------------------------------------------------------------------------
rewrite_bytes_test(Config) ->
ct:print("Running rewrite_bytes test for 2500 iterations..."),
rewrite_bytes(?config(db, Config), ?config(chunk, Config), 25).
rewrite_bytes(_Db, _Bytes, 0) ->
ok;
rewrite_bytes(Db, Bytes, Iter) ->
bdberl:put(Db, 1, Bytes),
rewrite_bytes(Db, Bytes, Iter - 1).
%%---------------------------------------------------------------------------
write_array_test(Config) ->
ct:print("Running write_array test for 150 iterations..."),
Chunk = ?config(chunk, Config),
write_array(?config(db, Config), Chunk, [Chunk], 15).
write_array(_Db, _Block, _Bytes, 0) ->
ok;
write_array(Db, Block, Bytes, Iter) ->
bdberl:put(Db, Iter, Bytes),
write_array(Db, Block, [Block|Bytes], Iter - 1).
%%---------------------------------------------------------------------------
write_bytes_test(Config) ->
ct:print("Running write_bytes test for 2500 iterations..."),
write_bytes(?config(db, Config), ?config(chunk, Config), 25).
write_bytes(_Db, _Bytes, 0) ->
ok;
write_bytes(Db, Bytes, Iter) ->
bdberl:put(Db, Iter, Bytes),
write_bytes(Db, Bytes, Iter - 1).

View file

@ -1,80 +0,0 @@
%% -------------------------------------------------------------------
%%
%% bdberl: Port Driver Thrash tests
%% Copyright (c) 2008 The Hive. All rights reserved.
%%
%% 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
%% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
%% copies of the Software, and to permit persons to whom the Software is
%% furnished to do so, subject to the following conditions:
%%
%% The above copyright notice and this permission notice shall be included in
%% all copies or substantial portions of the Software.
%%
%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
%% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
%% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
%% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
%% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
%% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
%% THE SOFTWARE.
%%
%% -------------------------------------------------------------------
-module(thrash_SUITE).
-compile(export_all).
all() ->
[test_thrash].
-define(PROCS, 10).
test_thrash(_Config) ->
%% Spin up 15 processes (async thread pool is 10)
start_procs(?PROCS),
wait_for_finish(?PROCS).
start_procs(0) ->
ok;
start_procs(Count) ->
spawn_link(?MODULE, thrash_run, [self()]),
start_procs(Count-1).
wait_for_finish(0) ->
ok;
wait_for_finish(Count) ->
receive
{finished, Pid} ->
ct:print("~p is done; ~p remaining.\n", [Pid, Count-1]),
wait_for_finish(Count-1)
end.
thrash_run(Owner) ->
%% Seed the RNG
{A1, A2, A3} = now(),
random:seed(A1, A2, A3),
%% Open up a port and database
{ok, 0} = bdberl:open("thrash", btree),
%% Start thrashing
thrash_incr_loop(Owner, 1000).
thrash_incr_loop(Owner, 0) ->
Owner ! {finished, self()};
thrash_incr_loop(Owner, Count) ->
% ct:print("~p", [Count]),
%% Choose random key
Key = random:uniform(1200),
%% Start a txn that will read the current value of the key and increment by 1
F = fun(_Key, Value) ->
case Value of
not_found -> 0;
Value -> Value + 1
end
end,
{ok, _} = bdberl:update(0, Key, F),
thrash_incr_loop(Owner, Count-1).

View file

@ -182,6 +182,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])),

View file

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