1 /* svn_bdb_compat.h --- Compatibility wrapper for different BDB versions.
3 * ====================================================================
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
20 * ====================================================================
23 #ifndef SVN_LIBSVN_FS_BDB_COMPAT_H
24 #define SVN_LIBSVN_FS_BDB_COMPAT_H
27 #include "svn_private_config.h"
31 #endif /* __cplusplus */
34 /* Symbols and constants */
36 /* BDB 4.1 introduced the DB_AUTO_COMMIT flag. Older versions can just
39 #define SVN_BDB_AUTO_COMMIT (DB_AUTO_COMMIT)
41 #define SVN_BDB_AUTO_COMMIT (0)
44 /* DB_INCOMPLETE is obsolete in BDB 4.1. */
46 #define SVN_BDB_HAS_DB_INCOMPLETE 1
48 #define SVN_BDB_HAS_DB_INCOMPLETE 0
51 /* In BDB 4.3, "buffer too small" errors come back with
52 DB_BUFFER_SMALL (instead of ENOMEM, which is now fatal). */
53 #ifdef DB_BUFFER_SMALL
54 #define SVN_BDB_DB_BUFFER_SMALL DB_BUFFER_SMALL
56 #define SVN_BDB_DB_BUFFER_SMALL ENOMEM
59 /* BDB 4.4 introdiced the DB_REGISTER flag for DBEnv::open that allows
60 for automatic recovery of the databases after a program crash. */
62 #define SVN_BDB_AUTO_RECOVER (DB_REGISTER | DB_RECOVER)
64 #define SVN_BDB_AUTO_RECOVER (0)
68 /* Explicit BDB version check. */
69 #define SVN_BDB_VERSION_AT_LEAST(major,minor) \
70 (DB_VERSION_MAJOR > (major) \
71 || (DB_VERSION_MAJOR == (major) && DB_VERSION_MINOR >= (minor)))
76 /* In BDB 4.1, DB->open takes a transaction parameter. We'll ignore it
77 when building with 4.0. */
78 #if SVN_BDB_VERSION_AT_LEAST(4,1)
79 #define SVN_BDB_OPEN_PARAMS(env,txn) (env), (txn)
81 #define SVN_BDB_OPEN_PARAMS(env,txn) (env)
84 /* In BDB 4.3, the error gatherer function grew a new DBENV parameter,
85 and the MSG parameter's type changed. */
86 #if SVN_BDB_VERSION_AT_LEAST(4,3)
87 /* Prevents most compilers from whining about unused parameters. */
88 #define SVN_BDB_ERROR_GATHERER_IGNORE(varname) ((void)(varname))
90 #define bdb_error_gatherer(param1, param2, param3) \
91 bdb_error_gatherer(param2, char *msg)
92 #define SVN_BDB_ERROR_GATHERER_IGNORE(varname) ((void)0)
95 /* In BDB 4.3 and later, the file names in DB_ENV->open and DB->open
96 are assumed to be encoded in UTF-8 on Windows. */
97 #if defined(WIN32) && SVN_BDB_VERSION_AT_LEAST(4,3)
98 #define SVN_BDB_PATH_UTF8 (1)
100 #define SVN_BDB_PATH_UTF8 (0)
103 /* In BDB 4.6, the cursor routines were renamed, and the old names
105 #if SVN_BDB_VERSION_AT_LEAST(4,6)
106 #define svn_bdb_dbc_close(c) ((c)->close(c))
107 #define svn_bdb_dbc_count(c,r,f) ((c)->count(c,r,f))
108 #define svn_bdb_dbc_del(c,f) ((c)->del(c,f))
109 #define svn_bdb_dbc_dup(c,p,f) ((c)->dup(c,p,f))
110 #define svn_bdb_dbc_get(c,k,d,f) ((c)->get(c,k,d,f))
111 #define svn_bdb_dbc_pget(c,k,p,d,f) ((c)->pget(c,k,p,d,f))
112 #define svn_bdb_dbc_put(c,k,d,f) ((c)->put(c,k,d,f))
114 #define svn_bdb_dbc_close(c) ((c)->c_close(c))
115 #define svn_bdb_dbc_count(c,r,f) ((c)->c_count(c,r,f))
116 #define svn_bdb_dbc_del(c,f) ((c)->c_del(c,f))
117 #define svn_bdb_dbc_dup(c,p,f) ((c)->c_dup(c,p,f))
118 #define svn_bdb_dbc_get(c,k,d,f) ((c)->c_get(c,k,d,f))
119 #define svn_bdb_dbc_pget(c,k,p,d,f) ((c)->c_pget(c,k,p,d,f))
120 #define svn_bdb_dbc_put(c,k,d,f) ((c)->c_put(c,k,d,f))
123 /* Before calling db_create, we must check that the version of the BDB
124 libraries we're linking with is the same as the one we compiled
125 against, because the DB->open call is not binary compatible between
126 BDB 4.0 and 4.1. This function returns DB_OLD_VERSION if the
127 compile-time and run-time versions of BDB don't match. */
128 int svn_fs_bdb__check_version(void);
133 #endif /* __cplusplus */
135 #endif /* SVN_LIBSVN_FS_BDB_COMPAT_H */