* support DBEnv.log_stat() method on BerkeleyDB >= 4.0 [patch #1494885]
This commit is contained in:
parent
58ce5bc14c
commit
76a82e89ab
|
@ -91,6 +91,9 @@ class DBEnv:
|
||||||
return apply(self._cobj.lock_stat, args, kwargs)
|
return apply(self._cobj.lock_stat, args, kwargs)
|
||||||
def log_archive(self, *args, **kwargs):
|
def log_archive(self, *args, **kwargs):
|
||||||
return apply(self._cobj.log_archive, args, kwargs)
|
return apply(self._cobj.log_archive, 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):
|
def set_get_returns_none(self, *args, **kwargs):
|
||||||
return apply(self._cobj.set_get_returns_none, args, kwargs)
|
return apply(self._cobj.set_get_returns_none, args, kwargs)
|
||||||
|
|
||||||
|
|
|
@ -659,6 +659,13 @@ class BasicTransactionTestCase(BasicTestCase):
|
||||||
except db.DBIncompleteError:
|
except db.DBIncompleteError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
if db.version() >= (4,0):
|
||||||
|
statDict = self.env.log_stat(0);
|
||||||
|
assert statDict.has_key('magic')
|
||||||
|
assert statDict.has_key('version')
|
||||||
|
assert statDict.has_key('cur_file')
|
||||||
|
assert statDict.has_key('region_nowait')
|
||||||
|
|
||||||
# must have at least one log file present:
|
# must have at least one log file present:
|
||||||
logs = self.env.log_archive(db.DB_ARCH_ABS | db.DB_ARCH_LOG)
|
logs = self.env.log_archive(db.DB_ARCH_ABS | db.DB_ARCH_LOG)
|
||||||
assert logs != None
|
assert logs != None
|
||||||
|
|
|
@ -4294,6 +4294,71 @@ DBEnv_lock_put(DBEnvObject* self, PyObject* args)
|
||||||
RETURN_NONE();
|
RETURN_NONE();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if (DBVER >= 40)
|
||||||
|
static PyObject*
|
||||||
|
DBEnv_log_stat(DBEnvObject* self, PyObject* args)
|
||||||
|
{
|
||||||
|
int err;
|
||||||
|
DB_LOG_STAT* statp = NULL;
|
||||||
|
PyObject* d = NULL;
|
||||||
|
u_int32_t flags = 0;
|
||||||
|
|
||||||
|
if (!PyArg_ParseTuple(args, "|i:log_stat", &flags))
|
||||||
|
return NULL;
|
||||||
|
CHECK_ENV_NOT_CLOSED(self);
|
||||||
|
|
||||||
|
MYDB_BEGIN_ALLOW_THREADS;
|
||||||
|
err = self->db_env->log_stat(self->db_env, &statp, flags);
|
||||||
|
MYDB_END_ALLOW_THREADS;
|
||||||
|
RETURN_IF_ERR();
|
||||||
|
|
||||||
|
/* Turn the stat structure into a dictionary */
|
||||||
|
d = PyDict_New();
|
||||||
|
if (d == NULL) {
|
||||||
|
if (statp)
|
||||||
|
free(statp);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define MAKE_ENTRY(name) _addIntToDict(d, #name, statp->st_##name)
|
||||||
|
|
||||||
|
MAKE_ENTRY(magic);
|
||||||
|
MAKE_ENTRY(version);
|
||||||
|
MAKE_ENTRY(mode);
|
||||||
|
MAKE_ENTRY(lg_bsize);
|
||||||
|
#if (DBVER >= 44)
|
||||||
|
MAKE_ENTRY(lg_size);
|
||||||
|
MAKE_ENTRY(record);
|
||||||
|
#endif
|
||||||
|
#if (DBVER <= 40)
|
||||||
|
MAKE_ENTRY(lg_max);
|
||||||
|
#endif
|
||||||
|
MAKE_ENTRY(w_mbytes);
|
||||||
|
MAKE_ENTRY(w_bytes);
|
||||||
|
MAKE_ENTRY(wc_mbytes);
|
||||||
|
MAKE_ENTRY(wc_bytes);
|
||||||
|
MAKE_ENTRY(wcount);
|
||||||
|
MAKE_ENTRY(wcount_fill);
|
||||||
|
#if (DBVER >= 44)
|
||||||
|
MAKE_ENTRY(rcount);
|
||||||
|
#endif
|
||||||
|
MAKE_ENTRY(scount);
|
||||||
|
MAKE_ENTRY(cur_file);
|
||||||
|
MAKE_ENTRY(cur_offset);
|
||||||
|
MAKE_ENTRY(disk_file);
|
||||||
|
MAKE_ENTRY(disk_offset);
|
||||||
|
MAKE_ENTRY(maxcommitperflush);
|
||||||
|
MAKE_ENTRY(mincommitperflush);
|
||||||
|
MAKE_ENTRY(regsize);
|
||||||
|
MAKE_ENTRY(region_wait);
|
||||||
|
MAKE_ENTRY(region_nowait);
|
||||||
|
|
||||||
|
#undef MAKE_ENTRY
|
||||||
|
free(statp);
|
||||||
|
return d;
|
||||||
|
} /* DBEnv_log_stat */
|
||||||
|
#endif /* DBVER >= 4.0 for log_stat method */
|
||||||
|
|
||||||
|
|
||||||
static PyObject*
|
static PyObject*
|
||||||
DBEnv_lock_stat(DBEnvObject* self, PyObject* args)
|
DBEnv_lock_stat(DBEnvObject* self, PyObject* args)
|
||||||
|
@ -4781,6 +4846,9 @@ static PyMethodDef DBEnv_methods[] = {
|
||||||
{"lock_put", (PyCFunction)DBEnv_lock_put, METH_VARARGS},
|
{"lock_put", (PyCFunction)DBEnv_lock_put, METH_VARARGS},
|
||||||
{"lock_stat", (PyCFunction)DBEnv_lock_stat, METH_VARARGS},
|
{"lock_stat", (PyCFunction)DBEnv_lock_stat, METH_VARARGS},
|
||||||
{"log_archive", (PyCFunction)DBEnv_log_archive, METH_VARARGS},
|
{"log_archive", (PyCFunction)DBEnv_log_archive, METH_VARARGS},
|
||||||
|
#if (DBVER >= 40)
|
||||||
|
{"log_stat", (PyCFunction)DBEnv_log_stat, METH_VARARGS},
|
||||||
|
#endif
|
||||||
{"set_get_returns_none",(PyCFunction)DBEnv_set_get_returns_none, METH_VARARGS},
|
{"set_get_returns_none",(PyCFunction)DBEnv_set_get_returns_none, METH_VARARGS},
|
||||||
{NULL, NULL} /* sentinel */
|
{NULL, NULL} /* sentinel */
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue