From db8a80735b9ce54f26d3e6796d0ae647455ca854 Mon Sep 17 00:00:00 2001 From: "Gregory P. Smith" Date: Mon, 5 Jun 2006 01:56:15 +0000 Subject: [PATCH] * support DBEnv.lsn_reset() method on BerkeleyDB >= 4.4 [patch #1494902] --- Lib/bsddb/dbobj.py | 10 ++++++++-- Modules/_bsddb.c | 25 +++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/Lib/bsddb/dbobj.py b/Lib/bsddb/dbobj.py index f5bd0dcb742..530de4f99a2 100644 --- a/Lib/bsddb/dbobj.py +++ b/Lib/bsddb/dbobj.py @@ -91,11 +91,13 @@ class DBEnv: return apply(self._cobj.lock_stat, args, kwargs) def log_archive(self, *args, **kwargs): return apply(self._cobj.log_archive, args, kwargs) + + def set_get_returns_none(self, *args, **kwargs): + return apply(self._cobj.set_get_returns_none, args, kwargs) + if db.version() >= (4,0): def log_stat(self, *args, **kwargs): return apply(self._cobj.log_stat, args, kwargs) - def set_get_returns_none(self, *args, **kwargs): - return apply(self._cobj.set_get_returns_none, args, kwargs) if db.version() >= (4,1): def dbremove(self, *args, **kwargs): @@ -105,6 +107,10 @@ class DBEnv: def set_encrypt(self, *args, **kwargs): return apply(self._cobj.set_encrypt, args, kwargs) + if db.version() >= (4,4): + def lsn_reset(self, *args, **kwargs): + return apply(self._cobj.lsn_reset, args, kwargs) + class DB(DictMixin): def __init__(self, dbenv, *args, **kwargs): diff --git a/Modules/_bsddb.c b/Modules/_bsddb.c index 3c50a3974d9..16bdf66c840 100644 --- a/Modules/_bsddb.c +++ b/Modules/_bsddb.c @@ -4294,6 +4294,28 @@ DBEnv_lock_put(DBEnvObject* self, PyObject* args) RETURN_NONE(); } +#if (DBVER >= 44) +static PyObject* +DBEnv_lsn_reset(DBEnvObject* self, PyObject* args, PyObject* kwargs) +{ + int err; + char *file; + u_int32_t flags = 0; + static char* kwnames[] = { "file", "flags", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "z|i:lsn_reset", kwnames, + &file, &flags)) + return NULL; + CHECK_ENV_NOT_CLOSED(self); + + MYDB_BEGIN_ALLOW_THREADS; + err = self->db_env->lsn_reset(self->db_env, file, flags); + MYDB_END_ALLOW_THREADS; + RETURN_IF_ERR(); + RETURN_NONE(); +} +#endif /* DBVER >= 4.4 */ + #if (DBVER >= 40) static PyObject* DBEnv_log_stat(DBEnvObject* self, PyObject* args) @@ -4848,6 +4870,9 @@ static PyMethodDef DBEnv_methods[] = { {"log_archive", (PyCFunction)DBEnv_log_archive, METH_VARARGS}, #if (DBVER >= 40) {"log_stat", (PyCFunction)DBEnv_log_stat, METH_VARARGS}, +#endif +#if (DBVER >= 44) + {"lsn_reset", (PyCFunction)DBEnv_lsn_reset, METH_VARARGS|METH_KEYWORDS}, #endif {"set_get_returns_none",(PyCFunction)DBEnv_set_get_returns_none, METH_VARARGS}, {NULL, NULL} /* sentinel */