diff options
author | jerenkrantz <jerenkrantz@13f79535-47bb-0310-9956-ffa450edef68> | 2002-10-04 04:25:12 +0000 |
---|---|---|
committer | jerenkrantz <jerenkrantz@13f79535-47bb-0310-9956-ffa450edef68> | 2002-10-04 04:25:12 +0000 |
commit | 9a134d94505ac542ec3d230f666b7e6eccedab27 (patch) | |
tree | b80ea595871b542b314adb6083ce1e815c32ba8e /dbm/apr_dbm_berkeleydb.c | |
parent | 9f904a30ba0e4ee6ae7770a121cf47b24ab1db6d (diff) | |
download | libapr-util-9a134d94505ac542ec3d230f666b7e6eccedab27.tar.gz |
Add further support for DB_AUTO_COMMIT flag which is required in DB4.1+
when a NULL transaction is passed.
Note that we treat DB 4.0 as DB_VER == 3, while higher versions of 4.x are
treated as DB_VER == 4 which has these API changes.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr-util/trunk@58773 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'dbm/apr_dbm_berkeleydb.c')
-rw-r--r-- | dbm/apr_dbm_berkeleydb.c | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/dbm/apr_dbm_berkeleydb.c b/dbm/apr_dbm_berkeleydb.c index 1840aa4d..7b13629c 100644 --- a/dbm/apr_dbm_berkeleydb.c +++ b/dbm/apr_dbm_berkeleydb.c @@ -73,12 +73,14 @@ */ #if defined(DB_VERSION_MAJOR) && (DB_VERSION_MAJOR == 4) -/* DB 4.1 has an altered open() argument list. */ +/* We will treat anything greater than 4.1 as DB4. + * We can treat 4.0 as DB3. + */ #if defined(DB_VERSION_MINOR) && (DB_VERSION_MINOR >= 1) -#define DB_NEED_OPEN_TXN_ARG -#endif -/* Otherwise, DB4 can be treated as DB3. */ +#define DB_VER 4 +#else #define DB_VER 3 +#endif #elif defined(DB_VERSION_MAJOR) && (DB_VERSION_MAJOR == 3) #define DB_VER 3 #elif defined(DB_VERSION_MAJOR) && (DB_VERSION_MAJOR == 2) @@ -196,10 +198,13 @@ static apr_status_t vt_db_open(apr_dbm_t **pdb, const char *pathname, { int dberr; -#if DB_VER == 3 +#if DB_VER >= 3 +#if DB_VER == 4 + dbmode |= DB_AUTO_COMMIT; +#endif if ((dberr = db_create(&file.bdb, NULL, 0)) == 0) { if ((dberr = (*file.bdb->open)(file.bdb, -#ifdef DB_NEED_OPEN_TXN_ARG +#if DB_VER == 4 NULL, #endif pathname, NULL, @@ -283,6 +288,11 @@ static apr_status_t vt_db_store(apr_dbm_t *dbm, apr_datum_t key, apr_status_t rv; DBT ckey = { 0 }; DBT cvalue = { 0 }; +#if DB_VER == 4 + int flags = DB_AUTO_COMMIT; +#else + int flags = 0; +#endif ckey.data = key.dptr; ckey.size = key.dsize; @@ -294,7 +304,7 @@ static apr_status_t vt_db_store(apr_dbm_t *dbm, apr_datum_t key, TXN_ARG &ckey, &cvalue, - 0)); + flags)); /* store any error info into DBM, and return a status code. */ return set_error(dbm, rv); @@ -304,6 +314,11 @@ static apr_status_t vt_db_del(apr_dbm_t *dbm, apr_datum_t key) { apr_status_t rv; DBT ckey = { 0 }; +#if DB_VER == 4 + int flags = DB_AUTO_COMMIT; +#else + int flags = 0; +#endif ckey.data = key.dptr; ckey.size = key.dsize; @@ -311,7 +326,7 @@ static apr_status_t vt_db_del(apr_dbm_t *dbm, apr_datum_t key) rv = db2s((*GET_BDB(dbm->file)->del)(GET_BDB(dbm->file), TXN_ARG &ckey, - 0)); + flags)); /* store any error info into DBM, and return a status code. */ return set_error(dbm, rv); @@ -346,11 +361,8 @@ static apr_status_t vt_db_firstkey(apr_dbm_t *dbm, apr_datum_t * pkey) dberr = (*f->bdb->seq)(f->bdb, &first, &data, R_FIRST); #else if ((dberr = (*f->bdb->cursor)(f->bdb, NULL, &f->curs -#if DB_VER == 3 - , 0 -#elif (DB_VERSION_MAJOR == 2) && (DB_VERSION_MINOR > 5) - , 0 - +#if DB_VER >= 3 || ((DB_VERSION_MAJOR == 2) && (DB_VERSION_MINOR > 5)) + , 0 #endif )) == 0) { dberr = (*f->curs->c_get)(f->curs, &first, &data, DB_FIRST); |