diff options
author | Matthias Klose <doko@ubuntu.com> | 2010-03-15 12:46:18 (GMT) |
---|---|---|
committer | Matthias Klose <doko@ubuntu.com> | 2010-03-15 12:46:18 (GMT) |
commit | 54cc539a2b06d4fc22358862dc72f3c9ede7b2d4 (patch) | |
tree | 536c3885d9e8123ff2f7b96499f0ad33ee787d7e /Modules | |
parent | f56813997fb546207ef1f9d15325dff2929dc455 (diff) | |
download | cpython-54cc539a2b06d4fc22358862dc72f3c9ede7b2d4.zip cpython-54cc539a2b06d4fc22358862dc72f3c9ede7b2d4.tar.gz cpython-54cc539a2b06d4fc22358862dc72f3c9ede7b2d4.tar.bz2 |
- Issue #6949: Allow the _bsddb extension to be built with db-4.8.x.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_bsddb.c | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/Modules/_bsddb.c b/Modules/_bsddb.c index 5aedfca..9ae8e52 100644 --- a/Modules/_bsddb.c +++ b/Modules/_bsddb.c @@ -215,6 +215,10 @@ static PyObject* DBRepUnavailError; /* DB_REP_UNAVAIL */ #define DB_BUFFER_SMALL ENOMEM #endif +#if (DBVER < 48) +#define DB_GID_SIZE DB_XIDDATASIZE +#endif + /* --------------------------------------------------------------------- */ /* Structure definitions */ @@ -4501,7 +4505,11 @@ DBEnv_txn_recover(DBEnvObject* self) DBTxnObject *txn; #define PREPLIST_LEN 16 DB_PREPLIST preplist[PREPLIST_LEN]; +#if (DBVER < 48) long retp; +#else + u_int32_t retp; +#endif CHECK_ENV_NOT_CLOSED(self); @@ -4522,7 +4530,7 @@ DBEnv_txn_recover(DBEnvObject* self) flags=DB_NEXT; /* Prepare for next loop pass */ for (i=0; i<retp; i++) { gid=PyBytes_FromStringAndSize((char *)(preplist[i].gid), - DB_XIDDATASIZE); + DB_GID_SIZE); if (!gid) { Py_DECREF(list); return NULL; @@ -5047,6 +5055,7 @@ DBEnv_set_private(DBEnvObject* self, PyObject* private_obj) } +#if (DBVER < 48) static PyObject* DBEnv_set_rpc_server(DBEnvObject* self, PyObject* args, PyObject* kwargs) { @@ -5068,6 +5077,7 @@ DBEnv_set_rpc_server(DBEnvObject* self, PyObject* args, PyObject* kwargs) RETURN_IF_ERR(); RETURN_NONE(); } +#endif static PyObject* DBEnv_set_verbose(DBEnvObject* self, PyObject* args) @@ -5949,9 +5959,9 @@ DBTxn_prepare(DBTxnObject* self, PyObject* args) if (!PyArg_ParseTuple(args, "s#:prepare", &gid, &gid_size)) return NULL; - if (gid_size != DB_XIDDATASIZE) { + if (gid_size != DB_GID_SIZE) { PyErr_SetString(PyExc_TypeError, - "gid must be DB_XIDDATASIZE bytes long"); + "gid must be DB_GID_SIZE bytes long"); return NULL; } @@ -6541,8 +6551,10 @@ static PyMethodDef DBEnv_methods[] = { #endif {"set_get_returns_none",(PyCFunction)DBEnv_set_get_returns_none, METH_VARARGS}, {"txn_recover", (PyCFunction)DBEnv_txn_recover, METH_NOARGS}, +#if (DBVER < 48) {"set_rpc_server", (PyCFunction)DBEnv_set_rpc_server, METH_VARARGS||METH_KEYWORDS}, +#endif {"set_verbose", (PyCFunction)DBEnv_set_verbose, METH_VARARGS}, #if (DBVER >= 42) {"get_verbose", (PyCFunction)DBEnv_get_verbose, METH_VARARGS}, @@ -7091,6 +7103,7 @@ PyMODINIT_FUNC PyInit__bsddb(void) /* Note the two underscores */ ADD_INT(d, DB_MAX_PAGES); ADD_INT(d, DB_MAX_RECORDS); +#if (DBVER < 48) #if (DBVER >= 42) ADD_INT(d, DB_RPCCLIENT); #else @@ -7098,7 +7111,11 @@ PyMODINIT_FUNC PyInit__bsddb(void) /* Note the two underscores */ /* allow apps to be written using DB_RPCCLIENT on older Berkeley DB */ _addIntToDict(d, "DB_RPCCLIENT", DB_CLIENT); #endif +#endif + +#if (DBVER < 48) ADD_INT(d, DB_XA_CREATE); +#endif ADD_INT(d, DB_CREATE); ADD_INT(d, DB_NOMMAP); @@ -7115,7 +7132,13 @@ PyMODINIT_FUNC PyInit__bsddb(void) /* Note the two underscores */ ADD_INT(d, DB_INIT_TXN); ADD_INT(d, DB_JOINENV); +#if (DBVER >= 48) + ADD_INT(d, DB_GID_SIZE); +#else ADD_INT(d, DB_XIDDATASIZE); + /* Allow new code to work in old BDB releases */ + _addIntToDict(d, "DB_GID_SIZE", DB_XIDDATASIZE); +#endif ADD_INT(d, DB_RECOVER); ADD_INT(d, DB_RECOVER_FATAL); |